Best Database for
Realtime Applications
From chat apps to live dashboards: choose the right database for sub-second updates, millions of connections, and seamless sync.
RECOMMENDATIONS BY USE CASE
Sub-100ms latency, presence, typing indicators
Built-in presence, offline sync, optimistic updates
High-frequency updates, aggregations
Redis for speed, Postgres for persistence & queries
State sync, conflict resolution, low latency
Firebase for casual, Redis for competitive
CRDT/OT support, fine-grained sync
Need specialized conflict resolution algorithms
High write throughput, time-series
Designed for millions of writes/second
Fan-out, read optimization
Redis for feed cache, Postgres for persistence
Key insight: Discord uses PostgreSQL. Twitter uses Redis. Firebase powers The New York Times live updates. The "best" database is the one that matches your team's expertise and your specific latency requirements.
DATABASE COMPARISON
Scores based on realtime-specific capabilities, not general database features
PostgreSQL + LISTEN/NOTIFY
Rock-solid ACID with native pub/subSupabase Realtime
Postgres with batteries-included realtimeFirebase Realtime DB
Zero-config realtime, Google-scaleMongoDB Change Streams
Flexible documents with realtime cursorsRedis Pub/Sub + Streams
Blazing fast in-memory messagingScyllaDB CDC
Cassandra-compatible at extreme scaleDECISION FRAMEWORK
Answer these questions to find your ideal realtime database
Latency Requirements
Redis delivers sub-millisecond latency. Firebase/Supabase handle most realtime apps. PostgreSQL is fine for less time-sensitive use cases.
Data Model Needs
Your query patterns determine the database. If you need SQL and transactions, start with PostgreSQL. If schema flexibility matters, consider document stores.
Scale Expectations
Don't over-engineer. Most apps never exceed 10k concurrent users. Firebase and Supabase scale surprisingly well for their ease of use.
Team Background
Managed services (Firebase, Supabase) eliminate DevOps burden. Self-hosting gives control but requires expertise.
Vendor Lock-in Tolerance
Firebase has highest lock-in. PostgreSQL is portable. Supabase is open-source but managed. Choose based on exit strategy importance.
REAL-WORLD SUCCESS STORIES
How top companies build realtime features at scale
Alibaba
11.11 Shopping FestivalFirebase for realtime inventory updates
The New York Times
Live election resultsRealtime vote count updates
Lyft
Driver location trackingFirebase for passenger-driver sync
Peerlist
Professional networkRealtime notifications and feeds
Mobbin
Design reference platformCollaborative collections
Replicate
AI model marketplaceRealtime model status updates
Twitter/X
Timeline cachingRedis for sub-millisecond feed reads
GitHub
Job queues & cachingSidekiq (Redis) for background jobs
Stack Overflow
Caching layerRedis for question/answer caching
Discord
Message storagePostgreSQL + ScyllaDB hybrid
Heavily sharded PostgreSQL
Notion
Block storagePostgreSQL for all persistent data
RECOMMENDED TECH STACKS
Complete stacks for different scale requirements
Simple Realtime Stack
Launch in days, scale to 100k usersPostgres + built-in subscriptions, zero config
Supabase has official SDK support
Serverless, co-located with DB
Integrated RLS policies
Production Realtime Stack
Battle-tested for serious appsACID transactions, complex queries
Pub/sub, caching, session storage
Reliable connection management
Handle high concurrency efficiently
Reliable async processing
High-Scale Realtime Stack
Millions of concurrent connectionsHandles millions of writes/sec
Distributed pub/sub at scale
Reliable event ordering at scale
Maximum connections per node
Auto-scale WebSocket pods
ARCHITECTURE PATTERNS
Common approaches to building realtime systems
Direct Database Subscriptions
Client subscribes directly to database changes
- Simple to implement
- Low latency
- Automatic sync
- Limited query flexibility
- Vendor lock-in
- Cost at scale
Database + Message Broker
Database triggers push to message queue, server broadcasts
- Decoupled architecture
- Flexible processing
- Scalable
- More complex
- Additional infrastructure
- Potential latency
Event Sourcing
Store events, derive state, broadcast changes
- Complete audit trail
- Time-travel debugging
- Scalable reads
- Complex to implement
- Learning curve
- Storage overhead
CQRS + CDC
Separate read/write models, Change Data Capture
- Optimized for each path
- Scales independently
- Flexible
- Eventually consistent
- Complex
- More infrastructure
PERFORMANCE BENCHMARKS
Real-world latency and throughput comparisons
| Metric | PostgreSQL | Supabase | Firebase | Redis | ScyllaDB |
|---|---|---|---|---|---|
| Write Latency (p99) Redis fastest, Firebase includes network | 5-15ms | 10-30ms | 20-50ms | < 1ms | 1-5ms |
| Broadcast Latency Time to reach all subscribers | 50-100ms | 30-80ms | 20-50ms | < 5ms | 10-30ms |
| Max Connections/Node Firebase uses Google's edge network | ~500 | ~10k | ~200k | ~10k | ~10k |
| Writes/sec/Node ScyllaDB designed for write-heavy | ~10k | ~5k | ~100k | ~100k | ~1M |
| Cost at 10k MAU Firebase can spike with heavy reads | $20-50/mo | $25/mo | $25-100/mo | $15-30/mo | $100+/mo |
Reality check: These benchmarks assume optimal conditions. Real-world latency depends on network, geographic distribution, and your specific query patterns. Always test with your actual use case before committing.
COMMON MISTAKES TO AVOID
Learn from failed realtime implementations
Polling instead of pushing
Using setInterval to check for updates every N seconds
Broadcasting everything to everyone
Sending all changes to all connected clients
No connection state management
Assuming WebSocket connections never drop
Skipping optimistic updates
Waiting for server confirmation before UI update
Ignoring message ordering
Assuming messages arrive in the order sent
Realtime App with Supabase
npx create-stacksfinder@latest --seed SF1-eyJ2IjoxLCJ0Ijoid2ViLWFwcCIsInMiOiJzdGFydHVwIiwiaHAiOlsic3BlZWQiLCJkeCJdLCJlIjoiamF2YXNjcmlwdCIsInNlbCI6eyJmcmFtZXdvcmsiOiJuZXh0anMiLCJkYXRhYmFzZSI6InN1cGFiYXNlIiwiYXV0aCI6ImJldHRlci1hdXRoIn19 --ref guide-realtime-db FREQUENTLY ASKED QUESTIONS
Frequently Asked Questions
Build Your Complete Tech Stack
Get personalized database recommendations based on your app's requirements