Fortnite: 3.4 million at once
In February 2018 Fortnite hit 3.4 million players at once, and its services fell over six times in one weekend. You're running one hundredth of that night: 34,000 players, each sending about one request a second. A quarter of them are writes: joining matches and saving stats. One cache sits in front of one database, and nothing holds the crowd back.
Play this levelPart of Bugpit Pro. It runs in your browser: build the design, press Run, and watch what breaks.
The lesson
Epic published what broke, and it wasn't one big thing. One cache cluster (Memcached) slowed down. The proxies waiting on it filled up, failed their health checks, and the load balancer took every node out of rotation. A slow dependency became a total outage.
So the cache needs company. Run at least two, so losing one machine costs speed, not the game.
Matchmaking was the busiest shard of the database, and its writes queued up for tens of seconds. Writes that can wait belong in a queue, with workers saving them at a steady pace. The player hears "you're in the queue" instead of an error.
Players also stay connected, so friends can see who's online. When Epic's messaging load balancer failed, every client reconnected at once and the flood made it worse. Hold those connections on a Realtime Gateway with room to spare, and make clients back off before they retry.
Finally, the front door. When more people arrive than the servers can take, a login queue lets them in at a safe rate. Epic added one to Fortnite; nearly every big online game has one now.
What you have to achieve
34,000 requests a second at the busiest hour, 25% of them writes.
- No broken or illegal connections
- Use a Waiting Room
- Use a Queue
- Hold 34k open connections
- If 1 in 2 Cache (Redis) machines drop out at once, under 1% of requests fail
- No component is overloaded
- Workers clear the queue within the day
- Fewer than 0.1% of requests fail
- p99 response time under 300 ms
What you learn
Crash one cache machine now: the game slows, but stays up. Most big outages are small failures that spread: a slow cache, a full proxy, a flood of retries. Every fix here stops one failure from reaching the next part.
The real numbers behind it
- Fortnite peaked at 3.4 million concurrent players in February 2018, and Epic counted six incidents that weekend (Published: Epic Games: Postmortem of service outage at 3.4M CCU)
- Its main database ran on 9 MongoDB shards, each with a writer, two read replicas and a hidden replica (Published: Epic Games: Postmortem of service outage at 3.4M CCU)
- Writes queued on the matchmaking shard, pushing some operations into tens of seconds (Published: Epic Games: Postmortem of service outage at 3.4M CCU)
- Memcached failures saturated NGINX, failing health checks; a messaging load balancer failure set off a flood of reconnections (Reported: BYU incident database: Fortnite, February 2018)
- 34,000 req/s with a quarter writes. Epic doesn't publish this mix (Estimate)
- The login queue, queue for matchmaking and two cache machines are the standard fixes, shown here as a lesson, not Epic's exact design (Estimate)
Check yourself
Fortnite's slow cache took the whole game down. How did a slow part become a total outage?
- The cache deleted player data
- Proxies waiting on it filled up and failed health checks, so every node was taken out
- Players logged out
Show the answer
Proxies waiting on it filled up and failed health checks, so every node was taken out. A slow dependency is often worse than a dead one: everything waiting on it fills up. Two cache machines and bounded waits stop it spreading.
Thousands of players lose their connection at once. What stops them all reconnecting in the same second?
- Clients back off, waiting longer and a little randomly before each retry
- A bigger database
- Turning off the game
Show the answer
Clients back off, waiting longer and a little randomly before each retry. Retries that all fire together are a second wave of traffic. Backing off spreads them out.