← Pinterest Interview Insights
I started with the data model which felt like the right call but I spent way too long there.
Start by clarifying requirements (scale, latency, consistency) and then present a high-level architecture that separates real-time delivery (WebSocket/SSE) from persistent storage. Dive into data modeling for notifications, read/unread state, and badges, and discuss trade-offs around fan-out, idempotency, and degradation. Conclude with how you'd handle failures and ensure durability.
Pro tip: Emphasize idempotency and deduplication early, as they are critical for exactly-once semantics in notification systems and often overlooked. Also, mention using a hybrid approach: push for real-time and pull for history to balance latency and cost.
Ask questions to understand expected QPS, latency targets, consistency needs, and client types (mobile/web). Define what 'real-time' means (e.g., <1s) and the scale of fan-out (e.g., millions of users).
Propose a system with an ingestion service (API), a message queue (Kafka) for decoupling, a fan-out service, and a delivery layer (WebSocket/SSE for real-time, push notifications for offline). Include a persistent store (e.g., Cassandra) for history and state.
Design schemas for notifications (user_id, notification_id, type, payload, timestamp), read/unread state (separate table or flag), and badges (counters). Discuss using Redis for fast unread counts and caching.
Explain how to ensure idempotency (unique notification IDs, dedup cache), deduplication (hash of content+recipient), and efficient fan-out (write to recipient timelines or use pub/sub). Discuss trade-offs between fan-out on write vs. read.
Describe fallbacks: if real-time fails, fall back to polling; if queue backs up, shed load or prioritize. Ensure durability with replication and retries, and monitor with metrics (latency, error rates).
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.