Skip to content(if available)orjump to list(if available)

SpacetimeDB

SpacetimeDB

204 comments

·April 9, 2025

aeturnum

SpacetimeDB fits into a genre of tech that I want to call "universe brain reorgs" - structural re-arrangements that might unlock wild performance increases. The challenge with these is that they require devs to re-align their thinking and it's hard to disentangle if "the problem" is that the technology isn't being fully embraced or if the promises of the tech don't work for your use case.

Other techs in this category have seen a lot of success. I'd classify Elixir and Node as being similar in that you adopt a stack to get access to some rare guarantees and also accept new or exotic limits.

I think these things tend to rely on having clear-eyed visionaries out in front, able to show off their strengths in open source. Without a successful project it's hard to believe the claims. I hope clockwork labs is able to deliver their example game (it seems high risk because, even if the game is a technical wonder - what if it isn't fun?!).

gafferongames

> SpacetimeDB fits into a genre of tech that I want to call "universe brain reorgs" - structural re-arrangements that might unlock wild performance increases. The challenge with these is that they require devs to re-align their thinking and it's hard to disentangle if "the problem" is that the technology isn't being fully embraced or if the promises of the tech don't work for your use case.

And this is exactly why as a professional multiplayer game developer I'm quite concerned about SpacetimeDB.

If you're a game developer and choose to use it, you must accept that you will completely structurally re-arrange your game server, and gameplay and simulation code in such a way that you'll conform to a database structure and programming model developed by some people who are currently making their first game.

I'd be surprised if any professional game developers would consider this a good idea. The last time somebody suggested such a significant refactor for game servers, was when the two cofounders of Improbable walked into our office at Respawn, shortly after we shipped Titanfall 1, and told us they wanted the complete source code for Titanfall 1, and they would show us how awesome Improbable is, by porting the entire Titanfall codebase to Improbable in just a few months!

They ended up getting the source code, despite all programmers and the technical director advising the COO against it... and we never heard from them again.

cloutiertyler

We are definitely inspired by Elixir/BEAM. IMC (inter-module communication) is directly inspired by it.

It is high risk, but I think a risk worth taking.

aeturnum

Absolutely! I work in Elixir and I feel very good about its tradeoffs - and a lot of being good with the tool is knowing when to not use it. This tech is very much out of my wheelhouse but it seems very cool and I hope y'all find a nice fit!

MasterYoda

Which tradeoffs does elixir have?

null

[deleted]

theLiminator

> Node

What's your reasoning behind this? Just being able to run the same code on frontend and backend?

barrell

When node first came out, it was pretty revolutionary. Being able to almost instantly start a JavaScript thread from a single file that could support realtime experiences (a la socket.io et al) without a build step felt pretty paradigm shifting

Swannie

Yeah, nah.

I worked on telco grade systems running on Rhino, in interpreted mode, in 2006. Leveraging Java to JS bindings. Responding to HTTP/JMS/etc.

cess11

How would that differ from PHP?

ffsm8

> could support realtime experiences

