How TagBalls is built
The whole system in one picture, where data lives, and each part with its page.
The whole system on one page, as it runs today: what each piece does, where data lives, and a short section per part with a link to its own page. Each part's page has how it works now, the key decisions, the changes that mattered and what's next.
The pieces
| Piece | What it does |
| Your browser | Draws the game, predicts your ball (see Netcode) and keeps your replays. |
| Web Worker | The Sandbox, the tutorial and the editor's Play here run the whole game room in a Web Worker in your tab. |
| Service worker | Keeps the site's files in your browser, so pages open at once and offline games work (Loading a game). |
| Site Worker | The site's Cloudflare Worker: serves the site, answers public lists from a cache near you, opens game connections and passes everything else on. World, Presence, Chat, Relay and StatusWatch live in it. Rate limits (joins and API calls a minute) are Cloudflare bindings. |
| World | One Durable Object for accounts, maps, the store and TagCoins, friends, matchmaking, the list of live games, groups and Find a game's pool (those two in memory). Its data is in SQLite. |
| Game rooms on Cloud | One Durable Object per game, started near its first player, running 60 ticks a second. It reports to World every 2 seconds and closes when empty. These and BotBrain live in the game Worker. |
| BotBrain | One per Cloud game with bots: where its bots think (Where bots think). |
| Presence | 8 shards that answer every tab's "who's online" poll and pass changes to World every 5 seconds. |
| Chat | Global chat, in its own SQLite. |
| League | The Bot League, with its own SQLite, in the helpers Worker with the daily map checks, so a heavy bot match never shares a room's object or World's. |
| Forums | The forums, in their own Worker with one object and its own SQLite, so forum traffic and forum deploys never touch games, World or the site's pages. It asks World who is signed in and keeps nothing of World's. |
| Relay | Carries messages for games hosted on a player's own computer. |
| StatusWatch | Checks the site every minute for the public status page, in its own SQLite (Watching the game). |
| Dedicated servers | Our own servers running the same game in Rust rooms (most games: Rust game rooms) and Node rooms, with a real clock: US West (Los Angeles), US East (New York), Europe (Amsterdam) and Oceania (Sydney), one dedicated core and up to 8 games each; idle regions scale to zero (Servers and deploys). |
| Ops worker | A separate Worker with one object (OpsStore) and a check every minute, so it answers when the game is down. Staff only. |
A Durable Object is a small single-threaded server with its own storage that lives in one place. No KV store is used: all saved data is in the objects' SQLite, and lists that are the same for everyone sit in Cloudflare's cache near you for 3 seconds to 5 minutes.
The Dedicated servers box stands for four servers: US West, fixed, and US East, Europe and Oceania, made by the autoscaler (switch AUTOSCALE_LIVE). Not drawn: Backup rooms on the Rust room in Cloudflare Containers (built, off, trial pending: variable RUST_BACKUP unset; Backup rooms on the Rust room). Rust rooms: Rust game rooms.
Four Workers
The site runs as four Cloudflare Workers, each deployed on its own, so a change reaches only the part it changed. Since 17 Nov 2026.
| Part | What it holds | What its deploy restarts |
| Site Worker | Pages, the API, World, Presence, Chat, Relay, StatusWatch | Those objects start again on the new code. Running games keep going, and open pages switch at their next page change. |
| Game Worker | Game rooms on Backup and BotBrain | Each running Backup game keeps its code and restarts at a calm moment, and its players are back in about a second. Then the Dedicated servers roll. |
| Helpers Worker | The Bot League and World's map checks | Only those objects. Running games keep going. |
| Forum Worker | The forums, in their own SQLite | Only the forums. Games, World and the pages keep going. |
| Dedicated servers | Our own Node servers for competitive games | A new process starts on the new build. The old one takes no new games, finishes the ones it has and exits within 45 minutes. |
| Ops site | The status checks and the staff ops page | Only itself. |
How a deploy picks. The deploy chain runs npm run deploy -- --since with the last live commit. deploy/which.mjs lists every file each Worker is built from, the way the bundler sees its imports, and deploys only the Workers whose files changed:
- A file a Worker's bundle imports, or its config, deploys that Worker. Shared code deploys every Worker that imports it.
- Any other file the site is built from (the client,
public/) deploys the site only. package.json deploys all four. Docs, tests and tools deploy nothing.- The order is helpers, game, forum, then site, because the site binds the other three. The first failure stops the rest.
- When the game Worker is in the list, the deploy prints "rooms: roll" and the chain rolls the Dedicated servers. Otherwise it leaves them alone.
On 17 Nov 2026, 116 of the first 157 deploys after the split changed only the site and restarted no game. The story: Splitting the site into four Workers.
Where it runs
Dedicated or Backup: every game shows where it runs. Dedicated is our own server, its clock always on time; Backup is a room on Cloudflare, in every region. US West (Los Angeles), US East (New York), Europe (Amsterdam) and Oceania (Sydney) have Dedicated servers (since 16 Nov 2026); Asia Pacific and South America are Backup only.
All regions (the default, your region first): people near you first. If no one is playing within about 90 ms, you join the nearest region that has people, up to about 250 ms, and the game shows the ping to expect; My region only keeps you home. Tick one or more regions instead and you play only there: a game with people in any of them first, the fullest, then the lowest ping; else a new game in the lowest-ping one whose Dedicated server has room. If none of them can take you, the page says so and offers Any region. The regions: US West, US East, Europe, Oceania, Asia Pacific and South America.
Rooms and tick
Each game is one room running 60 ticks a second: inputs, one physics step, the rules, one snapshot built for everyone, the send. On Cloud a room's clock can pause 40 to 200 ms a few times a quarter hour; the clock mend repays it evenly. Page: A game tick.
Netcode and wire format
The server decides everything. Automatic is the default: Classic, with Light only as Auto quality's last step on a slow computer. Updates go as wire 4 deltas, 6.0 to 6.2 KB a second per player with 4 people and 4 Expert bots. Page: Netcode.
Physics
Box2D version 3 compiled to WebAssembly, the same build on the server and in your browser, one step of 1/60 s. Classic physics values were measured from the classic game. Page: Physics.
Bots
Four levels on the same code everywhere. On Backup they think in a BotBrain next to the room; on Dedicated in a Node room, or for a Rust room in a bot brain process beside it. A brain written in Rust is in progress, switched off. 1 to 8 bots play up to Expert, 9 or more up to Elite. Page: How bots think.
Servers and deploys
Competitive and ranked games in US West run on the Dedicated server, everything else on Cloud. A deploy never cuts a running game: Dedicated rolls to a second process, Cloud rooms keep their code until a calm moment. An open page moves to a new site build by itself between games or while nobody is using it, and never asks you to reload. Page: Servers and deploys.
Rust rooms
Most games on a Dedicated Server run in the room written in Rust: every mode on one-floor maps, and most on multi-layer maps. A game goes there only when the server reports every feature it needs; anything else plays on the Node room. Every change is proven on recorded games both ways and checked by an independent verifier before the servers roll. Page: Rust game rooms.
Home, search and email
Home shows the next degree reward, a maps row that is never empty, a weekly store pick and the map royalty numbers; nothing on it is time-only and there are no ads. Every public page has its own title and address for search. Opt-in email is built and switched off. Pages: How Home and search work, How email works.
Data and accounts
World holds accounts, maps, the store and matchmaking in SQLite and answers one request at a time. A game saves once, when it ends: 11.2 ms and 234 database calls for 8 players. Page: Data and saving.
Loading and client drawing
A small core loads first, the room code only when a room runs in your tab, and the service worker keeps the rest. Auto quality steps drawing down one measured step at a time. Page: Making it fast.
Voice
Peer to peer WebRTC: one connection per pair, no mixing server. The game's socket or the group's poll carries the setup messages; no audio reaches our servers. Page: How voice works.
Testing and the feel gate
Scripts that play the game: about 360 tests, 88 browser tests, benchmarks and the feel audit. Every deploy runs the feel gate, a quick audit against the saved full report. Page: How we test.
Status and alerts
A StatusWatch object checks the site, Cloud games per region and each Dedicated server every minute for the public status page, and sends phone alerts. The ops worker watches from outside the game. Page: Watching the game.
From Play to a game
- Play opens a game connection with the mode you picked.
- The Worker picks your region from where you connect, or from Settings, Server.
- World looks for a public room of that mode on the current game version that isn't full, leaning toward players near your rating. If none fits, it lists a new room at once, so players who press Play at the same moment land together.
- The Worker opens that room in your region and hands it your connection. A Dedicated room sends your page to its server with a signed ticket instead (Dedicated).
- If World doesn't answer, you still get in: you join the region's main room.
Home's Find a game places you in a game at once: Find a game.
Staying connected
- A game stays on however long its tab is in the background. The room's idle rules still apply: an idle player goes to watching after 12 minutes and out 15 after that.
- A background tab's pings ride on the room's messages, since the browser slows its timers, and it tells the room it's hidden.
- The seat hold: a connection that closes without saying goodbye keeps its seat for 15 s, or 60 s from a background tab. The ball stands still and no bot takes it. The page dials again every second and comes back as the same player, same team, with no screen. Past the hold, a stand-in drives the ball until you're back.
- "You were away" shows only when the page's last message is older than the hold, with one click back into the same game.
- Leaving on purpose says goodbye: the seat goes at once, with no stand-in.
The switch is SEAT_HOLD_LIVE. More: Background tabs and the seat hold.
Caches
- Lists that are the same for everyone (live games, boards, store items) are answered from a cache near you, kept from 3 seconds to 5 minutes depending on the list.
- Pages you opened in the last 25 to 60 seconds show at once when you go back, and a fresh copy loads in the background.
More: Find a game, How ranks work, How the store and TagCoins work, How Home and search work, How email works, How replays and clips work, How groups work, How we ship, Bugs we hit, and how the site got here in the devblog.