Back to explorer
System Architectures 5 Min

Instagram

MEDIUM

Design Instagram (Photo Sharing Platform)

Instagram is a global photo sharing and social media platform hosting billions of user-uploaded images and custom activity feeds.


1. High-Level Design

Instagram requires a highly optimized media ingestion pipeline alongside a fast, pre-computed timeline generator.

code
Upload Path: Client ---> API Gateway (Presigned URL) ---> AWS S3 Storage
Metadata Path: Client ---> Feed Service ---> PostgreSQL (Metadata) ---> Redis Pre-computed Feed

Components

1. Media Ingest Gateway: Authenticates requests and returns a presigned S3 upload URL. The client uploads images directly to S3, bypassing application servers.

2. Media Processor: Triggered by S3 upload notifications, it compresses images and generates multi-resolution thumbnails.

3. Feed Service: Pre-computes activity timelines. It uses a Push Model (fan-out on write) for average users, publishing their photo directly to friends' feeds in Redis. It uses a Pull Model (fan-out on read) for popular/celebrity profiles to avoid write amplification.


2. Potential Deep Dives

  • Media Cache Eviction:

Use CDN edge networks (CloudFront) to cache hot images. Configure a Least Recently Used (LRU) policy on CDN edges to prune cold images.

  • Database Sharding:

Shard PostgreSQL metadata tables using user_id as the sharding key. This ensures all photo records for a single user live on the same physical shard.


3. References & Tech Blogs