Design an Instagram-like photo and video sharing service.
Core requirements:
-
Users can create accounts, follow and unfollow other users, and view profiles.
-
Users can upload photos and short videos.
-
Users can view a personalized home feed containing recent or ranked posts from accounts they follow.
-
Users can like, comment on, and delete posts.
-
Media should be served with low latency through a CDN.
-
The system should be highly available and eventually consistent where appropriate.
Discuss APIs, data models, storage, media upload and processing, feed generation, caching, scaling, reliability, and monitoring.
Deep-dive follow-up: The upload flow uses object-storage pre-signed URLs so clients can upload media directly. How can the system prevent or mitigate malicious uploads? In particular, discuss why size limits and server-side validation help, what they do not solve, and what additional controls should be used.