Node supports realtime applications? Really? Isn't it garbage collected? Or does the term mean something different in nodejs? I've only come to know the term in the context of time guarantees (i.e. if it's scheduled to run in x, it is guaranteed to run at that time) and that shouldn't apply to nodejs I think? When you schedule something there, I believe it'll run on the first free thread after the timer relapsed - which entirely depends on the load of the system

aeturnum

Like, if you decide to do your backend in rust or python you can choose async or synchronous approaches - but Node locks you into async. I'm not a node developer so I can't sing the praises of what you get, but being locked into JavaScript's process model, VM, and type system is certainly a downside (for which you get the whole JS world). It's another example of...if you are architecting your service and you pick this you are picking some built in trade-offs.

efilife

maybe I don't understand something but most if not all node methods have their sync counterparts

duxup

I feel like a lot of the "needs visionaries?, stuff has a pretty high chance of having not much real value.

That's not a judgment on SpacetimeDB, but it is kinda how it plays out with these kinds of things.

aeturnum

IMO it's more that there is value...but the chance that any random developer (i.e. me) is going to be able to realize it is much lower. Your instincts about how do to things will be predictably wrong in this new, different paradigm. You generally want a guide or you risk foot-gun'ing any project through misunderstanding.

meheleventyone

Could also be marketing hype! The MMO space tends to be full of this, most famously in the VC funded arena with Improbable. This also suffers from the same problem that Improbable did that there are just not that many people making MMOs but maybe it'll find a niche elsewhere.

I've been making multiplayer games professionally for twenty years from fast-paced shooters to spaceship MMOs and to me this isn't really crazy. If you wanted to make a comparison it's like having SQLite in memory but with the added infrastructure to support networking to clients and persisting state to disk. Obviously there is more work involved than that but conceptually thats where things are at. How nice it is to actually develop a game with is a pretty open question, and almost certainly the most important one when evaluating this sort of product, but you'd be surprised at the range of stacks in existence.

AtlasBarfed

It's a database that emphasizes stored procedures. And if you need it to distribute computing, it has the same challenges as the eliminated "game servers".

In addition, outside of single table updates and selects, SQL has scaling limits. If you throw the computation at the db server as well, you limit the vertical scaling.

Gaming and gamers are used to sharding (and geographic tower of babel us an implicit shard as well).

lakomen

[dead]

bob1029

> SpacetimeDB wasn't built in a vacuum. It's the system powers our own large-scale MMORPG BitCraft. We designed it specifically for the performance requirements of games. That means extremely low latency (~100 us/Tx) and extremely high throughput (~1,000,000 Tx/s).

If you are trying to build a new MMO that scales to the moon, you might want to take a look at how the existing market goes about things.

Take World of Warcraft for example. You could probably put a $20 MySQL VPS behind a realm and have it reliably persist state with how authoritative and infrequently updated the clients are.

Being clever with what you can trust the client with and how the server reconciles events is where I think you will find most of the scaling hacks.

kriper

I don't really understand how you would write a game server using this tech. Lets say you need to simulate physics, pathfinding, animation etc on server. How one would integrate all of this? In regular world you just use unreal/unity headless mode that includes all of this but using spacetimedb requires ditching the game engine and reimplementing everything from scratch?

nerflad

Just put it all in stored procedures. What could go wrong?

janderland

Forgive my ignorance, but why would you implement physics and animations on the server? I feel like you can get away with basic positional data and do the rest of that on the clients.

kriper

You need physics in order to make movement server authoritative. Otherwise player will be able to fly around and ignore collusions. You might need animation state in server if you are making a fps shooter and want to calculate raycasts properly.

weego

This looks really interesting, and bitcraft looks cute.

I did hit a personal bias: when I saw "maincloud" as a phrase to do with pricing my heart sank because my brain went "they've wedged in some crypto shit!". Turns out no, it's just a naming thing for hosting credits.

cmrdporcupine

There was a lot of crypto-adjacent talk in earlier versions of their marketing and product design. Without it actually being anything actually crypto-adjacent. Analogies drawn to ethereum etc concepts, I guess because they figured somehow there was an audience that would get those references and it would allow them to understand the product better?

I have no idea why. I was hired to work on very early versions of it, and left very early on in part because I wanted nothing to do with that angle. IMO it's a liability.

cloutiertyler

It had nothing to do with marketing, it was because conceptually stored procedures are similar to smart-contracts and share technical aspects. We thought engineers would find the similarities interesting. Instead they immediately assumed we were shilling tokens, so we pulled it down.

Kind of sad that people can't see past that, but I also understand. It is what it is.

cmrdporcupine

Hey Tyler; looking back I think maybe a better language than "reducers" etc would have been to just something analogous to the ECS term "systems", which I understand to be "processes that operate on entities / components" and always seemed overly general and non-specific to me but at least is familiar to game programmers operating in data driven design.

You may recall I was partial to the term "verb" :-)

cloutiertyler

Oh it's you! Sorry cmrdporcupine! I didn't see.

pmx

I feel like they've been inspired by crypto for the way they handle billing. They sell you "Energy" which you use by running on their infra. Seems like a needless abstraction to me.

anentropic

Doesn't Snowflake do something similar though?

Tomuus

And Vercel's "compute units"

cloutiertyler

They do indeed.

_huayra_

