What is SpacetimeDB?
You can think of SpacetimeDB as both a database and server combined into one.
It is a relational database system that lets you upload your application logic directly into the database by way of fancy stored procedures called "modules."
Instead of deploying a web or game server that sits in between your clients and your database, your clients connect directly to the database and execute your application logic inside the database itself. You can write all of your permission and authorization logic right inside your module just as you would in a normal server.
This means that you can write your entire application in a single language, Rust, and deploy it as a single binary. No more microservices, no more containers, no more Kubernetes, no more Docker, no more VMs, no more DevOps, no more infrastructure, no more ops, no more servers.
SpacetimeDB application architecture
(elements in white are provided by SpacetimeDB)
It's actually similar to the idea of smart contracts, except that SpacetimeDB is a database, has nothing to do with blockchain, and is orders of magnitude faster than any smart contract system.
So fast, in fact, that the entire backend of our MMORPG BitCraft Online is just a SpacetimeDB module. We don't have any other servers or services running, which means that everything in the game, all of the chat messages, items, resources, terrain, and even the locations of the players are stored and processed by the database before being synchronized out to all of the clients in real-time.
SpacetimeDB is optimized for maximum speed and minimum latency rather than batch processing or OLAP workloads. It is designed to be used for real-time applications like games, chat, and collaboration tools.
This speed and latency is achieved by holding all of application state in memory, while persisting the data in a write-ahead-log (WAL) which is used to recover application state.
You can run SpacetimeDB as a standalone database server via the spacetime
CLI tool.
Install instructions for supported platforms are outlined below.
The same install instructions can be found on our website at https://spacetimedb.com/install.
Installing on macOS is as simple as running our install script. After that you can use the spacetime command to manage versions.
curl -sSf https://install.spacetimedb.com | sh
Installing on Linux is as simple as running our install script. After that you can use the spacetime command to manage versions.
curl -sSf https://install.spacetimedb.com | sh
Installing on Windows is as simple as pasting the above snippet into PowerShell. If you would like to use WSL instead, please follow the Linux install instructions.
iwr https://windows.spacetimedb.com -useb | iex
If you prefer to run Spacetime in a container, you can use the following command to start a new instance.
docker run --rm --pull always -p 3000:3000 clockworklabs/spacetime start
For more information about SpacetimeDB, getting started guides, game development guides, and reference material please see our documentation.
We've prepared several getting started guides in each of our supported languages to help you get up and running with SpacetimeDB as quickly as possible. You can find them on our docs page.
In summary there are only 4 steps to getting started with SpacetimeDB.
- Install the
spacetime
CLI tool. - Start a SpacetimeDB standalone node with
spacetime start
. - Write and upload a module in one of our supported module languages.
- Connect to the database with one of our client libraries.
You can see a summary of the supported languages below with a link to the getting started guide for each.
You can write SpacetimeDB modules in several popular languages, with more to come in the future!
SpacetimeDB is licensed under the BSL 1.1 license. This is not an open source or free software license, however, it converts to the AGPL v3.0 license with a linking exception after a few years.
Note that the AGPL v3.0 does not typically include a linking exception. We have added a custom linking exception to the AGPL license for SpacetimeDB. Our motivation for choosing a free software license is to ensure that contributions made to SpacetimeDB are propagated back to the community. We are expressly not interested in forcing users of SpacetimeDB to open source their own code if they link with SpacetimeDB, so we needed to include a linking exception.