System Design - Examples
Twitter: Push vs Pull
- Normal Account: push model
- a new tweet will be pushed to all the followers, each follower has a home timeline cache like a mailbox. fan-out: poster 1 write, 100 followers, 100 writes, ~80 reads
- Large Account: pull model
- a new tweet is inserted to the db, every home timeline update query will pull from the db, 1 write, x reads
When you vote, your vote isn’t instantly processed—instead, it’s placed into a queue. if you were to vote and quickly refresh the page, your vote may not have been processed yet, and it would appear that your vote had been reverted. To get around this, we cache your recent votes for a short period of time to display them back to you until they’re processed.
reddit cache https://redditblog.com/2017/01/17/caching-at-reddit/
One of the optimizations we make is splitting up our caches by workload type, rather than running them as one big pool.
when to scale up caches: caches are starting to evict more and our database is slowing down as a result
Memcached works on a memory allocation system known as slab allocation.
React, GraphQL, Relay, Flow, Flux and Hack
Every entity is a node ("Object"), e.g. a person, a page, an ad account, etc. Nodes are connected by edges ("Association"). The API:
- Object: (id) -> (otype, (key, value))
- Assoc.: (id1, atype, id2) -> (time, (key, value))
- Stack Share: https://stackshare.io/
- Cloud Native Computing Foundation: https://www.cncf.io/