Requests spawn from the client at the chosen rate and are routed by the load balancer to one of the healthy instances across three availability zones (AZs):
Round Robin: pick the next instance in a fixed rotation
Least Connections: pick the instance with the fewest in-flight requests
Random: pick uniformly among healthy, non-full instances
Each instance can process up to 4 concurrent requests. An instance's CPU load is modelled as load = in_flight / 4. Every second the fleet-wide average CPU is compared against the scale-out threshold:
avgCPU > scaleOutThreshold → spin up a new instance (in the least-loaded AZ)
avgCPU < scaleOutThreshold − 30% → spin down an idle instance
a 2s cooldown after each action prevents oscillation ("flapping")
Queueing theory. Requests arrive as a Poisson stream (exponential gaps, rate λ) and hold one slot for 1.6 s (0.35 s to the balancer, 0.55 s to the instance, 0.7 s processing). With c = 4 × healthy instances slots and no queue this is an Erlang loss system, M/G/c/c, whose blocking probability depends only on the offered load a = λ · 1.6 s: B(c, a) with B(0) = 1, B(k) = a B(k-1) / (k + a B(k-1)) (insensitive to the service-time distribution). All three routing algorithms drop a request only when every slot is busy, so they share the same blocking probability; they differ in how evenly they load individual instances. Simplifications: identical instances, no boot delay for new instances beyond the scale animation, fixed 4-slot concurrency, zero network jitter, no queue.
If every healthy instance is already at its concurrency limit, an incoming request is dropped rather than queued indefinitely — visible as the Dropped counter and a red flash at the load balancer. Simulate AZ Outage marks the middle zone unhealthy: the balancer instantly stops routing to it and the surviving zones absorb the traffic, demonstrating the failover a real multi-AZ deployment relies on.