Efficient Online Strategies for Renting Servers in the Cloud
EEfficient Online Strategies for RentingServers in the Cloud
Shahin Kamali, Alejandro L´opez-Ortiz
University of Waterloo, Canada.
Abstract.
In Cloud systems, we often deal with jobs that arrive and depart in anonline manner. Upon its arrival, a job should be assigned to a server. Each jobhas a size which defines the amount of resources that it needs. Servers have uni-form capacity and, at all times, the total size of jobs assigned to a server shouldnot exceed the capacity. This setting is closely related to the classic bin packingproblem. The difference is that, in bin packing, the objective is to minimize thetotal number of used servers. In the Cloud, however, the charge for each server isproportional to the length of the time interval it is rented for, and the goal is tominimize the cost involved in renting all used servers. Recently, certain bin pack-ing strategies were considered for renting servers in the Cloud [Li et al. SPAA’14].There, it is proved that all Any-Fit bin packing strategy has a competitive ratio ofat least µ , where µ is the max/min interval length ratio of jobs. It is also shownthat First Fit has a competitive ratio of µ + 13 while Best Fit is not competitiveat all. We observe that the lower bound of µ extends to all online algorithms. Wealso prove that, surprisingly, Next Fit algorithm has competitive ratio of at most µ + 1 . We also show that a variant of Next Fit achieves a competitive ratio of K × max { , µ/ ( K − } + 1 , where K is a parameter of the algorithm. In par-ticular, if the value of µ is known, the algorithm has a competitive ratio of µ + 2 ;this improves upon the existing upper bound of µ + 8 . Finally, we introduce asimple algorithm called Move To Front (M TF ) which has a competitive ratio ofat most µ + 7 and also promising average-case performance. We experimentallystudy the average-case performance of different algorithms and observe that thetypical behaviour of M TF is distinctively better than other algorithms. Bin packing is a classic problem in the context of online computation. The input is asequence of items of different sizes which appear in a sequential, online manner. Thegoal is to place these items into a minimum number of bins of uniform capacity so thatthe total size of items in each bin is no more than the uniform capacity of the bins. It isoften assumed that bins have size 1 and items have a positive size no more than 1. Theproblem is online in the sense that, upon receiving an item, an algorithm should place itinto a bin without any knowledge about the (size of) incoming items. A simple onlinestrategy is Next Fit (N F ) in which there is a single open bin at each time. If an incomingitem fits in the open bin, the algorithm places it there; otherwise, it closes the open binand opens a new bin for the item. Clearly, if we want to minimize the number of bins,there is no benefit in closing a bin. First Fit is an online algorithm that never closes a a r X i v : . [ c s . D S ] A ug in and places an incoming item in the first bin that has enough space for the item; ifsuch a bin does not exist, it opens a new bin. In First Fit, the bins are maintained in theorder that they are opened. Best Fit works similarly to First Fit except that it maintainsbins in the decreasing order of their fill level . The level of a bin is the total size of itemsplaced in the bin. Note that First Fit and Best Fit are greedy algorithm in the sense thatthey avoid opening new bins unless they have to. The algorithms with this property arecalled Any Fit algorithm.In many cloud systems, a set of jobs appear in an online manner that should beassigned to servers. Each job has a load which defines the amount of resources thatit needs. Depending on the application, the load of a job might be defined through itsmemory requirement, GPU resource usage, bandwidth usage, or a function of all ofthem. In cloud gaming systems, different instances of computer games are created in anonline fashion and run in cloud servers while players interact with the servers via thinclients [8,10]. Here, an instance of a game is a job which, depending on the game andthe number of users involved in it, has a load. In case of computer games, the load of ajob is mainly defined through the amount of GPU resources that it demands [10].With the above definition, any online bin packing algorithm can be used to assignjobs to servers. A job of load x can be treated as an item of size x which is assignedto a server (bin) of certain capacity. In this paper, we interchangeably use the terms‘job’ and ‘item’ as well as ‘server’ and ‘bin’. There are, however, distinctions betweenassigning jobs to servers and the bin packing problem. First, jobs depart the systemafter they complete; however, the classic bin packing is static in the sense that items areassumed to remain in the bins. When a job arrives, it is not clear when it completes andan algorithm should place it without any knowledge about its departure time. A moreimportant difference between the two problems is that, in the bin packing problem,the objective is to minimize the number of used bins. In other words, we can think ofbins as servers that one can buy and we would like to minimize the cost by buying asmaller number of servers. In the cloud, however, we want to rent the servers from cloudservice providers. For example, gaming companies such as OnLive [3] and GaiKai [2]offer cloud gaming services which are execute in public clouds like Amazon EC2 [1]. Arented server is charged by its usage (often in hourly or monthly basis). So, in order tominimize the cost, we need to minimize the total time that servers are rented. In doingso, an algorithm releases a server when all the assigned jobs to it are complete. Definition 1.
In the server renting problem , a set of jobs (items) appear in an onlinemanner. Each job has a load (size) that defines the amount of resources that it needs.Upon its arrival, a job should be assigned to a server (bin). Servers have uniform ca-pacity and the total load of jobs assigned to a server should not exceed the capacity.Besides the arrival time, each job has a departure time that indicates when it leavesthe system. The length of the interval between the arrival and departure time of a job isreferred to as the length of the job. Upon the arrival of a job, its length is unknown tothe online algorithm. To assign a job to a server, an online algorithm might open (rent)a new server or place it to any of the previously opened servers. When all jobs assignedto a server depart, that server is released. The goal is to minimize the total usage timeof servers . More precisely, assuming that an algorithm opens m bins B , . . . , B m , thetotal cost of the algorithm is (cid:80) mi =1 t i , where t i is the length of time period that B i has een open for. Without loss of generality, we assume the capacity of servers to be 1 andjobs have size at most 1. Also, we assume the length of jobs to be at least ∆ and at most µ ∆ where µ ≥ . When studying the server renting problem, we are mostly interested algorithmswhich have good worst-case and average-case performance. For measuring the worst-case performance, we compare an online algorithm with an optimal offline algorithmO PT that knows the entire sequence (all arrival times, lengths and sizes) in advance.An algorithm is said to be c -competitive (more precisely, asymptotic c -competitive) ifthe cost of serving any input sequence never exceeds c times the cost of O PT within anadditive constant. The Bin Packing problem has been widely studied over the past few decades. It is knownthat Next Fit is 2-competitive while Best Fit and First Fit are both 1.7-competitive [9].Generally, any Any Fit algorithm that avoids placing items in the bin with the lowestlevel is 1.7-competitive (these algorithms are called Almost Any Fit). The Harmonicfamily of algorithms is another class of bin packing algorithms which are based onplacing items of similar sizes together in the same bins. These algorithm generally havebetter competitive ratios than Any Fit algorithms. The best member of this family isHarmonic++ with a competitive ratio of 1.5888 [11]. However, these algorithms arerarely used in practice since of their poor average-case performance. It is known that noonline algorithm can be better than 1.54037-competitive [4].Coffman et al. [6] studied a dynamic version of the bin packing problem in whichitems arrive and depart the system. In that variant, it is assumed that the length of anyitem is revealed upon its arrival. It is proved that the competitive ratio of First Fit isbetween . and . while no online algorithm can do better than . [6]. For thediscrete version of the problem, where each item has size /k for some integer k , thecompetitive ratio of Any Fit algorithms is 3 while no online algorithm can do betterthan 2.48 [5]. Note that in all these results, the objective is to minimize the number ofopened bins.The online server renting problem as defined above was recently introduced by Leet al. [10] (some terms and notations in this paper are also borrowed from [10]). There,the authors prove that no Any Fit algorithm can be better than µ competitive. Recall that µ is the ratio between the length of the largest and the smallest item in the sequence.They also proved that the competitive ratio of First Fit is kk − µ + kk − + 1 when the sizeof items are upper bounded by /k ( k can be any positive value). In particular, when k = 1 (when there is no restriction on item sizes), First Fit is µ + 13 -competitive.On the other hand, they prove that Best Fit is not competitive, i.e., it does not achievea constant competitive ratio. This result is somewhat surprising as Best Fit is usuallyconsidered to be the superior algorithm for many bin packing applications. In [10] aslight modification of the First Fit algorithm is introduced which achieves a competitiveratio of µ + 55 / when the value of µ is not known to the algorithm and a competitiveratio of µ + 8 when the value of µ is known.3n this paper, we study the server renting problem and improve some of the resultspresented in [10]. We first observe that the lower bound of µ presented for competitive-ness of any Any Fit algorithm can be extended to any online algorithm. The focus of[10] has been on studying Any Fit algorithms. In the standard bin packing, Any Fit al-gorithms have an advantage over bounded-space algorithms which close the bins (sincethere is no harm in keeping bins open). However, we show that this is not the case forthe server renting problem and it makes sense to close some servers to avoid placingnew items in the bins opened by older items. In particular, we show that the competitiveratio of the Next Fit algorithm is at most kk − µ + 1 when items are smaller than /k and µ +1 in the general case. Note that this is much better than the ratio µ +13 of First Fit.We also introduce variants of Next Fit which achieve a ratio of K × max { , µK − } + 1 ,where K is a parameter of the algorithm and can be any positive value. In particular, ifthe value of µ is known, we get an algorithm with competitive ratio of µ + 2 which isbetter than µ + 8 of the algorithm presented in [10].Although Next Fit has a superior competitive ratio compared to Best Fit and FirstFit, unfortunately, it has a poor average-case performance relative to these algorithms.Our experiments indicate that, for sequences generated uniformly at random, Best Fitperforms generally better than the other two algorithms. To address this issue, we intro-duce a simple Any Fit algorithm called Move To Front (M TF ) which outperforms BestFit and other algorithms on random sequences. Moreover, in contrast to Best Fit, M TF is competitive and has a competitive ratio of at most µ + 7 . In this section, we present some basic results about the server renting problem. First, weshow that any online algorithm for the server renting problem has a competitive ratio ofat least µ . Our lower bound sequence is similar to that of [10] and is composed of itemswith uniform sizes and different lengths. Theorem 1.
The competitive ratio of any online algorithm for the server renting prob-lem is at least µ (cid:15) ( µ − where (cid:15) is a lower bound for the size of items.Proof. Recall that the lengths of all items are at least ∆ and at most µ ∆ . Consider asequence which is defined through phases. Each phase starts with (cid:15) items of size (cid:15) . Toplace these items, any algorithm has to open at least /(cid:15) bins. At time ∆ , (cid:15) − (cid:15) itemsdepart in an adversarial manner so that there is a single of item of size (cid:15) in /(cid:15) bins(some bins might get released at this time). The remaining items stay for a period oflength µ ∆ and the online algorithm keeps a single bin for each of them. At time µ ∆ , allitems depart and the phase ends. The cost of the online algorithm for each phase is atleast µ ∆ /(cid:15) (it keeps /(cid:15) bins for a period of µ ∆ ). O PT places items which have length µ ∆ together in a single bin and incurs a cost of µ ∆ for them. Other (cid:15) − (cid:15) items areplaced tightly together in /(cid:15) − bins for a period of length ∆ (after which all theyleave and their bins get closed. The cost of O PT for these items will be ∆ /(cid:15) − ∆ . Intotal, the cost of O PT will be µ ∆ + ∆ /(cid:15) − ∆ and the competitive ratio of the algorithmwill be µ ∆ /(cid:15)µ ∆ + ∆ /(cid:15) − ∆ = µ (cid:15) ( µ − . (cid:117)(cid:116) PT for serving any inputsequence. We say an item x is active at time t if t lies in the interval between the arrivaland the departure time of a . Let the span of an input sequence σ denote the lengthof time in which at least one item in σ is active. Clearly, the cost of any algorithm(including the offline O PT ) for serving σ is at least equal to the span of σ . Define the resource utilization of an item as the product of its size and its length. This way, the costof any algorithm for σ is at least equal to util ( σ ) , that is, the total resource utilizationof items in σ . So, the cost of an optimal algorithm for an input sequence is always lowerbounded by the span of the sequence and also by the total utilization of the sequence. Proposition 1.
For any input sequence σ , the cost of an optimal offline algorithm O PT is at least equal to span ( σ ) and util ( σ ) , namely, the span of σ and also the totalresource utilization of items in σ . When we allow arbitrary small items, Theorem 1 indicates that all algorithms havea competitive ratio of at least µ . This suggests that when item sizes are larger than afixed value, better competitive ratios can be achieved. Consider a sequence σ in whichall item sizes are larger than /k for some positive value k . The cost of any algorithmis at most equal to the total length of all items denoted by L ( σ ) (which happens whenno two items share a bin). On the other hand, the total resource utilization of items, andconsequently cost of O PT , is at least L ( σ ) /k . So, we get the following. Proposition 2. [10] When items sizes are lower bounded by /k ( k is a positive value),the competitive ratio of any online algorithm for the server renting problem is at mostequal to k . In this section, we analyze the Next Fit algorithm for the server renting problem. Recallthat for the bin packing problem Next Fit keeps exactly one bin open at any given time.If an incoming item does not fit in the open bin, it closes the bin and opens a new bin.For the server renting problem, we distinguish between closing and releasing a bin.When an item does not fit in the open bin, the algorithm closes the bin and does notrefer to it. Such a bin remains in the system (i.e., is being rented) until all items whichare placed there depart and it becomes released.
Example 1.
Consider sequence (cid:104) a = (0 . , , , b = (0 . , , , c = (0 . , , , . . . (cid:105) ofitems. The first element of each tuple indicates the size and the second and third respec-tively indicate arrival and departure times of an item. At time 1, item a arrives and isplaced in the single open bin. At time 2, item b arrives and is placed in the same bin(the level of the bin will be 0.7). At time 3, item c arrives which does not fit in the openbin; hence, the current open bin is closed and a new bin is opened for c . The closed binremains in the system (and a rental cost is paid for it) until time 6 where item b departsand the bin gets released. Theorem 2.
The competitive ratio of Next Fit for the server renting problem is at most µ − /k + 1 for serving sequences in which item sizes are no more than /k . If k < ,the ratio is at most µ + 1 . roof. Consider an arbitrary sequence σ and assume Next Fit opens m bins B , . . . , B m for serving σ . Let st i denote the length of the time interval at which the server B i hasbeen rented, i.e., the time after it is opened and before it is released. We refer to thisperiod as stretch of B i . Let N F ( σ ) denote the cost of Next Fit for serving σ ; we haveN F ( σ ) = (cid:80) m st i . The stretch of B i can be partitioned into two period. First, the inter-val between its opening time and when Next Fit closes the bin. The second period is thetime between the bin gets closed and when it gets released. Let st i and st i denote thelengths of first and second period of B i ( st i + st i = st i ). If a bin gets closed beforebeing released, the second period will be empty ( st i = 0) (see Figure 1).Let p ≤ m denote the number of bins which are closed before being revealed. Wecall these bins critical bins and for them we have st i (cid:54) = 0 . The main observation isthat, when a bin gets closed, it takes a time of length at most µ before it gets released,i.e., the second period of each bin has a length of at most µ ( st i ≤ µ for all i ). This isbecause no new item is placed in the bin in the second period. So, the total rental timefor the second period of all bins is no more than p × µ . On the other hand, the totalrental time of the first periods of all bins is no more than the span of input sequence.This is because the first period of a bin starts when that of previous bin is finished (notwo bins are in their first stretch period at the same time). So we haveN F ( σ ) = m (cid:88) i =1 st i = m (cid:88) i =1 st i + p (cid:88) i =1 st i ≤ span ( σ ) + p × µ ∆ (1)Assume that all items in σ are smaller or equal to /k for k ≥ . At the time of beingclosed, all critical bins have a level of at least − /k (otherwise the item that causedopening of a new bin could fit in such a bin). This implies that the number of criticalbins (i.e., p ) cannot be more than ω ( σ )1 − /k where ω ( σ ) is the total size of items in σ . Let util ( σ ) denote the total resource utilization of items in σ . Since the length of each itemis at least ∆ , we have util ( σ ) ≥ ω ( σ ) × ∆ , and by Proposition 1 ω ( σ ) ≤ O PT ( σ ) / ∆ .Consequently, p ≤ O PT ( σ )(1 − /k ) ∆ . Also, by Proposition 1, span ( σ ) ≤ O PT ( σ ) . Pluggingthese into Equation 1, we get the following inequality which completes the proof.N F ( σ ) ≤ O PT ( σ ) + O PT ( σ )1 − /k × µ Next, assume k ≤ . We define the amortized level of a critical bin B as the sum ofthe size of the item that closes B and the total size of items in B (at the time that NextFit closes it). By definition of N F , the amortized level of all critical bins is more than 1.At the same time, the size of each item is added at most twice in the total amortized cost(once as a part of a critical bin and once as the time that closes a critical bin). Hence,the total sum of the amortized levels of all critical bins is at most twice the total size ofsequence. This implies that the number of critical bins is no more than twice the totalsize of items in σ , i.e., p ≤ ω ( σ ) ≤ O PT ( σ ) / ∆ . Applying this into Equation 1, weget the following inequality which completes the proof. N F ( σ ) ≤ O PT ( σ ) + 2 O PT ( σ ) × µ (cid:117)(cid:116) B B B B B st st st st st st st st st TimeB B B B B st st st st st st st st Time μ + 1 μ + 1 μ + 1 μ + 1 μ + 1 ≤ μ + 1 head B B B B B B B B B Time
Fig. 1.
The stretch of bins in a packing of the Next Fit algorithm. In this example, bins B , B , and B are critical bins. The second periods of bins are highlighted in red. Note that the totallengths of the first periods defines the span of the input sequence. In this section, we modify the Next Fit algorithm to improve its competitive ratio. In-tuitively speaking, the competitive ratio of Next Fit improves for sequences formed bysmall items. On the other hand, as Proposition 2 implies, when all items are large, thecompetitive ratio is independent of µ . This suggest that the competitive ratio might getimproved when large and small items are treated separately. A similar approach is usedin [10] to improve the competitive ratio of First Fit. Modified Next Fit:
The algorithm has a parameter K ≥ and treats items smallerthan /K using the Next Fit strategy. Items larger or equal to /K are treatedseparately also using the Next Fit strategy. Theorem 3.
The competitive ratio of Modified Next Fit with parameter K is at most K × max { , µ/ ( K − } + 1 .Proof. Consider a sequence σ and let σ s and σ l denote the subsequences of σ respec-tively formed by items smaller and larger or equal to K . Recall that the resource utiliza-tion of an item is the product of its length and its size, and the total resource utilizationof all items in a sequence is a lower bound for the cost of O PT for that sequence. AsProposition 2 suggests, the number of opened bin by Modified Next Fit for items in σ l is no more than k × util ( σ l ) , where util ( σ l ) is the total utilization of items in σ l .For placing σ s , as the proof of Theorem 2 suggests, the algorithm incurs a cost ofat most µ∆ × ω ( σ s )1 − /K + span ( σ s ) , where ω ( σ s ) is the total size of item in σ s . Thiswill be no more than µ∆ × util ( σ s ) ∆ (1 − /K ) + span ( σ s ) , where util ( σ s ) is the total resourceutilization of σ s (this is because the length of all items is at least ∆ ). In total, the cost ofthe algorithm will be at most K × util ( σ l ) + µ × util ( σ s )1 − /K + span ( σ s ) . This is no morethan K × util ( σ ) × max { , µK − } + span ( σ ) where util ( σ ) is the total utilization ofitems in σ . Since util ( σ ) and span ( σ ) are lower bounds for the cost of O PT , we canconclude the cost of Modified Next Fit is at most K × max { , µK − } + 1 . (cid:117)(cid:116) When the value of µ is known to the algorithm, we can define K to be µ + 1 . In thiscase, the competitive ratio of Modified First Fit will be µ + 2 .7 roposition 3. When the value of µ is known, there is an online algorithm with com-petitive ratio of µ + 2 . In the previous sections, we showed that Next Fit and a variant of that have promisingcompetitive ratios. These kinds of worst-case guarantees are important in theoreticalanalysis of the problem. Nevertheless, in practice, beside worst-case guarantees, we areinterested in algorithms that also have promising average-case performance. For exam-ple, in the case of the classic bin packing problem, Best Fit and First Fit are preferredover other algorithms in most applications because they have acceptable worst-caseperformance (although not as good as the Harmonic family of algorithms) and supe-rior average-case performance. We examined different packing algorithms to evaluatetheir average-case performance. Our experiments are presented in Section 5 and showthat, on average, Best Fit has an evident advantage over First Fit, and First Fit is betterthan Next Fit. These results are in contrast with competitive results (recall that Best Fitis not competitive at all) and indicate that the worst-case behaviour and average-casebehaviour of these algorithms are quite different.In this section, we introduce and evaluate the Move-To-Front (M TF ) algorithm forthe server renting problem. We prove that, unlike Best Fit, this algorithm is competitive(i.e., provides a worst-case guarantee). Our experiments indicate that M TF performsbetter than all other algorithms on randomly generated sequences. M TF is a simple AnyFit algorithm and runs as fast as BF and FF. Hence, we believe that this is the bestalgorithm for the server renting problem. Move To Front:
The algorithm maintains a list of open bins. When a new item x arrives, the algorithms checks the bins one by one, starting from the front of thelist, until it finds a bin that has enough space for x . If no bin has enough space, anew bin is opened for x . After placing x in a bin, that bin is moved to the front ofthe list.M TF tends to place items which arrive almost at the same time in the same bins. Byavoiding placing old an new items in the same bins, the algorithm avoids bad situationin which a bin is open for a small item x , and just before x departs another small item y is placed in the bin. Theorem 4.
Move To Front has a competitive ratio of at most µ + 7 .Proof. Consider the final packing of the algorithm for a sequence σ . We assume thatthe sequence is continuous in the sense that it has a continuous span, i.e., at each timethere is at least one active item and any algorithm maintains at least one open bin.For sequences which are not continuous, at some point, all bins of M TF and O PT areclosed. In this case, we can divide the sequence into continuous subsequences and applythe same argument for each of them.We divide the span of the sequence into periods of length ( µ + 1) ∆ (except the lastperiod which might be shorter). For each bin B , we define head , tail , and body of B as8ollows. If B is opened and closed in the same period, its head is its stretch (intervalbetween its opening and closing) while its body and tail are empty intervals. Otherwise,head of B is the interval between when B and the end of the period in which it isopened. Similarly, tail of B is the interval between the start of the period in which it isclosed and when B is closed. Body of B is the interval between its head and tail. Figure2 provides an illustration. Let head ( B ) , body ( B ) , and tail ( B ) indicate the lengths ofrespectively head, body, and tail of B . For the cost that M TF incurs for B (stretch of B )we have: stretch ( B ) = head ( B ) + body ( B ) + tail ( B ) ≤ µ + 1) ∆ + body ( B ) Assume there are m bins opened by M TF . The algorithm incurs a cost of at most × ( µ + 1) for head and tail of each bin. We will have:M TF ( σ ) ≤ m ( µ + 1) ∆ + m (cid:88) b =1 body ( B b ) Assume there are q periods in the packing. For each period P i ( ≤ i ≤ q ), let α ( P i ) denote the number of bins which have their body in P i , that is, bins which are open atthe beginning of the period and remain open till the end. Note that α ( P i ) ≥ . M TF incurs a cost of α ( P ) × ( µ + 1) for body of all bins in P . We will have:M TF ( σ ) ≤ m ( µ + 1) ∆ + ( µ + 1) ∆ q (cid:88) i =1 α ( P i ) (2)Next, we consider the cost of O PT for packing σ . We prove the following claims: Claim 1:
For the number of bins opened by M TF we have m ≤ O PT ( σ ) / ∆ + 1 . Claim 2:
For each period P , if α ( P ) = 1 , O PT incurs a cost of at least ( µ + 1) ∆ . Claim 3:
For each period P , if α ( P ) ≥ , O PT incurs a cost of at least ( α ( P ) − ∆ / .Claim 1 implies that the first term in Equation 2 is upper bounded by µ +1) O PT ( σ )+2( µ + 1) ∆ . Claims 2 implies that in the specified periods, M TF and O PT incur the samecosts. Claim 3 implies that α ≤ O PT ( P ) / ∆ + 1 where O PT ( P ) is the cost inured byO PT in period P . Consequently, the second term in Equation 2 is upper bounded by ( µ + 1) ∆ q (cid:88) i =1 (2 O PT ( P i ) / ∆ + 1) = 2( µ + 1) q (cid:88) i =1 O PT ( P i ) + q ( µ + 1) ∆ < µ + 1) O PT ( σ ) + span ( σ ) + ( µ + 1) ∆ The last inequality holds because we have divided the stretch of σ into q periods withequal length of ( µ + 1) ∆ (except the last period which might be shorter). Adding bothterms in Equation 2, we get:M TF ( σ ) ≤ µ + 1) O PT ( σ ) + 2( µ + 1) ∆ + 2( µ + 1) O PT ( σ ) + O PT ( σ ) + ( µ + 1) ∆ = (6 µ + 7) O PT ( σ ) + 3( µ + 1) ∆ B B B B B st st st st st st st st st TimeB B B B B st st st st st st st st Time μ + 1 μ + 1 μ + 1 μ + 1 μ + 1 ≤ μ + 1 head B B B B B B B B B Time
Fig. 2.
The span of an input sequence is divided into periods. The red and blue intervals respec-tively indicate heads and tails of bins while black intervals are the bodies of the bins.
This implies that the competitive ratio of the algorithm is at most µ + 7 (note that µ + 1) ∆ is a constant). To complete the proof, it remains to show the above claimshold.For Claim 1, consider the ordering in which bins are opened and define the amor-tized weight of a bin (except the last bin in the ordering) as the total size of items inthe bin plus the item that causes opening of the next bin. With this definition, every bin(except the last bin) has amortized weight of more than 1. Thus, the total amortizedcost of all bins will be more than m − . Each item is counted at most twice in thetotal amortized cost (once as the item that opens a new bin and once as the member ofa bin which cannot fit a new item). Assuming ω ( σ ) is the total size of items, we willhave m − < ω ( σ ) . Note that ω ( σ ) ≤ util ( σ ) /∆ ≤ O PT ( σ ) /∆ . Hence, we get m ≤ O PT ( σ ) /∆ + 1 .For Claim 2, note that at each time, O PT maintains at least one open bin; otherwise,the sequence is not continuous.For Claim 3, let t denote the start time of P and let B ∗ denote the set of the α ( P ) bins which have their body stretched along P . Consider the time interval [ t + ∆, t +( µ +1) ∆ ) . In this interval, any of the bins in B ∗ receive at least one new item; otherwise,the algorithm would have closed the bin (recall that the length of any item is at most µ∆ ). For each bin B in B ∗ , except the last bin in the list maintained by the algorithmright before time t + ∆ , let t B indicate the time that the bin B (cid:48) receives an item forthe first time (in the interval [ t + ∆, t + ( µ + 1) ∆ ) ). Here, B (cid:48) is the bin that is placedright after B in the mentioned ordering. Define the critical set of B as the set of itemsin B at time t B plus the item that was placed in B (cid:48) . Note that the total size of items inthe critical set of each bin is more than 1. Hence, the critical items of each bin have aresource utilization of more than ∆ in the interval [ t, t + ( µ + 1) ∆ ) . Since each itembelongs to critical sets of at most two bins, the total resource utilization of critical itemsis at least ( α ( P ) − ∆/ in the interval [ t, t + 1 + µ ) . Note that the resource utilizationis a lower bound for the cost of O PT in the same interval. (cid:117)(cid:116) In fact, the above proof can be extended to any algorithm that maintains a list of binand places an incoming item in the first bin which has enough space. Such an algorithmmight update the list after placing items (as M TF does). In particular, the above analysisalso applies for the First Fit algorithm. For the Best Fit algorithm, the above analysis10ails because the order of bins changes when items depart . Recall that Best Fit is notcompetitive at all. The bad sequences that cause unbounded competitive ratio of Best Fitcause the algorithm keep multiple bins open for an arbitrary long time with an arbitrarysmall level of (cid:15) . This cannot happen for M TF and First Fit. In this section, we study the performance of M TF compared to other algorithms forthe server renting problem on randomly-generated sequences. We discretize the prob-lem by assuming that the size of bins is an integer E and items have integer sizes inthe range [1 , E ] . Moreover, we assume items arrive in discrete time-steps in the range [1 , T − µ ] and their length is in the interval [1 , µ ] . Here, T denotes the span of gener-ated sequences. We examine different values of µ and T for sequences of fixed length.This way, T is a measure of sparsness and defines the rate at whcih the items arrive.Table 1 gives details of the datasets that we generated for our experiments. In all cases,both size and length of items are randomly and independently taken from the indicatedranges (assuming a uniform distribution). For each setting of the problem, we run differ-ent algorithms on randomly generated sequences. For each sequence, we computethe resource utilization of the sequence as a lower bound for the cost of O PT (see Propo-sition 1). We use the ratio between the cost of an algorithm and the resource utilizationas a measure of performance.The algorithms that we considered in the experiments are Next Fit, Modified NextFit, First Fit, Modified First Fit, Harmonic, Best Fit, and Move To Front. We define theparameters of Modified Next Fit and Modified First Fit to be respectively E/ ( µ + 1) and E/ ( µ + 7) . These values ensure that these algorithms achieve their best possiblecompetitive ratio (see Section 3.1 and [10]). Note that the value of µ is not knownto the online algorithm and these algorithms are semi-online in this sense. We alsoconsider the Harmonic algorithm which classify items by their sizes (using harmonicintervals) into K classes and applies the Next Fit strategy for placing items of eachclass; we assume K = 10 in our experiments. A straightforward analysis shows thatthe competitive ratio of the Harmonic algorithm is as good as Modified Next Fit (withthe same parameter K ). However, similar to the bin packing problem, for the serverrenting problem, Harmonic seems to have a poor average-case performance.Figure 3 shows the average-case performance ratio among all sequences for differ-ent algorithms. In most cases, Move To Front is the best algorithm. Intuitively, there aretwo factors which define the quality of a packing. One is how well items are aligned Parameter Description Value Note n length of sequences Number of items to be packed µ maximum length of items 1,2,5,10,100 Lengths are picked from the range [1 , µ ] T span of sequence , , Arrival times are picked from the range [1 , T − µ ] E bin capacity Sizes are picked from the range [1 , E ] Table 1.
A summary of the experimental settings.
11o each other. Informally speaking, a packing is well-aligned if items that arrive at thesame time are placed together; this ensures that, on expectation, all items of a bin de-part also at (almost) the same time. Thus, there is a more chance of saving cost throughclosing bins. The second factor in defining the quality of a bin is how well the itemsare packed together according their sizes. Clearly, if items are tightly packed together,there is a save in cost by avoiding opening new bins.By definition, Next Fit results in well-aligned packings; however, it does not packsitems as tightly as Any Fit algorithms do. On the other side, Best Fit results tight pack-ings which are not necessarily well-aligned. Move To Front provides a compromise.The packing of M TF are well-aligned because items placed in the most recent bin havealmost same arrival time; meanwhile avoiding to place items in other bins give the achance of being closed (and saving cost thoroughly). At the same time, as an Any Fitalgorithm, M TF places items almost tightly and does not open a large number of binsas Next Fit does. For smaller values of µ , it is more important to achieve well-alignedpackings. this is because, when items have roughly same length, there is more benefit inplacing them together according to their arrival time since it ensures that they depart atalmost same time and their hosting bin gets released. This is particularly more evidentfor sequences with small span ( T = 1 , ). In these sequences, many items appearat the same time and almost all algorithms result in relatively good packing (regardingitem sizes). As a results, for smaller values of µ and T , Next Fit performs better relativeto other algorithms. In particular, when µ = 1 and T = 1 , , it slightly outperformsM TF . For larger values of µ , it is more important to avoid opening new bins; this isbecause each bin remains open for a relativity long period of time and one should avoidopening a new bin as much as possible. As a result, when µ is large ( µ = 100 ), Best Fitoutperforms Move To Front. T=1,000 T=10,000 T=100,000μ=1 μ=2 μ=5 μ=10 μ=100 μ=1 μ=2 μ=5 μ=10 μ=100 μ=1 μ=2 μ=5 μ=10 μ=100Next Fit μ=1 μ=2 μ=5 μ=10 μ=100 μ=1 μ=2 μ=5 μ=10 μ=100 μ=1 μ=2 μ=5 μ=10 μ=100
Next Fit Modified Next Fit First Fit Modified First Fit Harmonic Best Fit Move To Front
Fig. 3.
Average-case performance ratio of major server renting problem algorithms, assuming auniform distribution for the length and size of items. The bold numbers indicate the best algorithmfor different values of T and µ . In all cases M TF is the best or second to the best algorithm. Tomake comparison easier, the numbers are plotted into a bar diagram. Concluding Remarks
In this paper, we showed that the Next Fit algorithm provides promising worst caseguarantees for the server renting problem. We expect that the same holds for otherbounded-space algorithm, e.g., Harmonic or BBF of [7]. Unfortunately, these algo-rithms do not have good average-case performance. To address this issue, we intro-duced the M TF algorithm which is a simple and fast Any Fit algorithm which can beregarded as an alternative to the Best Fit and First Fit algorithms. Our experiments indi-cate that M TF outperforms other algorithms on the average case for placing sequencesthat are generated randomly. The closest counterpart of M TF (regarding average caseperformance) is the Best Fit algorithm which is not good in the worst case as it is notcompetitive at all. In contrast to Best Fit, we proved that M TF is competitive and hasa competitive ratio of at most µ + 7 . We believe this upper bound is not tight and thecompetitive ratio of M TF can be improved to µ + 1 of N F ; we leave this as a futurework. Another promising direction for future work is to to provide theoretical upperbounds for the average-case performance of M TF on sequences that follow arbitrarydistributions. References