· 3 min read ·

SpacetimeDB Puts the Server Inside the Database

Source: lobsters

The standard multiplayer game backend is a stack you’ve seen a hundred times: a game server process, a database it reads from and writes to, and a networking layer stitching the two together. SpacetimeDB, from Clockwork Labs, argues that the separation between those layers is the problem, not the solution.

The core idea is straightforward. Instead of a game server that talks to a database, you write your server logic as modules, compiled to WebAssembly, that run inside the database runtime itself. The database owns both the state and the compute. Clients subscribe to queries rather than polling endpoints, and the system pushes diffs to them whenever matching rows change.

This technical review walks through how SpacetimeDB actually behaves under scrutiny, and it’s a useful read for anyone evaluating the system beyond the marketing pitch.

What the Architecture Gets Right

The subscription model is genuinely interesting. Rather than a client repeatedly asking “what changed?”, it declares interest in a query once, and SpacetimeDB handles the rest. For game state, where you care about a subset of entities near a player or within a session, this maps well to what you actually need.

The WebAssembly sandbox for modules is a reasonable choice. You get isolation without the overhead of a separate process, and Rust is the primary supported language for writing modules, which means you can share types between your client and server logic. The C# SDK support broadens the audience considerably for Unity developers.

Collocating compute and storage also eliminates a class of round-trip latency. When your update logic runs inside the same process as the data it reads, you skip serialization, network hops, and deserialization for internal state transitions.

Where It Gets Complicated

The tradeoff for that colocation is that your module code runs under significant constraints. WebAssembly modules can’t do arbitrary I/O, can’t spawn threads in the usual sense, and are subject to the database’s execution model. If your game logic needs to call an external HTTP endpoint, integrate with a physics engine, or do heavy parallel computation, you’re working against the grain of the system.

The query subscription model, while elegant in principle, puts pressure on schema design. Queries are SQL-like, but they have to be statically registerable at client connection time. Dynamic or complex subscriptions can get awkward. The row-level diff propagation also means that highly volatile state, like projectile positions updating at 60 Hz across hundreds of clients, can generate a lot of churn in ways that aren’t always obvious upfront.

The operational story is also still maturing. SpacetimeDB is built around a specific deployment model, and if your infrastructure assumptions don’t align with it, you’re doing more work than the system saves you.

The Honest Assessment

SpacetimeDB is solving a real problem: building low-latency, stateful multiplayer games is genuinely hard, and the traditional stack forces you to manage consistency across a process boundary that wouldn’t need to exist at all. The colocation approach has legitimate merit.

The system is also young. The constraints around module execution, the operational maturity, and the edge cases in subscription behavior are all things that a production team would need to pressure-test carefully. It’s not a drop-in replacement for an existing backend; it’s a different model that requires buying into its assumptions.

For greenfield projects where the use case fits, particularly smaller-scale multiplayer games or experiments, it’s worth evaluating seriously. For anything at scale or with unusual compute requirements, the architectural constraints deserve careful attention before committing.

Was this interesting?