---
title: "Why you shouldn't do application-level sharding"
description: "Application-level sharding of an OLTP database looks simple on day one (a `shard_for(user_id % N)` function) but accumulates serious engineering burdens as a system grows."
url: "https://swe.quest/articles/why-you-shouldn-t-do-application-level-sharding-4fe6249c12df9221"
canonical: "https://planetscale.com/blog/why-you-shouldnt-do-app-level-sharding"
source: "PlanetScale"
published: "2026-11-23"
difficulty: "medium"
kind: "Opinion"
reading_minutes: 21
tags: ["distributed-databases","scalability","consistency","schema-migrations","postgres"]
---

# Why you shouldn't do application-level sharding

A post on [PlanetScale](https://swe.quest/sources/planetscale.md), published 2026-11-23, 21 min read, Opinion. Original: [https://planetscale.com/blog/why-you-shouldnt-do-app-level-sharding](https://planetscale.com/blog/why-you-shouldnt-do-app-level-sharding)

## Summary

Application-level sharding of an OLTP database looks simple on day one (a \`shard\_for(user\_id % N)\` function) but accumulates serious engineering burdens as a system grows. Walking through a fast-growing marketplace on Postgres, the hazards are resharding with processes deploying at different times and losing writes, routing queries that lack the shard key (scatter-gather, colliding bigserial IDs, shard-encoded IDs à la Instagram, lookup tables that become single points of failure), hot shards from large tenants, cross-shard transactions requiring two-phase commit or sagas with outboxes and idempotency, and schema changes applied across every shard. Examples from Intercom, Etsy and Slack illustrate the costs, and the case is that this routing and coordination logic belongs in a database-level sharding layer rather than application code.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Distributed databases](https://swe.quest/tags/distributed-databases.md) (Data & databases)
- [Scaling](https://swe.quest/tags/scalability.md) (Distributed systems)
- [Consistency models](https://swe.quest/tags/consistency.md) (Distributed systems)
- [Schema migrations](https://swe.quest/tags/schema-migrations.md) (Data & databases)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)

## Prerequisites

- relational databases ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- database transactions ([easy posts on Databases](https://swe.quest/tags/databases.md?difficulty=easy))
- read replicas

## Keywords

PlanetScale, Postgres, two-phase commit, saga pattern, transactional outbox, consistent hashing, Instagram

## Related posts

- [Handling hot shards](https://swe.quest/articles/handling-hot-shards-713450434ac73606.md): PlanetScale · 2026-09-28 · Medium · 7 min read · Distributed databases, PostgreSQL, Scaling, Multi-tenancy
  When a shard key like tenant\_id stops matching reality because a few whale tenants dominate load or cross-tenant queries appear, Neki (PlanetScale's sharded Postgres from the Vitess maintainers) offers three escalating fixes: vertically scale the hot shard with its own configuration profile, isolate the whale by narrowing hashed key ranges in the declarative data topology, or reshard specific tables by a better key.
- [How Figma’s databases team lived to tell the scale](https://swe.quest/articles/how-figma-s-databases-team-lived-to-tell-the-scale-5117114294b188fe.md): Figma · 2024-03-14 · Medium · 19 min read · PostgreSQL, Distributed databases, Scaling, Query engines
  Figma horizontally sharded its RDS Postgres stack after vertical partitioning ran out of room.
- [Shard design doesn't start from your tables](https://swe.quest/articles/shard-design-doesn-t-start-from-your-tables-283c900085b220b2.md): PlanetScale · 2026-10-23 · Medium · 8 min read · Distributed databases, PostgreSQL, System design
  Neki's shard groups co-locate related Postgres tables by hashing a shared shard key (e.g. customer\_id via xxhash) into a 64-bit keyspace split across shards, so joins and transactions for one customer stay on a single shard with full Postgres semantics.
- [Horizontally scaling the Rails backend of Shop app with Vitess](https://swe.quest/articles/horizontally-scaling-the-rails-backend-of-shop-app-with-vitess-03c7b2da20f98ec3.md): Shopify Engineering · 2024-01-17 · Medium · 27 min read · MySQL, Distributed databases, Ruby, Scaling, Schema migrations
  Shop app outgrew a single MySQL database despite federating tables across databases, so the team moved its Rails backend to Vitess, sharding user-owned tables by user\_id into a "users" keyspace and keeping the rest in an unsharded "global" keyspace.
- [The architecture of Neki](https://swe.quest/articles/the-architecture-of-neki-b0a20bdb70a4c3cd.md): PlanetScale · 2026-09-18 · Medium · 9 min read · PostgreSQL, Distributed databases, Replication, System design, Kubernetes
  Neki shards unmodified PostgreSQL behind a single connection string.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
