News Feed — Hybrid Fan-out Architecture

News Feed — Hybrid Fan-out Architecture An architecture diagram generated by Archify. Clients · app + web · Architecture component Clients app + web API gateway · auth, rate limits · Architecture component API gateway auth, rate limits Post service · write API · Architecture component Post service write API Post store · posts by ID · Architecture component Post store posts by ID Kafka · PostCreated · Architecture component Kafka PostCreated Fan-out workers · push to followers · Architecture component Fan-out workers push to followers Social graph · followers · Architecture component Social graph followers Timeline cache · Redis lists of IDs · Architecture component Timeline cache Redis lists of IDs Feed service · merge + rank · Architecture component Feed service merge + rank HTTPS create post store event consume followers push IDs read hydrate + celebs Legend Frontend Backend Database Security Message bus

Write path

  • • Post stored once, event published
  • • Workers push post IDs to followers' timelines

Celebrities

  • • No fan-out for huge accounts
  • • Their posts are pulled and merged at read time

Read path

  • • Timeline = cached IDs + celebrity pull
  • • Hydrate posts, rank, paginate by cursor