Skip to content
About
Main content

Scenarios

Longer problems, like those in senior system design interviews. A strong answer estimates with numbers first, names the mechanism, then recommends a fix and says what it costs.

Try each one before you open the answer.
1Dashboards that normally load in 3 seconds take over a minute at 09:00. Users reload, and CPU is 100% busy. What is happening, and what do you do?Show the answer

Diagnose

Past the of the curve, more concurrent work adds latency but no . Reloads add load, and the holds requests whose users have already left, so throughput looks high while is low.

Fix, in order

  1. A bounded queue, sized as depth = tolerable wait × service rate: 5 seconds at 100 per second is 500.
  2. A deadline on every request, checked when it is dequeued.
  3. An .
  4. Fast rejection with "retry in a few seconds", which breaks the reload loop.

Trade-off

Some users are refused, but those admitted get answers. A limit set too low wastes capacity, which is why AIMD keeps probing upwards.

Read moreThe queue is the control surfaceCheck the deadline at dequeueAdaptive limits: AIMD

2A 64-machine training job has been pending for hours on a 200-machine cluster that looks half idle. Diagnose and fix.Show the answer

Diagnose

It is a gang job: it needs all 64 machines at once, and the free machines are scattered or keep being taken by short jobs.

Fix

A reservation that holds machines for the gang as they free up, plus backfilling short jobs, with enforced time limits, into the gap while it fills.

Costs

Machines sit idle while the gang accumulates: the price of making the job possible. works only if users declare honest time limits, so enforce or price them. Allocate gangs atomically, so two half-allocated gangs cannot deadlock.

Read moreGang schedulingBackfill scheduling

3Design the placement for a 3-replica database service and a 32-task tightly coupled training job in one region with 3 availability zones.Show the answer

The database

It survives if any replica does, so spread replicas across racks and zones. With a 1% chance per day of a rack failing, one rack risks 1% downtime; three racks, 0.0001%.

The training job

It fails if any task fails, so concentrate it in one rack: spreading a gang over 4 racks raises its failure chance from 1% to 3.9%, and adds cross-zone bandwidth cost.

Costs

Spreading lowers packing density and needs a to correct drift. Keep data on local NVMe.

Read moreOR-jobs versus AND-jobsAnti-affinity

4The finance team was promised 30 slots, but waited an hour to get them back after another team borrowed them. Design the fix.Show the answer

Diagnose

The borrowed tasks have a p99 duration of about 55 minutes, and without the slots return only as those tasks finish.

Options

Cap task length on borrowed capacity at, say, 10 minutes, so reclaiming takes at most about 10 minutes; allow preemption of borrowers, which loses their unsaved progress; or stop lending, which leaves capacity idle.

Recommend

A task-length cap plus preemption, with checkpointing for long borrowers.

State the trilemma

Guarantees, and no wasted work cannot all be had at once.

Read moreCapacity schedulingPreemption

5A cluster scheduler runs at 100% CPU while machines sit idle, now that tasks have shrunk to 100 ms. Do you rewrite it?Show the answer

Measure first

For 10,000 nodes, 30-second tasks need about 300 placements per second; 100 ms tasks need 100,000.

Options

If the scheduler manages 5,000 per second, batch tasks into units of about 5 seconds (50× less demand), and add a sampling fast path (two probes, shorter queue) for tiny tasks, keeping the careful scheduler for gangs, quotas and fairness. A shared-state scheduler is another option, but conflicts and retries grow as the cluster fills.

Note

The claim that monolithic schedulers do not scale is cited more often than demonstrated, so measure before redesigning.

Read moreWhy the single scheduler becomes a ceilingDoes the monolithic scheduler really not scale?

6A reactive autoscaler adds 40 machines 4 minutes after each 90-second traffic burst. What do you do?Show the answer

Diagnose

The burst is shorter than the scaling loop's delay, so scaling can never help, and the loop .

Fix

Absorb spikes with headroom sized for the known peak, a scheduled scale-up shortly before it (with a forecast biased high, since under-provisioning costs more), a bounded queue, and shedding. Scale to zero only if the gap between requests is much longer than the warm-up time.

Trade-off

Headroom is money spent on idle capacity.

Read moreAutoscalingPredictive scalingScale to zero

7Should 16 tenants share one big cluster, or should each team get its own warehouse?Show the answer

Compute the dividend

With a mean of 10 slots and a standard deviation of 5 per tenant, planning for mean + 2 standard deviations: separate clusters need 16 × 20 = 320 slots; a shared one needs 160 + 2 × 20 = 200, .

The catch

That gain assumes tenants are independent, but demand correlates at peak: if all of them peak at 20 together, the shared cluster needs 320 too.

Recommend

Shared pools for tenants whose peaks do not coincide, separate pools for heavy or correlated ones, and price isolation as the it gives up. Reserve a short-query lane, for example 10% of capacity, so short queries are not stuck behind long ones.

Read moreThe dividend depends on independenceWhy a warehouse per team can be a good designShort-query lanes

8A dispatch service is at 20% CPU, but bookings stall for 10 seconds whenever the operations team runs a bulk job. Diagnose and fix.Show the answer

Diagnose

: one first-in, first-out queue carrying work of very different costs.

Estimate

A bulk job of 5,000 rides at 2 ms each holds a worker for 10 seconds, while 300 small requests per second pile up behind it: 3,000 in those 10 seconds.

Fix both ways

Split bulk work into 50-ride chunks (100 ms each), and give bulk work its own pool. Alert on the age of the oldest waiting request.

Trade-off

Separate pools lose some multiplexing efficiency and add configuration. Then check the layer below for the next shared queue.

Read moreHead-of-line blocking

How to approach any scheduling problem

For any scheduling problem, the answer follows the same steps: say which of the three questions it is (when, where, whether); name the missing information; name the currency the guarantee is paid in (idle capacity or destroyed work); and find who pays the cost.