⚡ 2,326 req/sec on a $20 server

Build Real-Time
Apps 10x Faster

One binary replaces your backend, database, and real-time layer. Write Rust or TypeScript, deploy instantly, and scale to millions of connections. Real-time subscriptions with DBSP incremental engine — 10-100x faster than alternatives.

$ cargo install cosmictron

Your backend
is too complex

The traditional stack forces you to maintain an app server, a database, a pub/sub system, and an ORM layer. Network hops between tiers destroy latency. Cosmictron collapses all of it into one.

Traditional Stack
Client SDK
↓ HTTP / REST
App Server (Express, Rails...)
↓ ORM / SQL
Database (Postgres, MySQL...)
↓ triggers / polling
Pub/Sub (Redis, Kafka...)
↓ websocket
Real-time Server (Socket.io...)
Cosmictron
Client SDK
↓ WebSocket (binary)
Cosmictron
Database + Compute + Real-time
MongoDB Realm Deprecated Sept 2025

Migrating from MongoDB Realm?

Realm's deprecation left thousands of apps searching for a new home. Cosmictron offers a smoother migration path with similar concepts but superior performance.

From Realm

  • Device Sync → Real-time subscriptions
  • Functions → Reducers (ACID guarantees)
  • Triggers → Lifecycle hooks
  • BSON → BSATN (binary, efficient)
Migration Guide →

Most apps migrate in 1-2 days

Cosmictron vs
the Alternatives

See how we compare to the tools you're already evaluating.

vs SpacetimeDB

  • DBSP incremental joins & aggregations (10-100x faster)
  • Declarative row-level security (no manual auth code)
  • Deterministic simulation testing (FoundationDB-style)
  • MIT/Apache license (not BSL source-available)

vs Supabase/Firebase

  • Business logic runs in database (zero latency)
  • Single binary, fully self-hosted (no vendor lock-in)
  • Predictable costs (no per-operation billing surprises)
  • WebSocket binary protocol (not REST polling)

vs Building Your Own

  • No glue code between database and backend
  • Automatic real-time sync (no Socket.io wiring)
  • ACID transactions across all operations
  • Production-ready in days, not months

Everything you need.
Nothing you don't.

Zero-Latency Backend

Your business logic runs inside the database, not across the network. Microsecond response times on every request.

🔄

Real-Time by Default

Subscribe to any SQL query. Clients get instant deltas when data changes. DBSP incremental engine — 10-100x faster than full re-evaluation.

🛡️

Security You Can't Forget

Row-level policies are declarative SQL, automatically injected into every query. Impossible to accidentally expose data.

📦

One Binary to Rule Them All

Replaces your app server + database + pub/sub + cache. Self-hosted in 30 seconds. Zero external dependencies.

🔬

Deterministically Tested

FoundationDB-style simulation testing from Day 1. Every crash recovery path tested with 1000s of random seeds.

🚀

Zero-Downtime Deploys

Hot-reload modules without dropping connections. Blue/green deployment with automatic rollback on failure.

🔌

Postgres Compatible

Query with psql, DBeaver, or any PostgreSQL tool. Wire protocol support means existing tools just work.

🎯

Type-Safe Everything

Derive macros eliminate serialization boilerplate. TypeScript client with full intellisense. No more stringly-typed APIs.

📊

OpenTelemetry Observability

End-to-end tracing from client click to database commit. Prometheus metrics included. Production-ready monitoring.

Zero Boilerplate.
Maximum Velocity.

Derive macros eliminate serialization boilerplate. The Query API provides type-safe database operations. Focus on your logic, not the plumbing.

chat/src/lib.rs Rust
use cosmictron_sdk::*;

#[derive(BsatnSerialize, BsatnDeserialize)]
#[table(name = "messages")]
pub struct Message {
    #[primary_key] #[auto_inc]
    pub id: u64,
    #[index]
    pub channel_id: u64,
    pub content: String,
}

#[reducer]
pub fn send_message(
    channel_id: u64,
    content: String,
) {
    let msg = Message {
        id: 0,  // auto-assigned
        channel_id,
        content,
    };
    datastore::insert(&msg);
}

#[reducer(client_connected)]
pub fn on_connect() {
    info(&format!("User {} connected", 
        identity_abbr(&caller_identity())));
}
app.ts TypeScript
import { CosmictronClient } from '@cosmictron/client';

const client = new CosmictronClient(
  'ws://localhost:8080'
);

// Connect and authenticate
await client.connect();

// Subscribe to messages in real-time
await client.subscribe(
  'SELECT * FROM messages WHERE channel_id = 1',
  (update) => {
    update.inserts.forEach(msg =>
      console.log(`New: ${msg.content}`)
    );
  }
);

// Send a message
await client.callReducer(
  'chat',
  'send_message',
  { channel_id: 1, content: 'Hello!' }
);
0
Avg. Latency
Complex JOIN subscription
0
Requests/sec
500 concurrent clients
0
Faster for Joins
DBSP vs full re-evaluation
0
Connections/node
On a single $20 server

Built for Production

146 Tests Passing
100% Memory Safe
Deterministically Tested
MIT Apache-2.0 License
"We replaced our entire Express + PostgreSQL + Redis stack with Cosmictron. Deployments went from 30 minutes to 30 seconds, and we eliminated an entire class of cache invalidation bugs."
Senior Platform Engineer
Fintech Startup, 50K+ users
"The DBSP incremental subscriptions are magic. We went from 8-second re-queries to 80ms deltas on complex JOINs. Game-changer for our real-time dashboards."

From code to real-time
in four steps

01

Define Tables

Use the #[table] macro to declare your schema with types, indexes, and constraints in Rust structs.

02

Write Reducers

Business logic as plain functions. Each call is an atomic transaction with full access to the datastore.

03

Deploy

Compile to WASM and deploy with the CLI. Hot-reload is supported with zero downtime.

04

Subscribe

Clients subscribe to SQL queries over WebSocket. Deltas stream in real-time as data changes.

Built for Real-Time
Everything

🎮

Multiplayer Games

Low-latency state sync for thousands of concurrent players. Deterministic reducers prevent cheating. Powers games with 6M+ playtime hours.

See game example →
💬

Chat & Collaboration

Slack-like channels, presence indicators, and typing notifications out of the box. No CRDT complexity required.

See game example →
📊

Live Dashboards

Stream real-time analytics with incremental aggregations. No polling. No cache invalidation. Sub-millisecond updates.

See dashboard →
🏢

Multi-Tenant SaaS

Declarative row-level security isolates tenant data automatically. One query, scoped results. Built for B2B applications.

Learn about RLS →

Predictable Costs.
No Surprises.

Self-hosted means your server, your rules, your budget. No per-operation billing spikes.

Firebase Blaze

Expected: $50/month Actual: $280/month Viral post → 5x operation spike

Supabase Pro

Expected: $25/month Actual: Suspended Exceeded message quota

Cosmictron Self-Hosted

$20/month Hetzner Cloud instance Unlimited operations Unlimited connections You own the data

Self-hosted = no surprise bills, no vendor lock-in, no quota anxiety.

Ready to ship faster?

Join developers building the future with Cosmictron.
Open source, MIT/Apache-2.0 licensed, free forever.