Section 18.5.13

Fleet scaling, queueing, and parallelism limits

Definition

Fleet scaling describes how the time to update a fleet, a group of many devices, changes when more workers are added. A worker is anything that updates one device at a time, such as a dongle §6.5, a small radio adapter plugged into a computer. The makespan is the time from the start of the deployment until the last device has finished. Only in the ideal case do kk workers divide the makespan by kk. Shared resources, uneven jobs and dependencies between steps set lower limits that more workers cannot remove.

The idea

An operator must update 10 devices. One update takes 2 seconds, so one worker that updates the devices one after another needs 10×2=2010 \times 2 = 20 seconds. A second worker seems to halve that time, and a tenth worker to cut it to 2 seconds. The expectation holds only if each update is an independent job, one that needs nothing from the other jobs and shares no resource with them. Real deployments rarely satisfy this. The workers are usually attached to one computer, whose processor, USB (Universal Serial Bus) connections and software prepare or relay every job. Their radios share the same air, so their transmissions can collide. Some steps, such as preparing an update image or writing a log, may handle only one job at a time.

A shop with several checkouts and one narrow exit door is a fair picture. Opening more checkouts shortens the queues at the checkouts, but no more customers leave per minute than the door lets through. A step that every job needs and that serves one job at a time is such a door. Once the checkouts are no longer the slowest stage, more of them change nothing. The picture stops being accurate in one respect: extra workers can also slow each other down, for example through radio collisions, and extra checkouts do not.

A further limit lies in the computer. Adding dongles gives parallelism §9.1, work that truly happens at the same moment, only for the steps that each dongle performs with its own hardware. Steps that the computer’s software must perform for each dongle in turn are merely interleaved, which is concurrency without the speed of parallel work.

How it works

Predicting or checking the makespan with kk workers takes five steps.

  1. Describe each job as steps. For each device, list the steps of its update in order, the resource that each step uses, and the step’s service time, the time the resource is busy with that step.

  2. Classify the resources. A per-worker resource, such as the dongle itself, exists kk times. A shared resource, such as a preparation step on the host computer or the radio channel of one room, exists once, whatever kk is.

  3. Compute the lower bounds. The makespan cannot be shorter than the total service time on any shared resource that serves one job at a time; than the per-worker work divided among the kk workers, counted in whole jobs; or than the longest chain of steps that one job must perform one after another.

  4. Find the bottleneck. The resource behind the largest bound is the bottleneck, the resource that limits the deployment. Jobs that reach it faster than it serves them wait in a queue, and their queueing delay §14.38, the time spent waiting before service starts, adds to the makespan. The makespan reaches the largest bound only when the schedule keeps the bottleneck busy without a pause.

  5. Measure the speedup §18.1.13. Run with k=1,2,4,…k = 1, 2, 4, \dots workers on the same devices and plot the speedup S(k)=T(1)/T(k)S(k) = T(1) / T(k), where T(k)T(k) is the makespan with kk workers, against the ideal line S(k)=kS(k) = k. Where the curve flattens, a shared resource has taken over.

For a program whose one-worker run time contains a part that cannot run in parallel, Amdahl’s law §18.5.1 gives the same kind of ceiling in closed form [184]. If that part is a fraction ff of the one-worker time, the speedup with kk workers is at most 1/(f+(1−f)/k)1 / (f + (1 - f) / k), which stays below 1/f1 / f however large kk is.

Worked example

Ten invented devices each need a 2-second step on a worker. Without any shared step, the makespan is the number of jobs on the busiest worker times 2 seconds. Now add a shared step: before its worker step, every job must pass a 1-second preparation step on the host computer, which prepares one job at a time. Job jj, for j=1,…,10j = 1, \dots, 10, leaves the preparation step at jj seconds.

With one worker, the worker is the bottleneck. It starts job 1 at 1 second and then works without a pause: job jj runs from 2j−12j - 1 to 2j+12j + 1 seconds, so job 10 finishes at 2×10+1=212 \times 10 + 1 = 21 seconds. Job 10 left the preparation step at 10 seconds and waited in the queue until 19 seconds, a queueing delay of 19−10=919 - 10 = 9 seconds.

With two workers, job jj starts the moment it leaves the preparation step, because the worker that ran job j−2j - 2 finished it at jj seconds. Job 10 runs from 10 to 12 seconds, so the makespan is 12 seconds. A third worker would never find a job waiting: the preparation step now limits the deployment. The makespans, in seconds:

workers kk no shared step 1-second shared step
1 20 21
2 10 12
3 8 12
5 4 12
10 2 12

