Decision ADR-0011 · The Lighthouse
The real-time server keeps serving through a storage outage
Accepted ·
Context
The M5 chaos test (tools/loadtest/src/chaos.ts) restarted the real-time server while DynamoDB was down. The server waited for the arcade's saved state before it accepted anyone: about 30 seconds of retries. Then it gave up and ran the arcade with an empty wall that was never saved. Everything else the server does (pages, chat, presence, the 3D world) needs no storage at all. The same run showed two smaller problems:
- One log line per reconnecting visitor: 1,000 lines for 1,000 visitors.
- A visitor whose saved achievements couldn't be read was treated as having none, so their next lost packet would have overwritten the saved list.
Decision
- Listen at once.
main.tsno longer waits for the arcade's saved state. - The arcade waits for storage.
GameHub.loadedgates it:- joins are queued, and their players are seated by themselves once the saved state has loaded;
- actions are ignored meanwhile, and nothing is written, so empty state can never overwrite saved state;
- after a failed attempt, waiting players are told the arcade is waiting for its storage.
- Retry in the background, without limit. Backoff starts at 2 s and grows to at most 30 s. The server logs once when storage goes away and once when it's back.
- Achievements never act on progress they couldn't read. Nothing is awarded or saved for that visitor, and their next action reads it again.
- Logs are throttled per message (
log-throttle.ts): the first one at once, then at most one a minute, with a count of the ones skipped.
Consequences
- + In a DynamoDB outage the site stays fully usable, apart from the arcade. The arcade starts by itself when storage returns; no restart is needed.
- + At 1,000 bots: back 0.6 s after a restart during an outage; the arcade loaded 5.6 s after DynamoDB returned, with the wall intact; 18 server log lines for the whole run.
- − Until the first load succeeds, players see the arcade "waiting" rather than playing on an unsaved board. This is deliberate: saved state wins over availability for games.
- − Achievements earned during an outage are not awarded. They can be earned again later.