Week 12 · Capstone · Decide how much service capacity to add
Compare staffing under smooth, variable, and bursty workloads.
Compare staffing under smooth, variable, and bursty workloads.
Work through the problem
Suppose customers arrive every 1.2 minutes and service takes 1 minute. A single server has no queue. At the same average workload, longer service durations can push waiting time well above zero. Compare one and two servers against an illustrative requirement that the 95th percentile wait stays under 3 minutes.
For each arrival assign the server with earliest availability, then start at max(arrival, available). Compare two sets of arrival gaps with the same expected mean. The extra server’s value depends on both the arrival and service distributions. Make a decision conditional on the assumed workload and test it on future observations.
Run the Python lab
from heapq import heapreplace
import numpy as np
def simulate(gaps, service, capacity):
free = [0.] * capacity
wait = []
for arrival, duration in zip(np.cumsum(gaps), service):
start = max(arrival, free[0])
wait.append(start - arrival)
heapreplace(free, start + duration)
return np.quantile(wait, .95)
rng = np.random.default_rng(11)
n = 20000
smooth = np.full(n, 1.2)
burst = rng.choice([.15, 2.25], n)
service = rng.exponential(1, n)
for name, gaps, durations in [("smooth", smooth, np.ones(n)), ("variable", smooth, service), ("bursty", burst, service)]:
values = [simulate(gaps,durations,c) for c in [1,2]]
print(name, "p95:", np.round(values,2))
assert values[1] <= values[0]
Output from the lab
smooth p95: [0. 0.]
variable p95: [7.53 0. ]
bursty p95: [13.61 1.52]
Practice
- What observation would make you reconsider the second server?
Check your reasoning
- If held-out observations at the actual peak showed one server meets the wait threshold reliably, the second server may add little value.