Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Neon 11 min read Deep dive mediumAdept

A Deep Dive into PolyScale’s Architecture

PolyScale is a wire-protocol proxy cache that sits between an application and its database (here, Neon serverless Postgres), routing connections to the nearest edge PoP and caching query results with TTLs it learns automatically from arrival rate, result change rate and related "query templates". Typically a cache hit happens by the 2nd or 3rd query. Invalidation works in three layers: row-level SQL parsing of writes with global invalidation messages to all PoPs, a table-level fallback for complex queries, and detection of unexplained result changes that disables caching for affected queries, giving eventual consistency without reading the WAL. A built-in performance test shows cached responses around 1ms versus 90–515ms direct to the origin.

Related posts

  • Lakebase Postgres is built on object storage, but 99.99999% of reads never touch it

    Neon mediumAdept

    Lakebase Postgres stores durable history in object storage but keeps it off the read path through tiered caching. Production fleet stats show the compute's local cache serving ~1.1B page accesses/sec (99.46%), pageserver NVMe ~6M/sec (0.54%), and object storage only ~39 requests/sec, about 1 in 28 million reads, mostly from long-dormant project wakeups or branches and restores at old LSNs. Pageservers answer GetPage@LSN by replaying delta layers on top of the nearest image layer. Creating image layers more eagerly keeps p90 under 1 delta and p99 around 6 per read.

  • Separation of storage and compute without a performance tradeoff

    Neon easyNovice

    Neon's Local File Cache (LFC) sits between Postgres shared buffers and Neon's remote multi-tenant page storage. It uses the Linux page cache for RAM-like latency and can spill to local NVMe, so Neon keeps elastic, decoupled storage while matching local-disk Postgres performance. On a TPCC-like sysbench benchmark at 8CU, a 500GB LFC raised QPS from 12,512 to 17,030 and cut p99 latency from 593ms to 384ms, close to a local-disk setup needing 929GB. Sizing the LFC to the estimated working set (180GB) lost only about 10% of peak QPS.

  • Cache made consistent

    Meta Engineering mediumAdept

    Meta raised TAO's cache consistency from six nines to ten nines (99.99999999% of cache writes consistent within five minutes) by treating consistency as a measurement and debugging problem rather than only a protocol problem. Polaris acts as a client that consumes invalidation events and checks cache replicas against client-observable invariants. It uses multi-timescale retry queues and defers expensive cache-bypass database reads, which avoids false positives without overloading the database. A stateful consistency-tracing library logs cache mutations only in the short window after a write, where fills and invalidations race. That gave engineers complete timelines for bugs such as a versioned entry that stayed stale indefinitely.

  • Everyone gets faster writes: We turned off FPW's in Neon

    Neon hardMaster

    Neon disabled Postgres full-page writes fleet-wide because its stateless compute streams WAL to a Paxos safekeeper quorum and has no local disk pages that can tear. To keep delta chains bounded without FPW images, the pageserver now generates page images itself once a page accumulates more deltas than a threshold, rather than relying on the checkpoint cycle. HammerDB TPROC-C throughput rose up to 4.5x on 32 vCPU, and WAL per transaction fell from 58KB to under 4KB (94%). In production, p99 read latency dropped 30-50%, and the change was rolled out without restarts via the XLOG_FPW_CHANGE WAL record.

  • Distributing Global State to Serve over 1 Billion Daily Requests

    Render mediumAdept

    Render's request routers evolved from per-instance in-memory caches with 5-minute TTLs and database lookups on miss, which overloaded PostgreSQL on every redeploy and failed during database downtime, to push-based caching using PostgreSQL LISTEN/NOTIFY so routers never query the database in the hot path. That change cut p99 routing time to under 4ms and propagated updates in under a second. Going multi-region exposed database connection limits and slow router startup, fixed by adding per-cluster shared cache instances that serve snapshots, record fetches and WebSocket update streams. Routers pin to a single cache to avoid inconsistent state, and startup in distant regions fell from over a minute to under twenty seconds.

The quest for software engineering knowledge.

Look:
Layout: