Why you shouldn't do application-level sharding
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.
Topics Distributed systems
Scaling a system to more traffic or data, and what broke.
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.
Before launching Claude Docs, a two-week "chaos loop" had Claude Code drive a production-mirroring staging cluster at over a million synthetic docs a day, inject failures (mass reconnects, killed servers, stalled databases, hot docs), read Datadog telemetry, and ship fixes, with a human approving only hard-to-undo changes like schema or storage layout.
Datadog's metrics aggregation service, which merges DDSketch distributions to reduce tag dimensions, went through three generations as volume grew roughly 10× each time.
DBOS Transact adds workflow rewind to any step, which discards checkpoints from that step onward and re-executes while preserving the workflow ID.
Sharding Postgres with PgDog let DBOS durable workflow throughput scale linearly from 20K workflows/sec on one db.m7i.4xlarge RDS instance to 1M workflows/sec across 50 shards.
OpenAI's Habitat storage platform went from one shared Azure Cosmos DB container, to per-use-case dedicated containers, and back to a shared multi-tenant container.
GitHub has moved nearly all Git repositories to replicas split between its own data centers and Azure.
Managed ClickStack adds z-score anomaly detection to query-builder charts, computing the expected value from a 7-bucket one-minute moving average and the standard deviation over a longer baseline (two hours by default).
Anthropic replaced git with Scion, an in-house centralized version control system, after its monorepo grew past what git mirrors could serve.
LinkedIn's observability team consolidated a legacy metric metadata system (a custom in-memory search index, a custom KV store and Elasticsearch behind one gateway) onto a single-shard ClickHouse index.
Docker containers on Railway can be deployed either by having Railway build from a Dockerfile (via BuildKit with cache mounts, configurable with RAILWAY_DOCKERFILE_PATH) or by pulling a pre-built image from a registry such as Docker Hub, GHCR or ECR Public.
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.
Habitat, OpenAI's online storage platform, grew from a client-side Python library over Azure Cosmos DB into a centralized Python service handling 70M+ requests per second and 500+ PB across about 40 regions.
ZGateway is a stateless regional proxy tier in front of ZippyDB, Meta's most widely used key-value store.
Shopify consolidated metrics, logs, traces, exceptions and profiles from multiple vendors onto Observe, an internal observability platform built on self-hosted ClickHouse, and saw a 16x query improvement out of the box (over 30x at peak) along with predictable costs.
Datadog replaced CI fetches from a replicated Gitaly/Praefect cluster with gitretriever, a fleet of independent Git mirrors that poll GitHub per changed ref and fan packfiles out to autoscaled relays over a gRPC signaling stream plus HTTP.
PgDog avoids RDS Proxy's connection pinning, which silently disables transaction pooling when apps use SET, temporary tables, advisory locks, or queries over 16 KB, and can exhaust Postgres connections.
Mercado Libre moved the storage layer of its OpenTelemetry-based tracing platform, O11y events, to ClickHouse Cloud.
Canva moved its gateway session-revocation cache from per-pod MySQL loads to sorted binary chunks in S3, eliminating the database stampede when hundreds of gateway pods started during deploys.
incident.io moved nearly all Postgres read traffic to a read replica and had to preserve read-after-write consistency without hand-routing each query.
Modal rebuilt its sandbox control plane to run 1 million concurrent sandboxes, creating all of them in under a minute, by removing central coordination and durable stores from the creation path.
Because PgBouncer is single-threaded, ClickHouse Managed Postgres runs a fleet of PgBouncer processes sized to the core count, all binding one port via so_reuseport so the kernel load-balances connections behind a single endpoint.
LogHouse, ClickHouse Cloud's internal logging platform, has grown to 431 PiB uncompressed (27 PiB on disk) and 1.59 quadrillion rows across 36 cells in 33 geoshards on three clouds, ingesting up to 80 GiB/s and 190M rows/s.
The D. E. Shaw group moved per-task resource metrics from its HPC grid, millions of high-cardinality time series keyed by unique task IDs, from an InfluxDB-protocol time-series platform to ClickHouse.