This is indeed interesting, but FYI this is a BSL-covered project with somewhat onerous times: only one instance per service (i.e. don't scale out, if I understand correctly) [0].

[0] https://github.com/ClockworkLabs/SpacetimeDB?tab=License-1-o...

paulluuk

YouTube keeps recommending SpacetimeDB to me even though I have never made a videogame. Now I'm seeing it on HN too.

Are there any game devs here who can comment on how useful this actually is? The pitch seems pretty cool but I can't tell how much of it is just good marketing.

matthewfcarlson

Not a developer affiliated with the project. But here's my take:

The problem is that the proof is in the pudding. Some of their claims feel outlandish. Imagine writing your game with SQL queries. Rather than crafting update packets that only contain relevant game info you just do `select * from players where abs(player.x - current_player.x) + abs(player.y - current_player.y) + abs(player.z - current_player.z) < 100^2` and it just updates automagically 60 times a second.

Running physics sim in SQL stored functions sounds insane but that's exactly what they're advertising. They say it's due to in-mem DB optimization but I'm not sure how they horizontally scale that (they allow you to run standalone but any scaling requires their cloud product)

cloutiertyler

I mean you can download it and give it a try!

For BitCraft we scale it with IMC (inter-module communication). It works very similarly to Elixir.

Rohansi

It's in closed alpha so there's a limited number of players but I am curious to hear more about how BitCraft is scaling out. Is it a single, seamless world for all players? How much scaling is currently required? How is data replicated when horizontal scaling comes into the picture?

manas96

Given the name I was also expecting some clever SQL-like data structure/query for fast spatial lookup but I digress.

Game physics involves a lot of things (solvers, collision detection, numerical stability, etc.). I am skeptical of their claims of being able to run physics in what I understand are stored procedures for their database.

I looked at their docs for physics https://spacetimedb.com/docs/unity/part-4 where they demonstrate the simplest form of collision check (sphere overlap). I fail to see how that is an improvement or speedup over existing methods. Some quotes: "This may not be the most efficient way to do collision checking (building a quad tree or doing spatial hashing might be better), but SpacetimeDB is very fast so for this number of entities it'll be a breeze for SpacetimeDB." >> Nothing is quantified with numbers.

"For every circle, we look at all other entities." >> This is the most inefficient N^2 way you could do collision detection.

And not to mention networked physics is a whole additional layer of complexity, where you have to use some form of prediction techniques and very likely end up changing your core physics code to accommodate this.

All of this suggests to me much thought has not been put into the claim "you can also do physics with it!" and its implications. Perhaps it is enough for extremely simple physics, as demonstrated with their demo game. If the author is reading this, I suggest spending some time understanding what this claim implies and qualifying it better.

However I must mention that I applaud their courage to try something so outlandish. If you truly believe your claims are possible, I encourage you to keep working on it.

But I'll be convinced when extraordinary evidence backs extraordinary claims.

Source: I work on a commercial game physics engine and related netcode.

Cieric

I believe they've done more complicated physics in their game bitcraft, but that code hasn't been released yet (no idea if it will be.) But there has been work in the discord recently and 2 member have individually implemented rapier[1] at this point. I can't say anything about the related netcode however as I don't know how much they've focused on it. At the very least work has been done.

The unity tutorial is just to get up and running as fast as possible in the simplest way possible, not to make the perfect decisions for a networked physics based game.

I however do think they should provide an actual reference to prove the claim,

[1] https://github.com/dimforge/rapier

manas96

Nice, that's very interesting and a commendable achievement!

If that is the case I would really like to see some internals of how the physics engine has been implemented in their pattern. I'm not asking for the rapier port source code, but it is hard to think in terms of a new advertised programming paradgim when there's no working examples.

For example I am very curious to see how a constraint solve is implemented in a SQL-like fashion. You would need various math operations and an efficient matrix representation off the top of my head, and I can't think of how that maps to a SQL-like interface.

manas96

Then again looking at the FAQ for Bitcraft, we have this:

"What engine does BitCraft use? The BitCraft client is developed using the Unity game engine. For the server, we have developed a sophisticated distributed system called SpacetimeDB, which hosts the entirety of BitCraft’s server architecture. "

Correct me if wrong, but this suggests the physics engine is Unity's, and not something implemented in SpacetimeDB.

jackb4040

It's a cool technology, but the hard thing about building an MMO is architecture, not just making the server faster / wider. If you want a good overview of the types of problems to be solved in scaling an MMO, check out https://youtu.be/-c4t3Y5l5jY.

There is a pretty big underlap between these problems, and the ones solved by SpacetimeDB. So much so that if you built a system using both SpacetimeDB and another, high-level tool to manage chunking, transitioning, server provisioning etc. it would obviously be the latter system that was more indispensable to scaling your MMO.

Rohansi

As a game dev I don't really see what problems this solves. Most of the work you would have in games is related to simulation - something this doesn't help you with at all. It can actually make simulation more difficult because all your state would be decoupled from a game engine (which is built for simulation). So you'd end up having game servers running the simulation syncing to SpacetimeDB... or of course you try to build the simulation inside SpacetimeDB with no help from it.

cloutiertyler

It solves 3 problems:

1. Server <> client sync is handled for you 2. Server <> database sync is eliminated 3. Deployment is super easy because you just upload your wasm module to the database, and SpacetimeDB schedules it (similar to Kubernetes honestly, but at a different level of the stack)

Rohansi

The first two problems are nothing, IMO. Server <> client sync is handled by your engine or, if you need to roll your own, it's not that hard. Syncing to a database is more tedious than difficult.

Getting rid of a game engine on the server side adds a lot more work. I don't think it would even balance out.

XCSme

> 1. Server <> client sync is handled for you

In what sense? Is it as fast as using UDP with protobuf packets?

gafferongames

Professional multiplayer game developer here. I wonder what multiplayer games the SpacetimeDB folks have actually shipped?

pmx

This is theirs https://bitcraftonline.com/ - not "released" yet but they have alpha testers on it apparently.

gafferongames

Would you seriously consider using any technology built by people who are making their first game?

thefourthchime

Same! The algorithm thinks I needed to watch this.

bryanrasmussen

This guy often comes here from HN, give him some Rust, Elixir, why JavaScript framework of the day sucks, and this SpacetimeDB thing!

beders

    #[table(name = person, public)]
    pub struct Person {
        name: String,
    }
No, just say no. Do not conflate your relational database schema with however you treat that data in your app. You want explicit control, not annotation magic.

robmccoll

This sounds like a fundamental disagreement with using ORM. Are you advocating for always writing queries (not excluding the possibility of a query builder) over treating database rows as application-side entities that can have CRUD operations performed on them / persisted?

matthewfcarlson

A relational DB + serverless compute + suspiciously fast updates

thefourthchime

Haha, yes very suspiciously fast!

ksynwa

Is there a place where I can read about what technologies online games use? As a terminal gamer I am ashamed to say I have no idea what goes on behind the scenes.

spmurrayzzz

Assuming you're referring to the backend side of things for online/multiplayer games, working through the Hathora tutorials in the docs can be a good first introduction to general idioms related to backend systems architecture: https://docs.hathora.dev/#/builder/

From my past consulting experience though, the distributed systems side of games is all over the place. Designs tend to need to be customized for each games needs, which usually directly influences which technologies are chosen.

drwiggly

This looks to be an in memory db, with a wasm runtime to host domain logic. The hand wavy part was how do they handle scale and clustering? Are we sharding the data our selves (atm it seems so.).

This is nice and all but the hard part is replication and consistency in a distributed database. In memory has its uses, also disk backed tables can have their uses. Pretty much normal databases already do this, just writing domain logic in stored procs is kind of annoying.

I'd imagine embedding sqlite in your binary using memory tables is equivalent at the moment. Well you'd have to write code to publish table updates to clients. I suppose it has that going for it.

I've seen some hand wavy docs about clustering but nothing concrete.

Geee

Does this make any sense in single-player games, where the db would run locally on the user's machine? Does it have any benefit to run all game state through a local db?

I'm not a game dev, but I'm imagining that if I'd write a custom game engine, I'd have to write just the "frontend" aka. graphics engine if I'd have a robust state manager (+tooling) as a separate piece of software.

hansvm

Some algorithms are much more easily represented as SQL or that plus a little wrapper code. E.g., somebody re-wrote E-Graphs Good using SQL as their primitives, and that viewpoint made a bunch of other features and optimizations obvious.

Stated somewhat differently, do you want to write the algorithm to do a 3-connected recursive join in linear time, or do you want to slap the join into a DB and move on with your life?

For a concrete example, a DB could make the Entity-Component architecture even simpler to use than it already is (give me all the npcs in this radius who haven't attacked in the last second, have a distance attack, and are facing the right direction).

Would it have performance pitfalls if you weren't careful? Almost certainly. It could be a fun way to structure a game though.

sitkack

If you know all of your queries ahead of time, then compiling them efficiently has already been shown to be effective.

Noria

https://github.com/mit-pdos/noria

https://www.youtube.com/watch?v=kVv9Pik6QGY

https://thesquareplanet.com/research/

Materialize/TimelyDataflow

https://scholar.google.com/citations?hl=en&user=YYJ3aycAAAAJ...

hansvm

Oh, sure, the complaint wasn't about SQL per se, but that making complicated things easy to write isn't necessarily a win. Even if a big query perfectly represents the problem, and even if you can use compiled SQL to match hand-written efficiency, it still might not be the optimal way to approach the problem in the first place. If you have experience and plan for that it needn't be bad at all, but I think it's easier to write performance footguns in SQL (the "right" data model is more prescriptive, even with some number of years of experience, and is less likely to be tuned to your actual problems) than with traditional code, so I'd be quite surprised if the majority of game developers (even those with some degree of success currently average <3 YOE) wouldn't run into major performance issues with a SQL-based engine, even a good one.