Without the shared step, 3 workers need 8 seconds, not 20/3≈6.720 / 3 \approx 6.7: a job is not split across workers, so one worker must take 4 of the 10 jobs. The speedup is therefore 20/8=2.520 / 8 = 2.5, not 3, and with 10 workers it is 20/2=1020 / 2 = 10. With the shared step, the speedup is 21/12=1.7521 / 12 = 1.75 for every kk from 2 on. A lower bound explains the ceiling: the last job cannot leave the preparation step before 10×1=1010 \times 1 = 10 seconds and then needs 2 seconds on a worker, so no number of workers gives less than 10+2=1210 + 2 = 12 seconds. Every worker beyond the second is wasted.

Stated precisely

Let there be nn jobs and kk identical workers. Job jj needs wjw_j seconds on a worker and sjs_j seconds on one shared resource that serves one job at a time, and T(k)T(k) is the makespan. Then T(k)≥max(∑j=1nsj,1k∑j=1nwj,maxj(sj+wj)).T(k) \ge \max\left(\sum_{j=1}^{n} s_j,\ \frac{1}{k}\sum_{j=1}^{n} w_j,\ \max_{j}\,(s_j + w_j)\right). The first term holds because the shared resource must be busy for the sum of all sjs_j. The second holds because the kk workers together must supply the sum of all wjw_j. The third holds when each job’s two steps run one after the other, because no job finishes sooner than its own chain. The first term does not depend on kk, so the speedup satisfies S(k)≤T(1)/∑jsjS(k) \le T(1) / \sum_j s_j for every kk. If every job uses the shared resource before its worker step, the last job leaves the shared resource no earlier than ∑jsj\sum_j s_j and then needs its worker step, so T(k)≥∑jsj+minjwjT(k) \ge \sum_j s_j + \min_j w_j.

With nn equal jobs of ww seconds each, no shared resource and no splitting of jobs, a schedule that spreads the jobs as evenly as possible has T(k)=⌈n/k⌉wT(k) = \lceil n / k \rceil \, w, where ⌈x⌉\lceil x \rceil is xx rounded up to a whole number, and no schedule does better.

These statements rest on four assumptions.

  1. No other shared resource. Every further shared resource adds a bound of the first kind.

  2. No interference. Service times do not grow with kk. Radio collisions or a busier host computer break this assumption, and then T(k)T(k) can even rise when workers are added.

  3. Whole jobs. A job, once started on a worker, stays on that worker.

  4. All devices ready at the start. If the device of job jj becomes reachable only at time aa, that job cannot finish before a+sj+wja + s_j + w_j.

Limits and common mistakes

Dividing a measured one-worker time by the number of dongles is a prediction, not a measurement, and the prediction is right only when every condition of ideal scaling holds.

Deployment time has two meanings. More workers can shorten the makespan of the fleet by overlapping the updates of different devices. They never shorten the update of one device, and interference can lengthen it.

Jobs are rarely equal. Devices differ in signal strength, update size and number of retries. The busiest worker sets the makespan, one slow device, called a straggler, can set it alone, and a device retried after the others have finished extends it by a whole update.

When devices become ready over time instead of all at once, the waiting at a shared resource grows sharply as the rate at which jobs arrive approaches the rate at which the resource serves them.

A speedup measured with 10 devices in one room need not hold for 1000 devices in a building, where further resources become shared. Whether a result carries over to other settings is a question of external validity §11.44.

Questions answered

Can adding dongles divide deployment time by their number?

Adding dongles divides deployment time by their number only in an ideal case that real deployments rarely reach. Dongles, small radio adapters that each update one device at a time, divide the fleet’s deployment time (the time until the last device is updated) by their number kk only when four conditions hold: the device updates are independent of each other; they split evenly among the dongles; they share no resource, such as one host computer, one preparation step or the radio airtime §18.2.19 of one room; and the dongles do not slow each other down through radio interference.

Otherwise, lower bounds that more dongles cannot lower limit the time: the total time of any shared step that handles one job at a time, the work of the busiest dongle, and the longest chain of steps for one device. For example, ten 2-second updates that must each first pass a 1-second shared step take 21 seconds with one dongle, 12 seconds with two, and still 12 seconds with ten, so the speedup stops at 21/12=1.7521 / 12 = 1.75. Adding dongles also never shortens the update of a single device.

Related entries: Computational versus communication bottleneck (§14.37), Queueing delay (§14.38), Pseudoreplication (§11.6), Concurrency versus parallelism (§9.1), Amdahl’s law for an interpreter optimization claim (§18.5.1), External validity (§11.44). Further reading: [184].