code-of-kai

code-of-kai

Game Programming & Databases: Lessons from SpaceTimeDB

Game Programming & Databases: Lessons from SpaceTimeDB

Hey Elixeers!

I recently came across SpaceTimeDB, a fascinating distributed database being developed by Clockwork Labs for their upcoming MMORPG, BitCraft. What caught my eye is how it tackles familiar data, scale, and concurrency challenges in a way that could offer valuable lessons for the broader software world, even outside of gaming.

SpaceTimeDB blurs the lines between database and server. It allows developers to upload application logic directly into the database via “modules,” effectively eliminating the need for separate web or game servers. Clients connect directly to the database, executing logic within it. This approach promises to streamline development and potentially simplify deployment, as the entire application could be packaged as a single binary.

Intriguingly, SpaceTimeDB prioritizes speed and low latency over batch processing or OLAP workloads, making it well-suited for real-time applications like games, chat, and collaboration tools. This emphasis on real-time performance is achieved by holding all application state in memory and using a write-ahead-log (WAL) for persistence and recovery.

Here’s where it gets interesting for the Elixir community: The creator of SpaceTimeDB draws parallels between his project and Erlang in terms of its approach to concurrency and distributed systems.

This skips directly to the Erlang comparison:

Now, I’m curious to hear your thoughts:

  • Could SpaceTimeDB’s approach to integrating application logic into the database influence how we think about database interactions in Elixir?
  • What are the potential benefits and drawbacks of this tight coupling between application and database?
  • How might Elixir’s strengths in concurrency and fault tolerance complement or contrast with the design principles of SpaceTimeDB?
  • Do you see any opportunities to apply SpaceTimeDB’s focus on real-time performance in Elixir-based applications, within and outside of the gaming domain?

Most Liked

oliveiragahenrique

oliveiragahenrique

What are the potential benefits and drawbacks of this tight coupling between application and database?

That’s a topic I’m really interested in! Since discovering Mnesia, I’ve been contemplating building a fully-fledged, modern database on the BEAM that could run directly alongside an application. It’s definitely a project I plan to tackle one day.

In my view, the biggest hurdle lies in adoption and operational complexity. The current infrastructure ecosystem is heavily geared toward stateless applications for good reason—stateful systems are significantly more challenging to manage and operate. So, as soon as you mention a stateful app, it often raises eyebrows.

That said, I think BEAM’s concurrency model has shown itself capable of handling live updates while safely managing state (Mnesia is a great example of this).

The potential benefits are compelling, especially in terms of performance—keeping data within the same memory space enables faster I/O operations. Plus, simplifying development by eliminating translation layers between database and application formats could improve both speed and ease of development.

I’ll dig into this SpaceTimeDB more in-depth when I have the time. Thanks for sharing! (:

JEG2

JEG2

Author of Designing Elixir Systems with OTP

I’ve seriously considered building a SQLite clone in Elixir. You can see me playing around with the idea on my blog:

Last Post!

bottlenecked

bottlenecked

I’m only saying this half in jest and I haven’t seen the video but… AS/400 with COBOL and DB/2 running on the same machine sounds a lot like this programming model (minus the distributed aspects) :sweat_smile:

Where Next?

Popular in Discussions Top

New
chuck
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
mmmrrr
Just saw that dhh announced https://hotwire.dev/ Is it just me or is this essentially live view? :smiley: Although I like the “iFrame-e...
New
cvkmohan
The upcoming Phoenix 1.6 release looks very interesting. Became a habit to watch the commits - and - what they are bringing in. phx.gen...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
matthias_toepp
I’d love to hear what people think about Wisp, the new Gleam web framework started by Gleam’s primary creator Louis Pilfold. Gleam, alon...
New

Other popular topics Top

JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement