Catalogue / notion-2023-postgres-reshard

Notion triples its Postgres space shards from 32 to 96 and shards PgBouncer with zero downtime

Notion, 2023. Postgres space shards and PgBouncer layer.

Organisation
Notion
Evidence
Reported from production
Source
The Great Re-shard: adding Postgres capacity (again) with zero downtime

Notion, published 2023-07-17

Records

Decision#d1

Horizontally reshard Postgres space shards from 32 to 96 smaller instances instead of scaling vertically

Decision#d2

Replicate logical schemas to new shards with Postgres logical replication and deferred index builds

Decision#d3

Shard the PgBouncer cluster into four groups of 24 space shards before database cutover

Decision#d4

Verify with sampled bounded dark reads and cut over per shard via PgBouncer pause and reverse replication

Sign in to read what was chosen, what was rejected and what it cost, each with its place in the source. An account is free.