Shikhil Saxena

Mar 26, 2025 • 2 min read

From Monoliths to Scalable Shards: Lessons from Notion's Database Revolution

How Notion leveraged database sharding to scale PostgreSQL and meet the demands of exponential growth

As digital platforms scale, maintaining seamless user experiences becomes a growing challenge. Notion—a workspace tool beloved by millions—faced such a challenge when their monolithic PostgreSQL database hit its performance ceiling. The solution? A thoughtful and well-engineered sharding strategy that set a benchmark for database scaling.

The Problem: When Growth Pushes Boundaries

Notion's database had evolved into a bottleneck as the platform scaled to millions of users and billions of "blocks" (the modular pieces of content within Notion). A traditional monolithic database architecture could no longer handle the load efficiently. To sustain their rapid growth, Notion needed to divide and conquer: they embraced database sharding.

The Solution: Smart Database Sharding

Sharding involves splitting a large database into smaller, manageable pieces, called "shards," each hosting a subset of the data. Here's how Notion approached it:

  1. Strategic Shard Key Selection: The Notion team carefully selected Workspace ID as the sharding key, enabling related data to stay grouped while minimizing cross-shard queries.

  2. Scalable Architecture Design: The database was divided into 480 logical shards distributed across 32 physical databases. This setup ensured scalability, providing flexibility to handle even greater future demands.

  3. Seamless Migration Execution: Transitioning from monolith to shards was no small feat. The team employed techniques like:

    • Double writes to both the old and new databases.

    • Dark reads to validate the new setup without impacting users.

    • Verification scripts to ensure data integrity.

By taking these meticulous steps, Notion executed the migration with minimal downtime, keeping users unaware of the complex backend transformation.

Key Lessons for the Tech Community

  1. Plan Proactively: Scaling issues often emerge before they become critical. Addressing them early, as Notion did, avoids rushed and chaotic migrations.

  2. Prioritize User Experience: Every technical decision revolved around ensuring users wouldn't feel the impact of the migration—a guiding principle that every tech team can learn from.

  3. Think Long-Term: Designing for scalability today prevents repetitive overhauls tomorrow. Notion's architectural foresight now supports future expansion effortlessly.

The Takeaway

Notion's journey to sharding excellence showcases how thoughtful planning, strategic design, and meticulous execution can transform performance bottlenecks into opportunities for growth.

For engineers, architects, or anyone passionate about distributed systems, Notion’s case study serves as an inspiring example of solving modern scaling challenges with ingenuity and precision.

Join Shikhil on Peerlist!

Join amazing folks like Shikhil and thousands of other people in tech.

Create Profile

Join with Shikhil’s personal invite link.

0

2

0