Instagram Clone
Photo and Reels platform using presigned S3 uploads, Step Functions media processing, and a hybrid push/pull feed on ElastiCache Redis and DynamoDB.
- Presigned S3 upload
- Hybrid push/pull feed
- Step Functions + MediaConvert
- Redis + DynamoDB
Amazon Route 53
Route 53 DNS
Amazon CloudFront
CloudFront Media CDN
Amazon Cognito
Cognito User Pools
Amazon API Gateway
API Gateway HTTP API
Amazon Simple Storage Service
S3 Ingest Bucket
Amazon EventBridge
EventBridge Media Bus
AWS Step Functions
Step Functions Media Workflow
Amazon Rekognition
Rekognition Moderation
AWS Elemental MediaConvert
MediaConvert Reels & Thumbnails
Amazon Simple Storage Service
S3 Production Media Store
AWS Fargate
Fargate Feed & Post API
AWS Lambda
Fan-Out Worker Fleet
Amazon Simple Queue Service
SQS Fan-Out Queue
Amazon ElastiCache
ElastiCache Redis Timelines
Amazon DynamoDB
DynamoDB Social Graph
Amazon OpenSearch Service
OpenSearch Hashtags & Explore
Amazon CloudWatch
CloudWatch Metrics & Alarms
The problem
Uploads are heavy binary writes that require moderation and transcoding, while home feeds need sub-150ms reads. Pushing new posts to every follower's cache works for regular accounts, but a single post from an account with millions of followers will flood the queue if pushed on write.
Step-by-step flow
Presigned S3 direct upload
Cognito authenticates the user and Fargate issues a 5-minute S3 presigned PUT URL. The client uploads media straight to the private S3 Ingest bucket via S3 Transfer Acceleration.
Cognito · API Gateway · Fargate · S3Parallel moderation and transcoding
S3 ObjectCreated events trigger Step Functions via EventBridge. Rekognition scans for unsafe content while MediaConvert generates WebP thumbnails and HLS video segments into the production S3 bucket.
EventBridge · Step Functions · Rekognition · MediaConvertHybrid push/pull timeline fan-out
For authors under 10k followers, SQS and Lambda workers push the post ID into each follower's Redis Sorted Set (capped at 800 IDs). High-follower accounts skip fan-out and are merged on read.
DynamoDB · SQS · Lambda · ElastiCache RedisEdge media delivery and timeline hydration
Fargate reads the user's Redis timeline, merges followed celebrity posts, and batch-fetches metadata from DynamoDB. Photos and Reels stream from CloudFront with Origin Shield.
CloudFront · ElastiCache Redis · DynamoDB · OpenSearch
Key decisions & benefits
Direct S3 presigned uploads instead of API proxying
Fargate signs a size-bounded S3 PUT policy so clients upload directly to S3 edge endpoints instead of streaming megabytes through API Gateway.
Why it works: Keeps API tasks small and stateless while cutting ingress bandwidth costs in half.
Hybrid fan-out split at 10,000 followers
Standard posts push to follower Redis timelines on write; celebrity posts stay in an outbound list and merge on read.
Why it works: Delivers sub-10ms Redis reads for 99% of timelines without celebrity write storms.
Isolated S3 ingest and production buckets
Raw uploads land in a locked ingest bucket with 24-hour expiry. Only Rekognition-approved, transcoded files move to the CloudFront production bucket.
Why it works: Prevents unmoderated files or raw EXIF GPS data from ever being served publicly.
DynamoDB Streams to OpenSearch for discovery
DynamoDB handles key-value lookups while DynamoDB Streams syncs captions and hashtags to OpenSearch.
Why it works: Fast transactional writes on DynamoDB paired with full-text hashtag search.
AWS services used (16)
Amazon Route 53 Latency DNS
Routes clients to the nearest edge.
Amazon CloudFront Media CDN
Caches WebP and HLS segments via OAC.
Amazon Cognito User Auth
Issues JWTs and handles OAuth logins.
Amazon API Gateway HTTP Ingress
Validates JWTs and throttles traffic.
AWS Fargate Feed & Post API
Stateless containers in private subnets.
Amazon S3 Media Storage
Separate ingest and production buckets.
Amazon EventBridge Upload Events
Triggers processing on S3 ObjectCreated.
AWS Step Functions Orchestration
Runs moderation and encoding in parallel.
Amazon Rekognition Content Safety
Blocks unsafe images and videos.
MediaConvert Transcoding
Outputs WebP sizes and HLS video.
Amazon SQS Fan-Out Queue
Buffers timeline write bursts.
AWS Lambda Fan-Out Workers
Pushes post IDs into follower Redis sets.
ElastiCache Redis Timeline Cache
Stores 800 recent post IDs per active user.
Amazon DynamoDB Social Graph DB
Stores posts, likes, and follow edges.
Amazon OpenSearch Search Index
Powers hashtag and location search.
Amazon CloudWatch Observability
Monitors feed latency and queue backlog.
Trade-offs
| Choice | Benefit | Trade-off |
|---|---|---|
| Redis timeline cache (800 post IDs/user) | Sub-10ms home feed reads. | Higher RAM cost; cold users fall back to DynamoDB queries. |
| Async Step Functions + MediaConvert | Guaranteed moderation and mobile-optimized WebP/HLS. | 2–8 second delay before a new upload appears in feeds. |
| DynamoDB partitioned social graph | Predictable single-digit ms latency at scale. | No ad-hoc SQL joins across relationships. |
| CloudFront Origin Shield | Collapses regional cache misses into one S3 read. | Adds a small per-request Origin Shield fee. |
Open to Backend & AWS Cloud roles
Hiring for AWS Cloud or Backend Engineering?
Available immediately (UTC+1) for remote roles, sponsored relocation, or B2B contracts.