Database Comparison: SQLite vs. PostgreSQL vs. MongoDB ā
Alright, picking a database for QuickLinker-ZeroRPM was a big damn dealāI needed something that could handle 100,000 requests a minute, cost me nothing, and not fall apart under pressure. I messed around with SQLite, PostgreSQL, and MongoDB, and hereās the straight dope on why SQLiteās my champ, PostgreSQLās a solid starter, and MongoDBās out of the running. Letās break it down.
SQLite: The Scrappy Winner ā
This little beast is why Iām hitting my goalsācheap, fast, and tough when paired with Redis.
- Cost: $0. Itās just a fileāno server, no fees. Lives on Oracleās free tier (4 cores, 24 GB RAM) without blinking.
- Speed: Tuned it upāWAL mode, sync tweaksāand itās cranking 80,000 inserts a second (SQLite tuning). At 100,000 RPM (1,666 req/s), with 1% writes (16.7/s) and 99% reads (1,650/s), Redis grabs 99% of reads. SQLiteās left with ~33 ops/sāpocket change.
- Fit: Low writes, high reads? Thatās URL shortening in a nutshellābit.lyās 230 writes/min at 23,000 RPM proves it (Bitly stats). SQLite eats that up.
- Upside: LiteFS in Phase 3 adds HA for freeākeeps it bulletproof (LiteFS GitHub).
I love it ācause itās lean and meanākeeps my $0 dream alive and scales with some grit.
PostgreSQL: The Reliable Rookie ā
I kicked off Phase 1 with PostgreSQLāitās got chops, but itās not the endgame.
- Cost: $0 on the free VM for 100 req/s, but scaling to 100,000 RPM? Read replicas kick in at $10-20 a monthālike AWS RDS territory.
- Speed: Handles 100 req/s no sweatāACID-compliant, solid for my
short_code ā original_url
setup. But 1,666 req/s needs more juiceāconnection pooling and replicas eat CPU and RAM. - Fit: Great for Phase 1ās small scaleāconsistent, simple, no duplicates. Switching to SQLite later was easy since they speak the same SQL lingo.
- Downside: Itās a server hog. More RAM, more overheadāfine ātil I hit big traffic, then itās cash or bust.
Itās my trusty starter, but itās too thirsty for the long haul.
MongoDB: The Fancy Flop ā
MongoDB sounded coolābig name, big promisesābut itās a mismatch for my gig.
- Cost: $0 on one VM, but thatās sketchy for production. Real HA needs a 3-node clusterā$15-30 a month, like MongoDB Atlas at $5 a node. No way Iām paying that.
- Speed: Loves reads, sureāscales like crazy there. But Redis already owns 99% of my reads (1,633/s). Mongoās stuck with writes, and its eventual consistency could screw meātwo threads grabbing the same
short_code
? Disaster. - Fit: Overkill for
short_code ā original_url
. Its document flex is wasted here, and moving to SQLite later wouldāve been a nightmareāno SQL overlap. - Downside: Too fatā3 nodes need 3-6 GB RAM and heavy I/O. My free VM chokes on that.
Mongoās a beast, but not my beastāRedis steals its thunder, and the price tagās a dealbreaker.
Head-to-Head: Whoās Got What ā
Database | Cost (100,000 RPM) | Speed Fit | Resource Load | HA at $0? |
---|---|---|---|---|
SQLite | $0 (LiteFS) | 80,000 ops/s | Light as hell | Yup |
PostgreSQL | $10-20/month | Good ātil 100 req/s | Chunky server | Nope |
MongoDB | $15-30/month | Read-heavy king | Fat and greedy | Nope |
Takeaway: SQLiteās the only one that hits 100,000 RPM at $0āfast, light, and future-proof with LiteFS.
Why SQLite Wins ā
- Cash Rules: $0 from day one to 100,000 RPM. PostgreSQL and MongoDB tap out when I scale.
- Workload Match: Low writes (16.7/s), high reads (1,650/s)āRedis and SQLite split it perfect. Mongoās read edge is moot, and PostgreSQLās too bulky.
- Flex: LiteFS makes SQLite HA-ready; the others need paid crutches.
I started with PostgreSQL ācause itās safe and simpleāgot me to 100 req/s no fuss. But SQLiteās where I landedāsame SQL vibe, way cheaper, and with Redis, itās untouchable. MongoDB? Cool for someone elseās wallet.
What I Learned ā
- SQLiteās Sneaky Good: Thought it was small-time, but itās a tank with the right setup.
- Cost Kills: PostgreSQL and MongoDB are dope ātil the bill hitsā$0ās my line in the sand.
- Teamwork Wins: SQLite + Redis + LiteFS = my dream squad.
Whatās Next? ā
- Phase 1: Where PostgreSQL hands off to SQLite.
- SQLite + LiteFS: Deep dive on the duo.
- References: The dirt I dug up.
Last Updated: March 11, 2025