Menu

Running a week-long shared game world on a single Cloud Run instance that scales to zero
📰

Running a week-long shared game world on a single Cloud Run instance that scales to zero

Reading 0:00
15s threshold

The setup, for anyone curious whether Cloud Run can host something persistent:

- There's no game loop on the server. The world only advances when a request comes in: the service works out how many ticks should have passed since the last one and simulates them right then. With nobody playing, it costs nothing and the instance can go away.

- max instances is 1, so there's one source of truth. Every move is stamped with the tick it lands on and appended to a log.

- The log is cut into chunks of 150 ticks. A finished chunk never changes, so it's served with long cache headers and mostly comes from the CDN, not the instance.

- Every 1,000 ticks the whole world is snapshotted to Cloud Storage, so a cold start restores and catches up instead of replaying the whole week.

- Each player's browser runs the same deterministic simulation, so the server never sends world state, only the list of moves.

A tick is 4 seconds, so a week is about 15,000 years of in-game history.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.