1 · Post a tweet
The write path stores the tweet, fans it out to followers, indexes it, stores media, and notifies followers.
Interactive diagram · architecture
The write path stores the tweet, fans it out to followers, indexes it, stores media, and notifies followers.
The read path gets timeline ids from cache and enriches them with tweet and user information.
The read API retrieves the user timeline from the SQL database.
The search API parses the query and asks the search service for ranked results.
The person or program making a request.
It resolves DNS, can fetch static content from CDN, and sends requests to Load Balancer.
DNS translates a domain name to an IP address.
It receives the client lookup and directs the client to the service address.
A CDN serves content close to users.
It receives static requests from Client and can serve media held in Object Store.
A load balancer distributes requests across computing resources.
It receives client traffic and sends it to Web Server instances.
A reverse proxy forwards requests to application services.
It receives traffic from Load Balancer and routes requests to Read API, Write API, or Search API.
An application API that handles timeline reads.
It receives requests from Web Server and asks Timeline Service or SQL Read Replicas for timeline data.
An application API that handles tweet writes.
It receives work from Web Server, stores the tweet in SQL Write Master–Slave, and contacts Fan Out Service.
An application API for keyword search.
It receives a Web Server request and contacts Search Service for results.
A service that supplies tweet details.
Timeline Service calls it with a multiget to enrich timeline tweet ids.
A service that builds home timeline results.
It receives Read API requests, reads ids from Memory Cache, and calls Tweet Info Service and User Info Service.
A service that distributes a tweet to followers.
It receives the new tweet from Write API, queries User Graph Service, writes follower timelines to Memory Cache, indexes search, and starts notifications.
Users with millions of followers can take minutes to finish fanout.
A service that finds a user’s followers.
Fan Out Service queries it, and it uses Memory Cache for follower information.
A service that supplies user details.
Timeline Service calls it with a multiget to enrich user ids.
An in-memory store for timeline and follower data.
Timeline Service reads it, while Fan Out Service and User Graph Service update or query it.
A service that parses and queries keyword search.
It receives Search API queries and new tweets from Fan Out Service, then returns ranked search results.
A service that sends push notifications.
Fan Out Service calls it to notify followers asynchronously through a queue not pictured.
Replicas serve database reads after changes are copied from the writer.
Read API uses them for cache misses and user timeline reads.
A SQL writer stores tweets and replicates changes.
Write API sends new tweets here; user timeline reads use the database data.
Storage for media such as photos and videos.
Write API stores media here, and CDN can serve that media to Client.
Detail · follows playback, or click any box or step to pin it
Close · follow playbackClick any box for an explanation, or use Next or Play to walk through the four steps.
The Write API stores a tweet, then the Fan Out Service builds followers’ home timelines, indexes search, stores media, and sends notifications.
The post path favors fast writes and fanout.
Timeline Service reads timeline ids from Memory Cache, then multigets tweet and user information.
The home timeline favors fast reads.
Read API retrieves the user’s own timeline from the SQL database.
This path reads the user’s stored tweets.
Search API forwards a parsed query to Search Service, which queries the Search Cluster and returns ranked results.
The search path is read-heavy.