Skip to main content

The Inbox/Outbox Pattern Explained

At its core, the Inbox/Outbox pattern is a way to handle distribution at scale.
It shows up in email, messaging apps, and social feeds — anywhere one producer needs to deliver content to many consumers.


1. Conceptual Base

  • Outbox: the set of things I created or sent.
  • Inbox: the set of things I should see or receive.

That’s it. Everything else is implementation detail.


2. Why It Exists

Naively, you might build a news feed by scanning all your friends’ outboxes every time you open the app.
But if one friend has millions of followers, that quickly becomes impossible.

So systems keep inboxes: precomputed lists of pointers to content that belongs in your feed.
The question becomes: do you pay the cost when writing the post (push into every inbox), or when reading the feed (pull from outboxes on demand)?


3. How It Works

  • Outbox:

    • Canonical log of what a producer creates (e.g. posts, messages, events).
  • Inbox:

    • Pre-populated list of pointers to relevant outbox items.
    • Usually just IDs or metadata, not full content, for storage efficiency.
  • When you open your feed:

    • The system fetches from your inbox (fast).
    • If you scroll further, it may query outboxes to backfill more items.

4. Tradeoffs

  • Fan-out on Write (inboxes prefilled):

    • Write-heavy: one post → millions of inbox inserts.
    • Reads are cheap: just fetch inbox.
  • Fan-out on Read (outboxes only):

    • Writes are cheap: post once.
    • Reads are expensive: must union many outboxes.

👉 In practice, most systems use hybrids. Normal users’ posts may be fanned out into inboxes. Celebrities’ posts may stay only in their outbox and be fetched on demand.


5. Real-World Examples

  • Email:

    • Your outbox = what you send.
    • Your inbox = what you receive.
  • Social feeds (Facebook, Twitter/X):

    • Your outbox = posts you’ve made.
    • Your inbox = your feed, pre-populated with pointers to posts you should see.
  • Messaging apps:

    • Sending a DM writes to your outbox.
    • The recipient sees it in their inbox.

6. Gotchas

  • Deduplication: avoid double-inserts when posts overlap queries.
  • Deletes/Edits: propagate changes from outbox to all affected inboxes.
  • Backfill/Pagination: infinite scroll means inboxes often just hold a window of “most recent” items.
  • Celebrity amplification: massive fan-outs require special handling (hybrid strategies, caches, sometimes salted hashing at the storage layer).

7. Takeaway

The Inbox/Outbox pattern is just another form of logical separation:

  • Outbox = producer’s perspective (what I created).
  • Inbox = consumer’s perspective (what I should see).

The design choice isn’t about jargon — it’s about where you pay the cost: at write time or at read time.


📎 Related reading: Why Celebrities Are Necessary