Skip to content

Design Discord's Message Storage, stage 4 of 9: break it

The channel that froze the cluster

Here is what the message service and the store logged when one member opened the channel. Find the lines that explain the stall.

System so far· 5 parts
12345CLIENTMembersSERVICEAPI serversSERVICEGatewaySERVICEMessagedata serviceDATABASEMessage cluster

Select a component to see what it is responsible for and which state it owns.

  1. 1Members → API servers: Send, load history, jump
  2. 2API servers → Gateway: New message event
  3. 3Gateway → Members: Push to online members
  4. 4API servers → Message data service: Query by channel (hash-routed)
  5. 5Message data service → Message cluster: Read and write one partition
  • Request / response
  • Asynchronous
  • Server push

What you need to know

0 of 2 checks done
  1. In an LSM store, a delete is a write: a tombstone marking the row as deleted. Older copies of the row may sit in files that haven't been compacted yet, so the tombstone must be kept, and read past, until compaction removes both.

    Tombstones are kept for a grace period (gc_grace_seconds) so replicas that missed the delete can learn of it through repair.

  2. Think first

    A channel had 2 million messages; a bot deleted all but one. A read asks for the latest 50 messages. How much work is it?