Quick Overview
SpacetimeDB
- Colocated compute architecture
- WASM modules for business logic
- Real-time subscriptions
- BSL license (source-available)
- Simple query subscriptions
- Manual authorization
Cosmictron ✓
- Colocated compute architecture
- WASM + V8 modules
- DBSP incremental subscriptions
- MIT/Apache-2.0 (fully open)
- Complex query subscriptions
- Declarative RLS
Key Differences
1. Subscription Engine
SpacetimeDB: Uses simple WHERE-filter fast-path for single-table subscriptions. Complex queries (joins, aggregations) fall back to full re-evaluation on every transaction. This means N subscriptions with joins cost O(N * |table|) per transaction.
Cosmictron: Implements DBSP (Database Stream Processing) from the VLDB 2023 paper. This provides incremental view maintenance for ANY relational query:
- Joins are incremental—only matching rows are probed
- Aggregations maintain running totals with O(1) updates
- Nested queries compose incrementally
- 10-100x better scalability for complex queries
Real-World Impact
A dashboard with 10 real-time charts, each showing aggregated data from 3 joined tables, will use 10-100x less CPU with Cosmictron's DBSP engine compared to SpacetimeDB's full re-evaluation approach.
2. Security Model
SpacetimeDB:>Authorization is entirely manual. Every reducer must check ctx.sender against some admin table. There is no declarative security model for reads—any authenticated client can read any public table.
Cosmictron: Offers Supabase-style declarative Row-Level Security:
- Define policies at the table level with SQL predicates
- Read policies automatically injected as WHERE clauses
- Write policies checked before insert/update/delete
- Security-by-default—developers cannot forget auth checks
3. Testing & Correctness
SpacetimeDB: Standard Rust test suites. No evidence of deterministic simulation testing.
Cosmictron: FoundationDB-style Deterministic Simulation Testing (DST) from Day 1:
- All I/O abstracted behind traits
- Virtual clock for deterministic time
- Simulated filesystem with fault injection
- Simulated network with partitions/delays
- 1000s of random seeds tested in CI
4. Licensing
SpacetimeDB: Business Source License (BSL). Not truly open source—becomes open after 4 years. Self-hosting requires careful reading of license terms.
Cosmictron: Dual MIT/Apache-2.0. Fully permissive open source from day one. No restrictions on self-hosting, modification, or distribution.
5. Language Support
SpacetimeDB: Rust, C#, TypeScript (beta). Rust modules compile to WASM.
Cosmictron: Rust (WASM) and TypeScript (V8). Both runtimes offer the same transactional guarantees.
When to Choose Cosmictron
- You need complex real-time queries with joins and aggregations
- You want security-by-default with declarative RLS
- You need fully open-source licensing (MIT/Apache)
- You value deterministic testing for correctness guarantees
- You want TypeScript support without WASM compilation
When to Choose SpacetimeDB
- You're building simple games with basic entity subscriptions
- You don't need complex join queries in real-time
- You're comfortable with BSL licensing
- You want a managed cloud option (SpacetimeDB Cloud)
Migration Path
Both databases have similar architecture (embedded compute + real-time sync), making migration conceptually straightforward:
- SpacetimeDB modules → Cosmictron reducers (both Rust/WASM)
- Subscriptions work similarly (Cosmictron uses SQL instead of custom DSL)
- Client SDK concepts map directly