Design Facebook Messenger

Hard60 min
1 / 30
understanding3 min read

Messenger at Meta scale

What Messenger is and why per-thread ordering at scale defines it

Messenger at Meta scale

We are designing Facebook Messenger: real-time one-to-one and group chat for billions of users, integrated with the Meta social graph. The fact that defines the architecture is per-thread ordering at planet scale. Within a single conversation, every participant must see messages in the same order, but there is no requirement to order messages across different conversations, so the system is a sea of independent, totally-ordered threads rather than one global log. This is what makes Messenger shardable: each conversation is its own small ordered world.

Unlike a privacy-first messenger, Messenger is server-readable by default (the server stores and can process message content for search, integrations, and rich features), with secret conversations as an opt-in end-to-end-encrypted mode. The spine is therefore: a send path that assigns each message a per-thread sequence idempotently, a fan-out that delivers to connected devices over WebSocket and pushes to offline ones, an inbox-sync path that catches a reconnecting device up via cursors, and presence and receipts on top. State the framing up front, because per-thread ordering, idempotent send, and sync are the load-bearing ideas everything else hangs on.

Key Highlights

  • Per-thread total order, no cross-thread order: a sea of independent ordered threads
  • This is what makes Messenger shardable (each conversation its own ordered world)
  • Server-readable by default; secret conversations are opt-in end-to-end-encrypted
  • Spine: idempotent send, fan-out + push, inbox sync, presence and receipts
Interview move
Open by naming per-thread ordering with no cross-thread order. That single property is what makes Messenger shard cleanly by conversation.
Avoid
Trying to globally order all messages. Global order is unnecessary for users and impossible at scale; order within a thread is sufficient and achievable.

Section Rescue Kit

Buzzwords to use:

Per-thread orderingServer-readable

Safe statements:

  • "Messenger is a sea of independent, per-thread totally-ordered conversations."
  • "The spine is idempotent send, fan-out plus push, and inbox sync."
Design Facebook Messenger - System Design | WinJob | WinJob