Flowchart
Last updated
Was this helpful?
Last updated
Was this helpful?
Single direction relationship
Star users
High latency
Get news feed: N DB reads + K way merge (KlogK, K is the number of friends)
Bottleneck is in N DB reads, although they could be integrated into one big DB query.
This result in high latency because it needs to wait until N DB reads finish
Bi-direction relationship
No star users: Users do not have a lot of followers
Low latency
When number of followers is really large, the number of asynchronous task will have high latency.
Post a tweet: N followers, N DB writes. Executed asynchronously.
For users with a lot of followers, use pull; For other users, use push.
Define a threshold (number of followers)
Below threshold use push
Above threshold use pull
For popular users, do not push. Followers fetch from their timeline and integrate into news feed.
May miss updates.
Solutions:
Star users: Pull not push
Half star user: Pull + Push
Normal user: Push