Backend challenges we faced and how we fixed them
By Swapnil Shah · Updated 2026-11-24
Building a game server is one thing, keeping it healthy once strangers use it is another. These are the real problems I hit after launch and how I fixed them.
Challenge 1: a chain reaction that never ended
In Battle Royale mode, when the outer ring of the board collapsed, I found positions where explosions could bounce back and forth forever. The server kept resolving waves and never finished, which froze the room.
The fix was two guards: loop detection that notices when the board repeats a state, and a hard cap of 200 waves per move. If either triggers, the game ends and the winner is decided by orb count, with the reason shown to players. I also changed the collapse rule so it never triggers a chain by itself, which removed the root cause.
Challenge 2: players with no legal move
Occasionally a player had no legal move at all, and the turn logic waited for a move that could never come. Now the server detects that and eliminates the stuck player so the game continues. A related bug was a collapse that removed every remaining player, where the server used to invent a winner. The game now ends cleanly with no winner and says so.
Challenge 3: abuse and floods
Anything on the public internet gets hammered. I added per-address rate limits on creating rooms and joining them, a limit on request body size, and a limit on chat speed. Rooms that nobody uses are cleaned up, and the total number of rooms is capped.
I also moved the login token for the WebSocket from the URL into the first message, so it does not end up in logs, and restricted which websites may call the API.
Challenge 4: locking the server down
I run the game in a container with as little power as possible: it runs as a non-privileged user, the code is read-only, extra capabilities are dropped, memory and process counts are capped and the logs rotate. The API documentation pages are turned off in production.
On top of that the server sends strict security headers, including a content security policy that only allows scripts with a per-response nonce. That kills a whole class of injection attacks.
Challenge 5: caching without stale pages
Hashed asset files are cached for a year, because their names change when their content does. The main HTML page is never cached, so players always get the latest version. Small files like the manifest and robots file are cached for a short time and revalidated. Getting this right made repeat visits fast without ever serving an old game.
The lesson
Almost every one of these problems was invisible in testing and obvious in production. The most valuable habit I built was to log structured events for everything unusual, so that when something strange happened I could see exactly what the server did.