Design a social feed platform where sports bettors share their betting slips (teams, odds, stakes), follow other users, and interact through likes and comments. Think of it as a sports-focused social network where the core content object is a bet slip tied to live sporting events and outcomes. The feed blends posts from followed users with trending and live-event-related content.
The key engineering challenges are building a low-latency personalized feed that handles spiky traffic (major games drive sudden surges), delivering near-real-time updates for likes, comments, and new posts, managing hot-key contention when viral slips accumulate rapid engagement, and scaling the social graph and notification fanout. Your design must handle millions of active users during peak sports seasons, with individual events driving tens of thousands of concurrent interactions on popular slips.
Based on real interview experiences, these are the areas interviewers probe most deeply:
The home feed must blend content from multiple sources with low latency. Interviewers want to see how you balance precomputation with on-demand assembly and handle the fanout implications of popular accounts.
Hints to consider:
When a popular bettor's slip goes viral during a championship game, thousands of likes and comments hit a single entity simultaneously. Naive designs cause lock contention and throughput collapse.
Hints to consider:
Users expect to see new posts, likes, and comments appear without refreshing. Interviewers evaluate your push architecture for delivering updates efficiently.
Hints to consider:
Posts, likes, comments, and notifications flow through an event pipeline. Retries and duplicate events are inevitable in distributed systems, and interviewers want to see how you prevent corruption.
Hints to consider:
When a user with 100,000 followers posts a new slip, notifications must reach interested followers across push, in-app, and potentially email channels without overwhelming the system.
Hints to consider:
Ask about user scale, peak concurrent users during major events, and the ratio of content producers to consumers. Clarify whether the feed should show real-time bet outcomes (odds changes, win/loss status) or just static slip data. Determine if trending/discovery features are in scope beyond the followed-user feed. Confirm notification channel requirements (push, in-app, email). Ask about content moderation needs for betting-related content.
Sketch the core services: Post Service (stores slips in PostgreSQL), Feed Service (assembles timelines from Redis caches), Social Graph Service (manages follow relationships), Engagement Service (processes likes and comments), Notification Service (delivers alerts across channels), and a Trending Service (computes popular slips based on recent engagement). Show Kafka as the event backbone connecting post creation to fanout workers, engagement events to counter updaters, and follow events to notification delivery. Place Redis in front of timelines, engagement counters, and connection routing. Include WebSocket gateways for real-time push.
Walk through a feed load request. The Feed Service checks the user's timeline cache in Redis (sorted set of slip IDs with timestamp scores). If the cache is warm, it reads the top N entries after the client's cursor, hydrates them by fetching full slip content and author metadata from cache or database, and returns the page with a new cursor. For cold caches (new user or expired), the service queries the follow graph, fetches recent posts from each followed user's outbox, merges and scores them, and populates the cache. Trending slips from the Trending Service are blended in at defined positions. The entire flow targets sub-200ms latency by keeping hot data in Redis and parallelizing hydration calls.
Cover engagement handling: likes and comments published to Kafka, consumed by the Engagement Service which updates sharded counters in Redis and persists to PostgreSQL in batches. Discuss real-time updates: WebSocket gateways subscribe to Redis Pub/Sub channels for user-specific feed updates and slip-specific engagement deltas. Address notifications: a worker pool consumes follow-graph events, respects user preferences and quiet hours, and routes through push, in-app, or email channels with rate limiting. Touch on monitoring: track feed latency, fanout lag, engagement processing throughput, notification delivery rates, and Kafka consumer lag. Discuss scaling: shard Redis by user ID, partition Kafka by slip ID for engagement and user ID for fanout, and auto-scale WebSocket gateways based on connection count.
Deepen your understanding of the patterns used in this problem: