Katkat

Design a scalable image-based social network

AmazonSoftware Engineer · Onsite

Last updated

This question tests your ability to design a distributed system architecture capable of handling high-volume image uploads, metadata storage, and low-latency feed retrieval.

Problem Statement

Design a scalable image-based social network (similar to Instagram) that allows users to upload photos, follow other users, and view a personalized feed of images from the people they follow.

Functional Requirements

  • Users can upload images with captions.
  • Users can follow/unfollow other users.
  • Users can view a 'Home Feed' consisting of the latest images from accounts they follow.
  • Users can view their own profile containing all their uploaded images.

Non-Functional Requirements

  • High Availability: The system must be resilient to individual component failures.
  • Scalability: The system must handle millions of concurrent users and high throughput.
  • Low Latency: Image uploads should be reliable, and feed retrieval should be near-instant (under 200ms).
  • Consistency: Eventual consistency is acceptable for feeds, but profile data should be highly consistent.

Deliverables

  1. A high-level architectural diagram (describe components).
  2. API endpoints for the core features.
  3. Data model/Database schema design (consider SQL vs. NoSQL).
  4. Strategies for image storage and delivery.

Assumptions

  • Assume 100 million Daily Active Users (DAU).
  • Assume 5 million new image uploads per day.
  • Focus on read-heavy workloads.

Hints

Hint 1

Consider the difference between storing metadata (text, timestamps, relationships) and the actual binary image files.

Hint 2

Think about whether to pre-compute feeds upon upload (push model) or compute them when a user requests their feed (pull model) given the scale.

Hint 3

Use CDNs to solve latency issues for static assets and caching layers for frequently accessed data.

Follow-up questions

  • How would you handle a 'celebrity' user with millions of followers to prevent system crashes during an upload?
  • What changes would you make if the system needs to support real-time notifications for new likes or comments?
  • How would you implement an efficient search functionality for finding users by username or images by hashtags?