ENGINEERING 459 upvotes 2021

Lessons learned from sharding Postgres at Notion

459 pts
Hacker News Signal
2021 · Shared by @craigkerstiens
Lessons learned from sharding Postgres at Notion by @craigkerstiens

Retrospective Overview & Key Insights

Distilled reflections, business mechanics, and tactical takeaways:

In this technical retrospective (2021), @craigkerstiens shares practical architectural lessons learned from running, scaling, or migrating production software under lean constraints.

Core Principles for Independent Builders:
1
Defaulting to simpler architectures (such as monolithic frameworks, SQLite, or managed VPS) prevents early engineering bankruptcy.
2
Evaluating true compute and egress costs reveals that high cloud bills can often be slashed by 80%+ through judicious re-platforming.
3
Code you write at 2 AM as a solo engineer must be easy to debug six months later without complex microservice dependencies.
Community Debate Themes:

HN engineers debated the tradeoffs between cloud convenience and raw server economics, database indexing strategies, and resisting premature architectural complexity.

Founder's Discussion Replies (@craigkerstiens)

Direct clarifications and follow-up comments shared by the author during the live discussion:

OP @craigkerstiens Original Author

Community Discussions & Critical Reviews

Key perspectives, counter-arguments, and peer founder insights debated on Hacker News (120 total discussions):

JO @jordanthoms Peer Contributor
SI @sillysaurusx Peer Contributor
MB @mbell Peer Contributor
FL @flowerlad Peer Contributor
CA @caffeinecrazy Peer Contributor

I'm curious about whether using Postgres native partitioning was considered? If so, I'd like to hear the rationale for not doing it.

It seems like you made the database sharding decision as a result of vacuum taking too long. Partitioning the problematic table (assuming you're storing "blocks" in 1 giant table) would have enabled per-partition vacuuming, which will avoid long running vacuum processes.

HISTORICAL ERA Pandemic Bubble (2020–2022)
COMMUNITY SCORE 459 points
TOTAL DISCUSSIONS 120 comments
TOPICS & TECH STACK:
More Retrospectives by @craigkerstiens