Architecture Comparison
Supabase
- PostgreSQL database
- Separate application server
- WAL-based Realtime
- Row Level Security (RLS)
- REST + GraphQL APIs
- Managed service
Cosmictron ✓
- Embedded database + compute
- Business logic in database
- DBSP incremental engine
- Declarative RLS
- WebSocket binary protocol
- Self-hosted or managed
Key Differences
1. Latency
Supabase: Your application server (Edge Functions or external) makes HTTP requests to PostgreSQL. Even with edge deployment, you're looking at 20-100ms for round-trips between compute and database.
Cosmictron: Business logic runs inside the database process via WASM/V8 sandboxing. Zero network hops between compute and data. Microsecond-level latency (0.8ms average).
When Latency Matters
Multiplayer games, high-frequency trading, real-time bidding, and collaborative editing all benefit from sub-millisecond response times. With Supabase, you'll need to add caching layers (Redis) that add complexity. With Cosmictron, it's fast by design.
2. Cost Predictability
Supabase pricing is based on usage quotas. Exceed your limits and your project gets suspended.
| Scenario | Supabase Pro ($25/mo) | Cosmictron Self-Hosted |
|---|---|---|
| Viral post (10x traffic spike) | Suspended or overages | Handles it (same $20 server) |
| 500 concurrent connections | Included (up to 500) | 10,000+ supported |
| 5M messages/month | Included (up to 5M) | Unlimited |
| 2x quota overage | ~$50-100 extra | No extra cost |
3. Vendor Lock-in
Supabase: While PostgreSQL is standard, Supabase's Realtime, Auth, and Storage APIs are proprietary. Migrating away requires rewriting significant portions of your application.
Cosmictron: Single binary that you can run anywhere. If you want to migrate, export your data as SQL and move to any PostgreSQL-compatible database. Your business logic is in reducers that can be ported.
4. Real-time Model
Supabase Realtime: Listens to PostgreSQL's Write-Ahead Log (WAL). Good for simple table changes, but struggles with:
- Complex filtered subscriptions (can hit btree index limits)
- Joins across multiple tables
- Aggregations (requires polling)
Cosmictron: DBSP incremental subscriptions support any SQL query:
- Multi-table joins with automatic delta computation
- Real-time aggregations (SUM, COUNT, AVG)
- Nested subqueries
5. Security
Both offer Row Level Security, but with different approaches:
- Supabase RLS: PostgreSQL RLS policies using PL/pgSQL
- Cosmictron RLS: Declarative SQL predicates on table definitions
Cosmictron's approach is simpler for common patterns like "user can only see their own data." Supabase's approach is more flexible for complex enterprise rules.
When to Choose Cosmictron
- You need sub-millisecond response times
- You want predictable costs without usage anxiety
- You need complex real-time queries (joins, aggregations)
- You prefer self-hosting for data sovereignty
- You want to minimize infrastructure (single binary)
When to Choose Supabase
- You need the full PostgreSQL ecosystem (extensions, PostGIS, etc.)
- You want a fully managed service with zero ops
- Your real-time needs are simple (single-table changes)
- You need mature Auth with social providers out-of-the-box
- Your team is familiar with PostgreSQL and SQL
Migration Path
Migrating from Supabase to Cosmictron is straightforward since both use SQL:
- Export your PostgreSQL schema with
pg_dump --schema-only - Convert tables to Cosmictron's Rust/TypeScript table definitions
- Move Supabase Edge Functions to reducers
- Replace supabase-js client with Cosmictron client SDK
- Migrate RLS policies to Cosmictron's declarative format