NoSQL, cache & search Representative engagement

A replica set that outgrew one machine, split into a sharded cluster with a controlled balancer

MongoDB — sharded cluster

Client
IoT platform · North America
Region
Single region, three zones
Scale
3.1TB time-series documents · 45,000 writes per second
Timeline
9 weeks
Service line
Database clusters

Where they started

A three-member replica set was near the write ceiling of its primary. Vertical scaling had reached the top of the available instance size and IOPS were saturating.

The problem, precisely

Sharding introduces a new failure mode: the balancer. Uncontrolled chunk migration will saturate the same IOPS you were trying to relieve.

What we did

Chose a shard key against the actual query patterns before creating any shards, then enabled balancing with a window and a migration rate limit.

Delivered

  • Shard key selection analysis against production query patterns, with the alternative rejected and why
  • Sharded cluster with config server replica set and multiple mongos routers behind a VIP
  • Balancer window set outside peak hours, with a migration rate ceiling
  • Consistent backup with snapshot verification and a tested restore procedure
  • Runbook for adding a shard without unbalancing the hot collection

Technologies used

  • MongoDB 8.0
  • mongos routers + config server replica set
  • Zoned sharding + hashed keys where needed
  • MongoDB Ops Manager / Cloud Manager for backup
  • Prometheus + mongodb_exporter

Measured result

Every number below was measured and reported to the customer. Where we do not have a measured figure, the entry is a fact rather than a percentage — we would rather be precise than impressive.

  • 45k writes per second sustained after migration
  • 0 user-visible slowness during chunk migration
  • 1 shard key chosen against real query patterns, not defaults
  • < 30 min measured restore of a sharded snapshot to scratch
The reusable part

Pick the shard key from the query log, not from the schema diagram. A sharded cluster with the wrong key is slower than the single node it replaced.

Something here look familiar?

Most of these started with a cluster audit: two weeks, fixed price, and a risk map that names the single points of failure before you commit to any work. Keep the report either way.