Design a Content Aggregator and Disposable Inbox Service
System DesignModel answerLast updated
Design two systems: a multi-publisher article feed with ranking and client-adaptive APIs, and a temporary email service that generates human-looking addresses with guaranteed uniqueness at scale.
Design a Content Aggregator and Disposable Inbox Service
You have 45–50 minutes. Split your time roughly in half. The interviewer cares more about your reasoning and trade-offs than an exhaustive diagram.
Part 1: Multi-Publisher Article Feed
Build a backend that continuously pulls articles from thousands of independent publishers, consolidates and ranks them, and exposes feeds to a variety of client types.
Your design should cover:
- How articles flow from publishers into your system (polling, webhooks, push)
- How you detect and collapse duplicate or near-duplicate stories (for example, the same wire report picked up by hundreds of outlets)
- How you rank and precompute feeds at scale
- API design: when would you choose REST over RPC for different parts of the system? Justify your choice.
- Pagination: what strategy keeps the feed stable as new articles arrive? Why does a common alternative break?
- Caching: identify the layers where caching helps most, and explain what gets cached at each layer
- Client diversity: how does your API surface accommodate a low-bandwidth mobile client differently from a desktop web client?
Assume roughly 5 million new articles per day across 50,000 publishers, and 500 million feed loads per day across 50 million daily active users.
Part 2: Disposable Email Service
Design a platform that lets users instantly create a throwaway inbox, receive email at that address, and read messages through an API. Addresses expire but are never reused — even after expiry.
Two requirements make this non-trivial:
-
Human-looking usernames. Generated addresses must resemble real email addresses (e.g.,
james.rivera92@…) rather than obvious random strings (e.g.,xk7q2mnt@…), because many websites reject addresses that look machine-generated. -
Uniqueness at scale. The system creates tens of millions of new addresses per day. Explain how you would generate addresses efficiently without ever issuing a duplicate. If you consider a probabilistic data structure like a Bloom filter for the uniqueness check, discuss its trade-offs honestly.
Your design should also cover: how inbound SMTP mail is received and stored, how a user reads their inbox securely, and how domain rotation factors into plausibility.
Hints
Hint 1
For the feed, think about who owns a story at write time vs. read time. Because articles come from publishers rather than people a user follows, fan-out-on-write (the Twitter model) is a poor fit — precomputed per-topic candidate pools are more natural here.
Hint 2
Cursor-based pagination encodes a stable position in the ranked list, while offset-based pagination shifts when new items are inserted at the top. Ask yourself: if a breaking story jumps to position 1 while a user is on page 2, what happens to each approach?
Hint 3
For address uniqueness, there is a spectrum from 'try and retry on collision' to 'guaranteed unique by construction with zero lookups.' Think about a bijective mapping from a counter to a human-readable name — a permutation over the name space. A Feistel network or format-preserving encryption can do this.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
Approach
This is two independent design problems back to back. The feed question is really about API judgment; don't spend the session drawing ingestion pipelines. The disposable email question has one genuinely hard sub-problem — uniqueness at scale — and the interviewer will probe it directly.
Part 1: Multi-Publisher Article Feed
Scale anchors
- 5M articles/day ≈ 60 writes/s, spiking to ~1,000/s during breaking news
- 500M feed loads/day ≈ 6,000 reads/s average, ~20,000 at peak
- Read:write ratio ≈ 100:1, so the architecture should be read-optimized
Ingestion and deduplication
Publishers are onboarded with one of three mechanisms: RSS/Atom polling (legacy publishers), inbound webhooks (preferred), or a push API. All three write raw articles onto a message queue (Kafka works well here, partitioned by publisher) so the rest of the pipeline is decoupled from ingestion burst patterns.
Deduplication has two tiers:
- Exact duplicates: normalize the URL (strip tracking parameters, follow redirects) and hash the canonical URL. One lookup catches republished links.
- Near-duplicates: compute a SimHash or MinHash over the title and first few paragraphs. Stories within a similarity threshold are clustered into a single story entity that retains references to all source articles. This handles wire stories picked up by hundreds of outlets without flooding the feed with repetitions.
Ranking
Use a pull model (precomputed candidate pools, personalized at read time). Fan-out-on-write makes sense for social graphs but not for publisher content — there is no per-follower fan-out to do.
Every 30–60 seconds a ranking job scores all recently ingested articles by freshness, source reputation, and engagement velocity (click-through rate on similar stories in the past hour) and writes the top ~500 candidates per topic/region into Redis. At read time, a thin personalization layer re-ranks those candidates against the requesting user's interest profile. This keeps read latency low while still personalizing.
API design: REST vs. RPC
| Layer | Protocol | Reason |
|---|---|---|
| Public client API | REST/JSON over HTTPS | GET responses are CDN-cacheable; universal tooling; easy to debug |
| Internal service mesh | gRPC | Typed protobuf contracts, HTTP/2 multiplexing, low latency; streaming works well for ranking pipeline |
| Mobile (optional) | gRPC-Web | Smaller payloads, but you lose HTTP-layer caching — usually not worth it unless bandwidth is severely constrained |
The common mistake is using gRPC all the way to the client by default. The cacheability of plain GET requests is worth more than the payload savings in most cases.
Pagination
Use cursor-based pagination, never offset.
Offset pagination breaks under insertion: if 10 new articles arrive at the top while a user is paging, every subsequent offset shifts by 10 and the user sees duplicates or misses items. Cursor tokens encode a stable position — for example (snapshot_id, score, article_id) — signed and opaque to the client. Paging always continues from a fixed ranked snapshot. A separate ?since=<timestamp> endpoint handles pull-to-refresh, returning a count of new stories since the client's last load.
Caching layers
- CDN: non-personalized topic and regional feeds.
Cache-Control: max-age=30, stale-while-revalidate=60absorbs the vast majority of traffic, especially during news spikes. - Redis: ranked candidate pools (TTL ~60s) and each user's first-page result (short TTL, ~5s).
- HTTP conditional requests:
ETag/If-None-Matchso an unchanged feed returns 304 with no body — saves mobile bandwidth and server throughput. - Client-side: persist the last feed locally for instant launch and offline reading.
Adapting to client capabilities
Use a Backend-for-Frontend (BFF) per client family, or GraphQL with field selection. Mobile clients request compact card objects (title, thumbnail_url, source, published_at); web clients request richer payloads including summary text and related articles. Image variants are resolved at the CDN based on device pixel ratio and Accept headers (WebP/AVIF where supported). Maintain a versioned API path (/v2/) so older app versions continue to work during rollouts.
Part 2: Disposable Email Service
Core flow
A user hits POST /inboxes. The service returns an {address, access_token} pair. Inbox reads require the token — the address alone must not grant access, because an attacker who guesses or observes an address could otherwise intercept verification codes.
Inbound SMTP is handled by edge mail servers (Haraka, Postfix with a custom policy daemon) with MX records pointed at them. At RCPT TO, the server does a fast existence check and rejects unknown addresses immediately at the SMTP layer — this is important because it blocks the majority of inbound spam without accepting and storing it. Raw MIME is written to blob storage; parsed metadata (from, subject, received timestamp) goes to a wide-column store keyed by inbox_id with a TTL (e.g., 24h). New messages are pushed to the client over Server-Sent Events or WebSocket, with polling as fallback.
Generating human-looking usernames
Build a template engine over weighted name lists (census first names, common surnames):
- Templates:
first.last,firstlast,f.last,first_last,first.last{YY},firstl{YY} - Sample names proportionally to real-world frequency so the output distribution resembles genuine inboxes
- Post-filter: reject profanity, celebrity names, and role words (
admin,info,support)
Capacity check: 5,000 first names × 50,000 last names × 10 templates × 100 two-digit suffixes ≈ 2.5 × 10¹¹ combinations per domain. At 50M new addresses per day, a single domain lasts thousands of years. In practice you'll rotate across many domains for plausibility anyway.
Guaranteeing uniqueness
Option A — optimistic insert with retry. Generate a name, attempt INSERT IF NOT EXISTS, retry on collision. This is correct and simple. At low utilization the collision rate is negligible; at 10% saturation the expected retries per creation is ~1.1. The weakness: requires a strongly consistent lookup on every creation.
Option B — bijective counter mapping (no lookup needed). This is the stronger answer:
- Treat the name space as integers
[0, N)where N is the total number of valid combinations. - Each generator node leases a block of counter values (e.g., 100,000 at a time) from a central coordinator. Within a block it increments locally with no coordination.
- Map each counter value through a keyed format-preserving permutation over
[0, N)— a Feistel network with cycle-walking works well. This scrambles sequential counter values into an unpredictable order. - Decode the permuted index via mixed-radix decomposition into
(template, first_name, last_name, suffix).
Because a permutation is a bijection, distinct counter values always produce distinct names. Uniqueness is guaranteed by construction — no lookup, no retry. Leased counter blocks mean coordination overhead is one RPC per 100,000 addresses.
Why not a Bloom filter? A Bloom filter can answer "probably not seen before" quickly and with low memory (~10 bits per element at 1% false-positive rate). At 18B addresses per year that's ~22 GB — feasible. But false positives mean valid unused names are incorrectly rejected and wasted, and there is no way to remove entries. More importantly, a Bloom filter doesn't prevent duplicates; it only reduces the probability of the uniqueness check letting a duplicate through. For a hard "never reuse" requirement, you need either the authoritative store (Option A) or the bijective approach (Option B). The Bloom filter is at best a pre-filter that reduces load on the authoritative store, not a replacement for it.
Common mistakes to avoid
- Treating the address as the access credential — anyone who intercepts it can read the inbox
- Using offset-based pagination for the article feed
- Claiming a Bloom filter guarantees uniqueness — it doesn't; false negatives are possible and false positives waste address space
- Forgetting that domain reputation matters for plausibility, not just the local part of the address