Splitting the site into four Workers
16 to 17 Nov 2026
- The site now runs as 4 Cloudflare Workers instead of one: the site with World, the game rooms, the helpers and the forums.
- Before the split, all 229 deploys from 13 to 17 Nov reached every game on Backup. In the first 157 deploys after it, 116 changed only the site and restarted no game.
- The Dedicated servers rolled after 38 of those 157 deploys and were left alone after the other 119.
- The site’s startup time on Cloudflare did not clearly change. Its median was 277 ms over all deploys before the split, 172 ms over the last 40, and 214.5 ms after.
Cloudflare deploys a Worker as one unit. If game rooms live in the same Worker as the site, a fix to a page restarts every game, so give the rooms their own Worker.
Each game on Backup is a Durable Object. Until 17 Nov those objects lived in the same Worker as the site, World and the API. Cloudflare deploys a Worker as one unit, so every deploy reached every running game, even one that only changed a page. Each game then restarted at its next calm moment, and its players reconnected in about 0.8 s. This fits any project that keeps long-lived real-time objects beside a site that changes often. The wiki page How TagBalls is built describes the current state.
Measured how: we read the deploy chain’s logs. For every deploy, Cloudflare prints which Worker it uploaded, the upload size and the Worker’s startup time. 229 deploys from 13 Nov 09:41 to 17 Nov 00:04 ran on one Worker, and 157 deploys from 17 Nov 00:19 to 16:13 ran on four. Counts and sizes do not depend on machine load. Startup times are Cloudflare’s own figures.
| Measured | One Worker (229 deploys) | Four Workers (157 deploys) |
|---|
| Deploys that reached games on Backup | 229 | 38 |
| Deploys that changed only the site | 0 | 116 |
| Site upload size, median | 7,324 KiB (last 40 deploys) | 7,302 KiB |
| Site startup time on Cloudflare, median | 277 ms (172 ms over the last 40) | 214.5 ms |
| Upload time per deploy, median | 10.6 s | 9.1 s for the site alone, 17.2 s with the game Worker |
The other Workers after the split, medians: game 4,619 KiB and 140 ms startup, helpers 5,215 KiB and 162 ms, forum 59 KiB and 3 ms.
How it works
- The site Worker keeps its name, address, routes and secrets. It reaches game rooms, the helpers and the forums through Durable Object bindings, so a join is still one hop.
- A room checks its version against World’s answer. World answers a game Worker room with the game Worker’s version, which it reads at most every 10 s, so a site deploy never hands rooms off.
- The deploy script lists every file each Worker’s bundle imports, the way the bundler sees them, and the deploy chain deploys only the Workers whose files changed.
- The order is helpers, game, forum, then site, because the site binds the other three. The first failure stops the rest.
- The Bot League’s data was copied once into the helpers Worker, table by table, with row counts compared. The old copy stays frozen as the rollback.
What didn’t work
- The site did not start faster. A local profile had shown its startup halving, but Cloudflare’s own figures showed no clear change. World still imports most of the game code for its checks, and the old League copy is still in the site.
- Moving the League with Cloudflare’s class transfer migration: it cannot be rehearsed locally and a failed transfer cannot be retried, so we copied the data instead.
Not done yet: the cleanup that removes the old League copy and the empty room classes from the site.
Reuse
- Put long-lived real-time objects in their own Worker, and bind them from the site. A binding call costs the same as before and adds no hop.
- Decide what to deploy from the bundler’s own list of imports, not from folder names. Shared code then deploys every Worker that uses it.
- Count what each deploy restarts. It is a better measure of a split than bundle size.
All the details are in the wiki: Four Workers.