KatInterview

Build a Social App for Sharing Pictures and Short Clips

System DesignModel answer
MediumModel answerSystem Designsystem-designfeed-generationcdn

Last updated

Design a social platform where people post photos and short videos, follow each other, and browse a personalized home feed, with attention to media delivery, feed fan-out and trade-offs.

Design the backend for a social app centered on visual content. People publish photos and short videos with a caption, follow other accounts, and open a home feed that lists recent posts from the accounts they follow. Posts can be liked and commented on, and every account has a profile page listing its own posts.

Be prepared to defend each choice. Expect questions such as: why this data store and not another, what fails first as traffic grows, how latency, cost and consistency pull against each other, and what you would change if usage patterns shifted. Budget your time so the core design fits comfortably in less than a full session.

Assumptions and rules

  • The workload is read-heavy: feeds are opened far more often than posts are created.
  • No traffic numbers are provided. State your own estimates and use them to drive decisions.
  • Ephemeral stories, private messaging, search and advertising are out of scope.

Questions you may want to settle up front

  • Is the feed ordered by time or ranked?
  • Are videos included, and how long may they be?
  • How soon after posting should followers see the new item?
  • What is the maximum follower count for one account?
  • Is the audience global, requiring multiple regions?

What to cover

  1. Scope, requirements and back-of-envelope estimates.
  2. The upload path and how media is stored and delivered.
  3. Feed generation for ordinary accounts and for accounts with huge audiences.
  4. Data model and storage choices, including the follow graph.
  5. Caching and consistency choices per feature.
  6. Failure handling, scaling to several regions, and the main trade-offs.

Hints

Hint 1

Start from estimates: posts per day, feed opens per day, and average media size. The ratio of reads to writes should justify most of your later choices.

Hint 2

Keep large files away from your API servers: think about direct-to-object-storage uploads with signed URLs, asynchronous transcoding, and CDN delivery.

Hint 3

Compare fan-out on write with fan-out on read, then ask what happens when one account has tens of millions of followers. A hybrid approach is the usual answer.

Hint 4

Decide consistency per feature: an author should see their own post immediately, while follower feeds and like counts can lag by seconds.