Introduction to SpacetimeDB
What is SpacetimeDB?
SpacetimeDB is a unique fusion of a database and a server, streamlining the architecture for developers who are tired of the traditional model involving separate web or game servers. With SpacetimeDB, application logic can be embedded directly within the database in the form of advanced stored procedures known as "modules."
This architecture replaces the need for deploying intermediary servers as clients connect directly to the database. It’s a revolution in real-time computing, optimized for speed and minimal latency, suitable for applications like online multiplayer games, chat applications, and other collaboration tools.
The novelty of SpacetimeDB is achieved by using a single language—Rust—allowing developers to write and deploy applications as a single binary. This approach eliminates the need for microservices, containers, and other infrastructure-heavy solutions.
Benefits and Key Features
- Unified Architecture: Clients connect directly to SpacetimeDB, running your application logic within the database, eliminating the need for external servers.
- High Performance: Designed to handle real-time workloads efficiently.
- Single Language: Use Rust to write full application and database logic, simplifying development.
- Simplified Operations: No need for DevOps, Kubernetes, Docker, or dedicated server management.
- Security and Flexibility: Integrated permission and authorization logic within the modules.
Speed and Efficiency
SpacetimeDB is designed for environment requiring rapid data processing and minimal latency. It keeps the application state in memory and uses a write-ahead-log (WAL) for data recovery, ensuring both data integrity and swift performance. It's so effective that it supports the entire backend for the MMORPG, BitCraft Online, without additional servers or services.
Installation Guide
Installing SpacetimeDB is straightforward, with options to suit various operating systems:
- macOS: Install via Homebrew with the simple command:
brew install clockworklabs/tap/spacetime
- Linux: Download and install using:
curl --proto '=https' --tlsv1.2 -sSf https://install.spacetimedb.com | sh
- Windows: Run in your terminal:
iwr https://windows.spacetimedb.com -useb | iex
- Docker: For an installation-free experience using Docker:
docker run --rm --pull always --name spacetimedb -p 3000:80 clockworklabs/spacetimedb:latest start
- Source: For advanced users, build from source on MacOS and Linux following specific commands.
Expand Your Knowledge
Comprehensive documentation is available to guide you through getting started and utilizing SpacetimeDB's full potential. For beginners, follow a simple four-step process to implement SpacetimeDB:
- Install the
spacetime
CLI tool. - Initiate a standalone SpacetimeDB node.
- Develop and upload a module.
- Connect to the database with a client library.
Supported Languages and Libraries
SpacetimeDB supports multiple languages for module creation and client libraries:
- Server-side Libraries: Available in Rust and C#, with Languages like TypeScript, Python, C++, and Lua planned.
- Client Libraries: Available in Rust, C#, and TypeScript with more extensions in planning.
Licensing
SpacetimeDB is under the BSL 1.1 license with a pathway to the AGPL v3.0 license after a few years, including a linking exception to facilitate community contributions without forcing open-source requirements on user code.
SpacetimeDB is a paradigm shift in real-time, high-speed database and application server integration, offering novel solutions for modern software development challenges.