Why We Migrated 50,000 Active Users to SQLite
Ditching a managed cloud PostgreSQL instance saved us hundreds of dollars a month and dropped query latency from 35ms to under 1ms.
When software engineers discuss production databases, the default answer is almost always PostgreSQL or MySQL. The assumption is that SQLite is a toy: fine for local test fixtures or mobile phone address books, but unfit for serious web applications serving tens of thousands of concurrent users.
That assumption is ten years out of date.
Earlier this year, we migrated our user data store across three Ryla Labs applications from a managed AWS RDS PostgreSQL cluster over to embedded SQLite running in WAL mode.
The results stunned our entire team.
The Problem with Cloud Database Latency
When your application server sits in one data center and your managed PostgreSQL database sits in another availability zone, every query pays a network round-trip tax:
Standard Network Round Trip: 15ms - 40ms
SSL / TLS Handshake Overhead: 10ms - 25ms
Connection Pool Contention: 5ms - 15ms
Total Time Before Query Execution: 30ms - 80ms
Even if the database executes an indexed lookup in 0.2ms, your web server spends 98% of its time waiting for TCP packets to travel back and forth over fiber optic switches.
SQLite: The Power of In-Process Memory
With SQLite, the database engine is not a separate server process. It is a C library compiled directly into your application runtime:
- SQLite in-process function calls take under 0.05 milliseconds.
- Zero TCP connection overhead.
- Zero SSL serialization overhead.
When you query data in SQLite, you are essentially reading bytes directly from OS page cache in local RAM.
// Sample production SQLite configuration with WAL mode
import Database from 'better-sqlite3';
const db = new Database('/var/data/production.db');
// Enable Write-Ahead Logging for high concurrent read throughput
db.pragma('journal_mode = WAL');
db.pragma('synchronous = NORMAL');
db.pragma('foreign_keys = ON');
db.pragma('busy_timeout = 5000');
With Write-Ahead Logging (WAL), readers never block writers, and writers never block readers. A single SQLite instance on NVMe SSD storage can easily sustain 8,000 to 12,000 writes per second. For our 50,000 monthly users, it was the best engineering decision we made all year.
Written by Daniel Dano
danieldano.com ↗15-year-old software developer, founder of Ryla Labs (50,000+ monthly users across 12 countries), author of Built Young, and high school student leader.