← sources

Studied how the News Feed works in Instagram and other social media platforms.

source: reddit (reddit:webdev)published 2026-06-04 07:41ingested 2026-06-04 09:48

retained text

<!-- SC_OFF --><div class="md"><p>One important concept I learned is Fanout, which is basically how posts are distributed to user's feeds. </p> <ol> <li>Fanout Push</li> </ol> <p>When a user creates a post, the system immediately pushes that post to the feed cache of all followers.<br /> This is very fast because the feed is already prepared when users open the app.</p> <ol> <li>Fanout Pull</li> </ol> <p>Instead of precomputing feeds, the system generates the feed when a user opens the application by fetching posts from accounts they follow.<br /> It saves storage and avoids unnecessary work for accounts with huge follower counts.</p> <p>Now real system user Hybrid Approach</p> <p>For normal users with a few hundred followers, Fanout Push works well because the cost is manageable and feed loading is fast.</p> <p>For celebrities like Virat Kohli with 250M+ followers, pushing every post to every follower's feed cache would be extremely expensive. Many followers may not even open the app, so a lot of storage and compute would be wasted. That's why large scale systems often use Fanout Pull (or a hybrid approach) for such accounts.</p> <p>But How Does the Feed Know to Fetch Celebrity Posts?</p> <p>A question I had was:</p> <p>If my normal friends' posts are already present in my feed cache through Fanout Push, how does the system know that it should also fetch posts from celebrity accounts?</p> <p>One possible approach is that the social graph stores metadata about accounts. Celebrity or high follower accounts can be marked differently. When a user opens the app, the Feed Service:</p> <ol> <li>Loads the feed generated through Fanout Push.</li> <li>Checks the accounts the user follows in the Social Graph.</li> <li>Identifies celebrity accounts that use Fanout Pull.</li> <li>Fetches their latest posts separately.</li> <li>Merges both results and then applies recommendation algorithms before returning the final feed.</li> </ol> <p>Simplified Flow</p> <p>User Creates Post<br /> Post Service<br /> Store in Database<br /> Fanout Service<br /> Check Social Graph &amp; User Preferences (blocked users, muted users, close friends, etc.)<br /> Create Fanout Tasks<br /> Message Queue<br /> Fanout Workers (Push or Pull Strategy)</p> <p>I'm still learning system design, so if I've misunderstood anything or missed important concepts related to feed generation, please let me know in the comments.</p> </div><!-- SC_ON --> &#32; submitted by &#32; <a href="https://www.reddit.com/user/No-Resolution-4054"> /u/No-Resolution-4054 </a> <br /> <span><a href="https://www.reddit.com/r/webdev/comments/1twgou1/studied_how_the_news_feed_works_in_instagram_and/">[link]</a></span> &#32; <span><a href="https://www.reddit.com/r/webdev/comments/1twgou1/studied_how_the_news_feed_works_in_instagram_and/">[comments]</a></span>

document fetched 2026-06-04 09:48