HeadlinesBriefing favicon HeadlinesBriefing.com

Nextdoor’s Scaling Story: From PostgreSQL to a Distributed System

ByteByteGo •
×

Nextdoor, the hyper‑local social network, grew from a single PostgreSQL instance to a distributed stack as user volume hit five thousand concurrent workers. The process‑per‑connection model forced the database to spawn thousands of processes, draining CPU and memory. To break this bottleneck, the team introduced PgBouncer, a connection pooler that shares a few hundred warm connections among all workers today.

As reads outpaced writes, a single node struggled with contention. The solution was a Primary‑Replica architecture: a master accepts all writes while read replicas serve the bulk of traffic. Asynchronous replication introduced lag, so Nextdoor deployed Time‑Based Dynamic Routing, directing a user’s reads to the primary for a few seconds after a write to maintain consistency for users today always.

To shave milliseconds from every page load, Nextdoor layered a Valkey cache using a look‑aside pattern. A cache hit returns data instantly; a miss falls back to PostgreSQL. This hybrid approach lets millions of neighbors see fresh content without overloading the database, keeping the platform responsive while scaling to thousands of neighborhoods worldwide across global communities today always and efficiently.