๐ Designing a news feed system similar to Facebook, Instagram, and Twitter.
๐ธ The system will focus on photo posts but can easily be extended to include video posts.
๐ป The system will be built using relational database tables, starting with MySQL.
๐ก A news feed system can consist of complex tables, but for simplicity, we start with basic relational tables.
๐ฑ The end-to-end flow of a user creating a post involves the app, load balancer, and the post service.
๐ Additional work behind the scenes includes post moderation, enrichment, and storing metadata.
๐ The system design for a scalable news feed involves using a change data capture stream (CDC) to make the process asynchronous.
๐ Different consumers, such as a moderation stream processor and an enrichment stream processor, can independently process the data from the CDC stream to perform various actions on the posts.
๐ฒ When consuming posts in a feed, the client makes a get request to the feed service, which computes and returns the user's feed as a JSON payload.
๐ The feed system works by obtaining the user's friends' user ids and getting all their posts.
โ๏ธ The ranking service ranks the posts based on different conditions and sends them back to the feed service.
๐ To optimize performance, a cache is added to the feed service to pre-compute and store the post ids for each user.
๐ The cache is used to map user IDs to a list of post IDs, saving on bandwidth and storage.
โก The cache allows the feed service to quickly retrieve the list of post IDs and make HTTP calls to retrieve post metadata.
๐ The cache significantly reduces the workload of the feed service and other services when serving a user's feed.
๐ The video discusses the design of a scalable news feed system similar to Instagram, Facebook, and Twitter.
๐ The system includes a real-time feed stream processor that updates the feed cache for each user whenever a new post is created.
๐ Additionally, there is a scheduled batch job that iterates through all users to update their feed cache periodically.
๐ The system design for a scalable news feed involves multiple processors that moderate posts, extract metadata, and promote posts to relevant users.
โก Real-time processing is used for moderating and enriching posts, while offline processing is used for reformatting and recomputing user feeds.
๐ The feed service utilizes a cache to quickly retrieve and deliver post details to users.