Chat message sharding

DesignHard45 minSalesforce and Microsoft style

Your task

Design the sharding scheme for the message store of a large team-chat product: ~2B messages/day, 100M channels, reads are channel-scoped (load last N messages, paginate backward), and a small number of channels (a few thousand 'mega' channels) get 1000x the traffic of the median. Hot channels can spike 50x within minutes during live events. You must support online resharding without downtime and keep p99 channel-history reads under 80ms. Describe the partition key, the topology, how you handle hot channels, and how resharding works.

It covers

  • Consistent hashing
  • Resharding
  • Hot keys