Skip to content

Decision ADR-0001 · The Lighthouse

One stateful real-time server instead of serverless WebSockets

Accepted ·

Context

Every visitor in the 3D world sends movement updates at about 10 Hz, and the server must fan those updates out to nearby players.

API Gateway WebSockets costs about $1 per million messages plus a Lambda invocation per inbound message. Five always-moving players would generate about 130M messages a month, which is over $150. The budget is ≤ $5/month.

Decision

Run one long-lived Node.js process: a modular monolith that owns all real-time state in memory. Request/response work (contact, garden, stats) stays on Lambda (ADR-0004, ADR-0006).

Consequences

  • + Fixed cost (~$2/month of compute), latency under 1 ms inside the server, and full control of the tick loop and fan-out.
  • + Lambda endpoints keep working even if the real-time server is down.
  • − It is a single node. That is mitigated by durable state living only in DynamoDB/S3 (the server is disposable), EC2 auto-recovery, client auto-reconnect with session resume, and sharding into world layers.