Midnight sale, one server dies, carts vanish: Load balancers (Mock Interview Notes)
How to answer the midnight-sale load balancer interview question: why a bigger server is the weak answer, round robin vs least connections vs hashing, active and passive health checks with real defaults, why sticky sessions empty your cart, Redis as the shared store, POST retries, the LB as a single point of failure, and connection draining.
By InternHack Team · · 13 min read · Interview Prep
The interview question: "It's a midnight sale. At 12:00, lakhs of people are checking out at the same time. One of your 4 servers dies. Some users get an error, some find their cart empty. What do you do?"
Big sales really do open at midnight with huge traffic. Flipkart's own site says they handle "1.5 million requests per second when the sale opens" (that's 15 lakh requests every second). (To be clear: the dead-server, empty-cart story in these notes is an example sale, not a real company's outage. No source we found blames any sale outage on a load balancer or sticky sessions.)
In these notes: the weak answer and why it fails, how a load balancer picks a server, active and passive health checks with the real default timings, why the cart vanished, the fix with stateless servers and Redis, why "Place order" isn't retried, what happens if the load balancer itself dies, connection draining during deploys, and a ready interview answer.
The weak answer: "Just get a bigger server"
A typical fresher answer: "Sir, we'll get one big server, 64 cores, 256 GB RAM. If there's only one server, the cart stays there too, so no problem."
Here's why the interviewer pushes back:
- What if that big server dies at 12:01? The whole sale goes down. One machine is a single point of failure. With 4 servers, losing one hurts; with 1 server, losing it is the end.
- There's a ceiling. You can only make one machine so big (vertical scaling). 15 lakh requests per second is not a one-machine job.
- It dodges the real question. The cart vanished because of where the cart was stored, not because there were too few servers. A bigger server doesn't teach you anything about that.
The strong answer is horizontal scaling: many smaller, identical, stateless servers with a load balancer in front. One-liner to remember: "Not a bigger server, more servers. And don't let the server remember the cart, let Redis remember it."
Sign up free to unlock the full notes
Aage ke sections free InternHack account ke saath khulte hain:
- How a load balancer works
- Health checks: the guard asking "are you alive?"
- The detection gap: where users see errors
- Why the cart vanished: sticky sessions
- The fix: stateless servers + a shared store
- Why "Place order" errors but browsing doesn't
- What if the load balancer itself dies?
- Deploys: connection draining
- Three follow-up questions
- The reel's question: which sale did you lose your cart in?
- How to answer this in an interview
Sources
- NGINX docs, upstream module (round robin default, least_conn, ip_hash, consistent hash, max_fails, fail_timeout): https://nginx.org/en/docs/http/ngx_http_upstream_module.html
- NGINX docs, proxy_next_upstream (non-idempotent requests not retried): https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_next_upstream
- HAProxy docs, health checks (active vs passive, inter 2s, fall 3, rise 2): https://www.haproxy.com/documentation/haproxy-configuration-tutorials/reliability/health-checks/
- AWS docs, ALB target group health checks (30 s, 2 / 5 thresholds, fail open): https://docs.aws.amazon.com/elasticloadbalancing/latest/application/target-group-health-checks.html
- AWS docs, ALB target group attributes (algorithms, stickiness, deregistration delay): https://docs.aws.amazon.com/elasticloadbalancing/latest/application/edit-target-group-attributes.html
- AWS, session management (central session store): https://aws.amazon.com/caching/session-management/
- Google Cloud docs, load balancing overview (anycast, software-defined): https://docs.cloud.google.com/load-balancing/docs/load-balancing-overview
- Envoy docs, outlier detection defaults: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/cluster/v3/outlier_detection.proto
- GitHub blog, Introducing GLB (2016): https://github.blog/engineering/infrastructure/introducing-glb/
- Cloudflare blog, Unimog edge load balancer (2020): https://blog.cloudflare.com/unimog-cloudflares-edge-load-balancer/
- Flipkart Stories Q&A, 1.5 million requests per second at sale open (2023): https://stories.flipkart.com/innovation-customer-first-qna-jeyandran-venugopal
- DesignGurus, load balancer mistakes in system design interviews: https://www.designgurus.io/blog/load-balancer-mistakes-in-system-design-interviews
The detection-gap timings (about 1 minute, 2.5 minutes, 6 seconds, roughly 1 in 4 requests) are our arithmetic on the documented defaults. Floating IP / VRRP, idempotency keys, DNS caching and the college-IP gotcha are general knowledge, not from the sources above. No sale outage has been publicly attributed to a load balancer or sticky sessions in the sources we checked.