Exercise 2: Two Servers Going Down at Different Points — Possible Solution ==================================================================== THE CHANGE ------------------------------ if i == 10: server_b.healthy = False if i == 20: server_c.healthy = False Server B goes down at request 10 (matching this chapter's own original timing), and server C goes down at request 20 - leaving only server A healthy for the final third of the run. This chapter's own HealthCheckingBalancer and send_request() logic are used completely unchanged. VERIFYING ZERO FAILURES STILL HOLDS ------------------------------ failures out of 30 requests: 0 Even with two separate, independent failures during the run, the health-checking balancer produced zero failed requests - exactly matching this chapter's own single-failure result. Each time a server went down, the balancer's own healthy_servers filter simply excluded it from the very next routing decision onward. DISTRIBUTION ACROSS THE THREE SERVERS ------------------------------ distribution: {'A': 19, 'B': 3, 'C': 8} B received 3 requests before going down at request 10 (its share of the first 10 requests, split with A and C). C received 8 requests total - its share of requests 0-9 alongside A and B, plus its share of requests 10-19 alongside only A, before going down itself at request 20. A received the remaining 19 requests - its share of both earlier windows, plus the ENTIRE final 10 requests (20-29) once it was the only healthy server left standing. WHY THIS CONFIRMS HEALTH CHECKING SCALES TO MULTIPLE FAILURES ------------------------------ This chapter's own single-failure scenario already showed health checking prevents failed requests from one dead server. This exercise confirms the same mechanism handles a SECOND, independent failure happening later in the same run, with zero additional logic needed - the balancer re-evaluates which servers are healthy on every single routing decision, so it doesn't matter whether one server goes down or several, or when. WHY THIS WORKS AS AN ANSWER ------------------------------ The scenario extends this chapter's own single-failure test with a second, independently-timed failure using the exact same balancer code, verifies the zero-failure result still holds, and traces the resulting server distribution back to exactly which servers were healthy during each segment of the run rather than only reporting the final totals.