• Atom Reaction
  • How to play
  • Strategy
  • Videos
  • Shorts
  • Tdm
  • Drills
  • Chess
  • About me
  • Projects
  • Social Medias
    • Instagram
    • YouTube
    • Twitter
  • Games
    • Dice Chess
    • Ultimate Tic Tac Toe
    • Atom Reaction

    • About the games
  • Coding
    • Resume
    • LeetCode
    • Codechef
    • CodingNinjas
โ–S๐’Š๐’๐’†๐’๐’•ใ€…๐’Œ๐’Š๐’๐’๐’†๐’“เฟ

Atom Reaction rules, strategy guides and free browser games, plus gameplay videos and projects by Swapnil Shah.

Connect with me
  • Instagram
  • YouTube
  • Twitter
  • Contact Me

    silentkillerop123@protonmail.com

    How to playStrategyGamesProjectsAboutContactPrivacy PolicyTerms
    ยฉ 2026 Copyright: silentkillerop.me

    Behind the game ยท by Swapnil Shah ยท 23 November 2026

    Saving games to a database without slowing play

    Players like seeing their game history and a leaderboard. But storing every game must never slow a move or cost much to run. Here is how I added a database to a game that started life entirely in memory.

    The requirement

    Moves must stay instant, so the game itself never waits for the database. The database is also optional: if it is missing or asleep, the game keeps working. And because it is a hobby project, I wanted it to cost nothing when nobody is playing.

    A database that sleeps

    I run PostgreSQL in a container that is started on demand. A small systemd socket listens for connections, and the first connection wakes the database, which takes about two and a half seconds. After three minutes with no connections it shuts itself down and uses no memory at all. When idle it costs nothing, and when awake it uses a few tens of megabytes.

    A background queue

    When a game finishes, the result is put on a queue and saved in the background. If the database is still waking up, the save retries after one, three, ten and thirty seconds. The player never notices, because the game does not wait for the result.

    Short connections

    A database that never sleeps because a connection pool holds it open defeats the whole idea. The pool keeps no idle connections and closes unused ones after about a minute, so the database can go back to sleep. Statistics and leaderboard responses are cached for five minutes, so most page views do not wake it either.

    Privacy by design

    Anonymous players are identified only by a random id in their browser. A nightly job removes games older than a day where nobody was signed in, and anonymises guests in mixed games, replacing their names with "Guest". Signed-in players can edit their name, make their profile private or delete their account.

    What I learned

    Treating the database as an optional add-on kept the game fast and robust. If I had started by making every move depend on it, a sleeping database would have turned into laggy games. Design the critical path to work without it, then add it on the side.

    Put it into practice โ†’

    More Atom Reaction guides

    • How to play: The complete rules, critical mass numbers and a worked example of a chain reaction.
    • Strategy guide: Ten practical tips for the opening, middle game, endgame and Battle Royale.
    • Game modes: Online rooms, bots, pass and play, daily puzzle and Battle Royale explained.
    • FAQ: Quick answers about players, bots, accounts and installing the game.
    • Opening moves: Where to place your first orbs and what to avoid in the first five turns.
    • Corner strategy in Atom Reaction: Why corners are the strongest cells and how to build chains out of them.
    • Common Atom Reaction mistakes: Seven mistakes that cost new players games, with a fix for each.
    • Beating the Atom Reaction bots: How each bot level thinks and the habits that beat them.
    • Multiplayer tactics for Atom Reaction: Target selection, kingmaking and surviving a crowded board.
    • Battle Royale survival guide: How the shrinking board works and how to be the last one standing.
    • Two player strategy for Atom Reaction: Tempo, forcing exchanges and corner control in head-to-head games.
    • Reading the board in Atom Reaction: A simple scan routine to spot threats and chains before they happen.
    • Trap patterns in Atom Reaction: The decoy corner, the delayed fuse and the forced capture.
    • Endgame guide: Count orbs, keep reserve moves and finish the last opponent.
    • Choosing the right board size: How the grid size changes pace, tactics and player count.
    • Reviewing your games to improve: Using replay and post-game review to find the move that lost the game.
    • Hosting a game night: Rooms, invite links, spectators, chat and keeping everyone engaged.
    • Playing on your phone: Install it, switch on lite mode and get turn alerts on any phone.
    • How the Atom Reaction backend was built: FastAPI, WebSockets, in-memory rooms and a chain-resolving game engine.
    • Backend challenges we faced and how we fixed them: Endless chains, room floods, rate limits and server hardening.
    • Frontend challenge: why phones got hot and how we fixed it: Cached sprites, frame pacing and lite mode to cool down phones.
    • Making multiplayer reliable: reconnects and dropped connections: Automatic reconnect, seat recovery and bots that cover for dropped players.
    • How the Atom Reaction bots were built: Alpha-beta search, web workers and the experiments that surprised us.