๐Ÿ“ Scaling Writes While Designing Systems

Most engineers donโ€™t know how to scale writes, because writing everything to one single database instance may have worked for your small company but wonโ€™t cut it in a big-tech interview.

Here are the ๐Ÿฐ ๐˜€๐˜๐—ฟ๐—ฎ๐˜๐—ฒ๐—ด๐—ถ๐—ฒ๐˜€ one ๐—ป๐—ฒ๐—ฒ๐—ฑ ๐˜๐—ผ ๐—ธ๐—ป๐—ผ๐˜„ ๐˜๐—ผ ๐˜€๐—ฐ๐—ฎ๐—น๐—ฒ ๐˜„๐—ฟ๐—ถ๐˜๐—ฒ๐˜€ ๐—ถ๐—ป ๐—ฎ๐—ป ๐—ถ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„:

1๏ธโƒฃ ๐—ฉ๐—ฒ๐—ฟ๐˜๐—ถ๐—ฐ๐—ฎ๐—น ๐—ฆ๐—ฐ๐—ฎ๐—น๐—ถ๐—ป๐—ด & ๐——๐—ฎ๐˜๐—ฎ๐—ฏ๐—ฎ๐˜€๐—ฒ ๐—–๐—ต๐—ผ๐—ถ๐—ฐ๐—ฒ๐˜€

Youโ€™re probably underestimating modern hardware. Bigger machines โ€” 200 cores, 10Gb NICs, SSDs โ€” can push write limits further than most expect. Consider write-optimized databases like Cassandra, time-series stores, or column databases also improve throughput, though usually at the cost of slower reads.

2๏ธโƒฃ ๐—ฆ๐—ต๐—ฎ๐—ฟ๐—ฑ๐—ถ๐—ป๐—ด & ๐—ฃ๐—ฎ๐—ฟ๐˜๐—ถ๐˜๐—ถ๐—ผ๐—ป๐—ถ๐—ป๐—ด

Spread the load. Hashing on userId or postId spreads writes evenly across shards. Vertical partitioning separates โ€œpost contentโ€ from โ€œpost metrics,โ€ so counters update without blocking core content. In interviews, always explain your partition key choice as balanced distribution is key.

3๏ธโƒฃ ๐—ค๐˜‚๐—ฒ๐˜‚๐—ฒ๐˜€ & ๐—Ÿ๐—ผ๐—ฎ๐—ฑ ๐—ฆ๐—ต๐—ฒ๐—ฑ๐—ฑ๐—ถ๐—ป๐—ด

When you can afford it, queues like Kafka or SQS absorb bursts so databases process writes steadily, but they mask issues if overload is constant. Load shedding drops lower-value writes, such as redundant location updates, to preserve critical ones.

4๏ธโƒฃ ๐—•๐—ฎ๐˜๐—ฐ๐—ต๐—ถ๐—ป๐—ด & ๐—›๐—ถ๐—ฒ๐—ฟ๐—ฎ๐—ฟ๐—ฐ๐—ต๐—ถ๐—ฐ๐—ฎ๐—น ๐—”๐—ด๐—ด๐—ฟ๐—ฒ๐—ด๐—ฎ๐˜๐—ถ๐—ผ๐—ป

Things work better in chunks. Batching collapses many writes into fewer operations, like turning 100 likes into one counter update. Hierarchical aggregation reduces volume further by processing locally before sending upstream. Both approaches ensure no single component is overwhelmed.

๐Ÿ’ก ๐—œ๐—ป๐˜๐—ฒ๐—ฟ๐˜ƒ๐—ถ๐—ฒ๐˜„ ๐˜๐—ถ๐—ฝ: Donโ€™t just say โ€œshard the DB.โ€ Show the tradeoffs: โ€œFor posts, Iโ€™d shard by userId to spread writes evenly. For engagement metrics, Iโ€™d batch and aggregate to reduce DB pressure.โ€

๐Ÿ‘‰ ๐—ฅ๐˜‚๐—น๐—ฒ ๐—ผ๐—ณ ๐˜๐—ต๐˜‚๐—บ๐—ฏ:

  • Exhaust hardware + DB tuning first
  • Shard for steady load
  • Queue or shed for bursts
  • Batch & aggregate for extremes