|
@@ -3,7 +3,7 @@
|
|
|
# The System Design Primer
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/jj3A5N8.png">
|
|
|
+ <img src="http://i.imgur.com/jj3A5N8.png"/>
|
|
|
<br/>
|
|
|
</p>
|
|
|
|
|
@@ -44,7 +44,7 @@ Additional topics for interview prep:
|
|
|
## Anki flashcards
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/zdCAkB3.png">
|
|
|
+ <img src="http://i.imgur.com/zdCAkB3.png"/>
|
|
|
<br/>
|
|
|
</p>
|
|
|
|
|
@@ -61,7 +61,7 @@ Great for use while on-the-go.
|
|
|
Looking for resources to help you prep for the [**Coding Interview**](https://github.com/donnemartin/interactive-coding-challenges)?
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/b4YtAEN.png">
|
|
|
+ <img src="http://i.imgur.com/b4YtAEN.png"/>
|
|
|
<br/>
|
|
|
</p>
|
|
|
|
|
@@ -91,7 +91,7 @@ Review the [Contributing Guidelines](CONTRIBUTING.md).
|
|
|
> Each section contains links to more in-depth resources.
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/jrUBAF7.png">
|
|
|
+ <img src="http://i.imgur.com/jrUBAF7.png"/>
|
|
|
<br/>
|
|
|
</p>
|
|
|
|
|
@@ -436,7 +436,7 @@ Generally, you should aim for **maximal throughput** with **acceptable latency**
|
|
|
### CAP theorem
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/bgLMI2u.png">
|
|
|
+ <img src="http://i.imgur.com/bgLMI2u.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://robertgreiner.com/2014/08/cap-theorem-revisited>Source: CAP theorem revisited</a></i>
|
|
|
</p>
|
|
@@ -530,7 +530,7 @@ This topic is further discussed in the [Database](#database) section:
|
|
|
## Domain name system
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/IOyLj4i.jpg">
|
|
|
+ <img src="http://i.imgur.com/IOyLj4i.jpg"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/srikrupa5/dns-security-presentation-issa>Source: DNS security presentation</a></i>
|
|
|
</p>
|
|
@@ -568,7 +568,7 @@ Services such as [CloudFlare](https://www.cloudflare.com/dns/) and [Route 53](ht
|
|
|
## Content delivery network
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/h9TAuGI.jpg">
|
|
|
+ <img src="http://i.imgur.com/h9TAuGI.jpg"/>
|
|
|
<br/>
|
|
|
<i><a href=https://www.creative-artworks.eu/why-use-a-content-delivery-network-cdn/>Source: Why use a CDN</a></i>
|
|
|
</p>
|
|
@@ -609,7 +609,7 @@ Sites with heavy traffic work well with pull CDNs, as traffic is spread out more
|
|
|
## Load balancer
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/h81n9iK.png">
|
|
|
+ <img src="http://i.imgur.com/h81n9iK.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://horicky.blogspot.com/2010/10/scalable-system-design-patterns.html>Source: Scalable system design patterns</a></i>
|
|
|
</p>
|
|
@@ -679,7 +679,7 @@ Load balancers can also help with horizontal scaling, improving performance and
|
|
|
## Reverse proxy (web server)
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/n41Azff.png">
|
|
|
+ <img src="http://i.imgur.com/n41Azff.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://upload.wikimedia.org/wikipedia/commons/6/67/Reverse_proxy_h2g2bob.svg>Source: Wikipedia</a></i>
|
|
|
<br/>
|
|
@@ -722,7 +722,7 @@ Additional benefits include:
|
|
|
## Application layer
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/yB5SYwm.png">
|
|
|
+ <img src="http://i.imgur.com/yB5SYwm.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://lethain.com/introduction-to-architecting-systems-for-scale/#platform_layer>Source: Intro to architecting systems for scale</a></i>
|
|
|
</p>
|
|
@@ -757,7 +757,7 @@ Systems such as [Consul](https://www.consul.io/docs/index.html), [Etcd](https://
|
|
|
## Database
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/Xkm5CXz.png">
|
|
|
+ <img src="http://i.imgur.com/Xkm5CXz.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://www.youtube.com/watch?v=w95murBkYmU>Source: Scaling up to your first 10 million users</a></i>
|
|
|
</p>
|
|
@@ -780,7 +780,7 @@ There are many techniques to scale a relational database: **master-slave replica
|
|
|
The master serves reads and writes, replicating writes to one or more slaves, which serve only reads. Slaves can also replicate to additional slaves in a tree-like fashion. If the master goes offline, the system can continue to operate in read-only mode until a slave is promoted to a master or a new master is provisioned.
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/C9ioGtn.png">
|
|
|
+ <img src="http://i.imgur.com/C9ioGtn.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/jboner/scalability-availability-stability-patterns/>Source: Scalability, availability, stability, patterns</a></i>
|
|
|
</p>
|
|
@@ -795,7 +795,7 @@ The master serves reads and writes, replicating writes to one or more slaves, wh
|
|
|
Both masters serve reads and writes and coordinate with each other on writes. If either master goes down, the system can continue to operate with both reads and writes.
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/krAHLGg.png">
|
|
|
+ <img src="http://i.imgur.com/krAHLGg.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/jboner/scalability-availability-stability-patterns/>Source: Scalability, availability, stability, patterns</a></i>
|
|
|
</p>
|
|
@@ -823,7 +823,7 @@ Both masters serve reads and writes and coordinate with each other on writes. I
|
|
|
#### Federation
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/U3qV33e.png">
|
|
|
+ <img src="http://i.imgur.com/U3qV33e.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://www.youtube.com/watch?v=w95murBkYmU>Source: Scaling up to your first 10 million users</a></i>
|
|
|
</p>
|
|
@@ -844,7 +844,7 @@ Federation (or functional partitioning) splits up databases by function. For ex
|
|
|
#### Sharding
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/wU8x5Id.png">
|
|
|
+ <img src="http://i.imgur.com/wU8x5Id.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/jboner/scalability-availability-stability-patterns/>Source: Scalability, availability, stability, patterns</a></i>
|
|
|
</p>
|
|
@@ -988,7 +988,7 @@ Document stores provide high flexibility and are often used for working with occ
|
|
|
#### Wide column store
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/n16iOGk.png">
|
|
|
+ <img src="http://i.imgur.com/n16iOGk.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://blog.grio.com/2015/11/sql-nosql-a-brief-history.html>Source: SQL & NoSQL, a brief history</a></i>
|
|
|
</p>
|
|
@@ -1011,7 +1011,7 @@ Wide column stores offer high availability and high scalability. They are often
|
|
|
#### Graph database
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/fNcl65g.png">
|
|
|
+ <img src="http://i.imgur.com/fNcl65g.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://en.wikipedia.org/wiki/File:GraphDatabase_PropertyGraph.png>Source: Graph database</a></i>
|
|
|
</p>
|
|
@@ -1039,7 +1039,7 @@ Graphs databases offer high performance for data models with complex relationshi
|
|
|
### SQL or NoSQL
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/wXGqG5f.png">
|
|
|
+ <img src="http://i.imgur.com/wXGqG5f.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://www.infoq.com/articles/Transition-RDBMS-NoSQL/>Source: Transitioning from RDBMS to NoSQL</a></i>
|
|
|
</p>
|
|
@@ -1081,7 +1081,7 @@ Sample data well-suited for NoSQL:
|
|
|
## Cache
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/Q6z24La.png">
|
|
|
+ <img src="http://i.imgur.com/Q6z24La.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://horicky.blogspot.com/2010/10/scalable-system-design-patterns.html>Source: Scalable system design patterns</a></i>
|
|
|
</p>
|
|
@@ -1152,7 +1152,7 @@ Since you can only store a limited amount of data in cache, you'll need to deter
|
|
|
#### Cache-aside
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/ONjORqk.png">
|
|
|
+ <img src="http://i.imgur.com/ONjORqk.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/tmatyashovsky/from-cache-to-in-memory-data-grid-introduction-to-hazelcast>Source: From cache to in-memory data grid</a></i>
|
|
|
</p>
|
|
@@ -1188,7 +1188,7 @@ Subsequent reads of data added to cache are fast. Cache-aside is also referred
|
|
|
#### Write-through
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/0vBc0hN.png">
|
|
|
+ <img src="http://i.imgur.com/0vBc0hN.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/jboner/scalability-availability-stability-patterns/>Source: Scalability, availability, stability, patterns</a></i>
|
|
|
</p>
|
|
@@ -1223,7 +1223,7 @@ Write-through is a slow overall operation due to the write operation, but subseq
|
|
|
#### Write-behind (write-back)
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/rgSrvjG.png">
|
|
|
+ <img src="http://i.imgur.com/rgSrvjG.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/jboner/scalability-availability-stability-patterns/>Source: Scalability, availability, stability, patterns</a></i>
|
|
|
</p>
|
|
@@ -1241,7 +1241,7 @@ In write-behind, the application does the following:
|
|
|
#### Refresh-ahead
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/kxtjqgE.png">
|
|
|
+ <img src="http://i.imgur.com/kxtjqgE.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.slideshare.net/tmatyashovsky/from-cache-to-in-memory-data-grid-introduction-to-hazelcast>Source: From cache to in-memory data grid</a></i>
|
|
|
</p>
|
|
@@ -1273,7 +1273,7 @@ Refresh-ahead can result in reduced latency vs read-through if the cache can acc
|
|
|
## Asynchronism
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/54GYsSx.png">
|
|
|
+ <img src="http://i.imgur.com/54GYsSx.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://lethain.com/introduction-to-architecting-systems-for-scale/#platform_layer>Source: Intro to architecting systems for scale</a></i>
|
|
|
</p>
|
|
@@ -1319,7 +1319,7 @@ If queues start to grow significantly, the queue size can become larger than mem
|
|
|
## Communication
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/5KeocQs.jpg">
|
|
|
+ <img src="http://i.imgur.com/5KeocQs.jpg"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.escotal.com/osilayer.html>Source: OSI 7 layer model</a></i>
|
|
|
</p>
|
|
@@ -1351,7 +1351,7 @@ HTTP is an application layer protocol relying on lower-level protocols such as *
|
|
|
### Transmission control protocol (TCP)
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/JdAsdvG.jpg">
|
|
|
+ <img src="http://i.imgur.com/JdAsdvG.jpg"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.wildbunny.co.uk/blog/2012/10/09/how-to-make-a-multi-player-game-part-1/>Source: How to make a multiplayer game</a></i>
|
|
|
</p>
|
|
@@ -1375,7 +1375,7 @@ Use TCP over UDP when:
|
|
|
### User datagram protocol (UDP)
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/yzDrJtA.jpg">
|
|
|
+ <img src="http://i.imgur.com/yzDrJtA.jpg"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.wildbunny.co.uk/blog/2012/10/09/how-to-make-a-multi-player-game-part-1/>Source: How to make a multiplayer game</a></i>
|
|
|
</p>
|
|
@@ -1404,7 +1404,7 @@ Use UDP over TCP when:
|
|
|
### Remote procedure call (RPC)
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/iF4Mkb5.png">
|
|
|
+ <img src="http://i.imgur.com/iF4Mkb5.png"/>
|
|
|
<br/>
|
|
|
<i><a href=http://www.puncsky.com/blog/2016-02-13-crack-the-system-design-interview>Source: Crack the system design interview</a></i>
|
|
|
</p>
|
|
@@ -1600,7 +1600,7 @@ Handy metrics based on numbers above:
|
|
|
| Question | Reference(s) |
|
|
|
|---|---|
|
|
|
| Design a file sync service like Dropbox | [youtube.com](https://www.youtube.com/watch?v=PE4gwstWhmc) |
|
|
|
-| Design a search engine like Google | [queue.acm.org](http://queue.acm.org/detail.cfm?id=988407)<br/>[stackexchange.com](http://programmers.stackexchange.com/questions/38324/interview-question-how-would-you-implement-google-search)<br/>[ardendertat.com](http://www.ardendertat.com/2012/01/11/implementing-search-engines/)<br>[stanford.edu](http://infolab.stanford.edu/~backrub/google.html) |
|
|
|
+| Design a search engine like Google | [queue.acm.org](http://queue.acm.org/detail.cfm?id=988407)<br/>[stackexchange.com](http://programmers.stackexchange.com/questions/38324/interview-question-how-would-you-implement-google-search)<br/>[ardendertat.com](http://www.ardendertat.com/2012/01/11/implementing-search-engines/)<br/>[stanford.edu](http://infolab.stanford.edu/~backrub/google.html) |
|
|
|
| Design a scalable web crawler like Google | [quora.com](https://www.quora.com/How-can-I-build-a-web-crawler-from-scratch) |
|
|
|
| Design Google docs | [code.google.com](https://code.google.com/p/google-mobwrite/)<br/>[neil.fraser.name](https://neil.fraser.name/writing/sync/) |
|
|
|
| Design a key-value store like Redis | [slideshare.net](http://www.slideshare.net/dvirsky/introduction-to-redis) |
|
|
@@ -1628,7 +1628,7 @@ Handy metrics based on numbers above:
|
|
|
> Articles on how real world systems are designed.
|
|
|
|
|
|
<p align="center">
|
|
|
- <img src="http://i.imgur.com/TcUo2fw.png">
|
|
|
+ <img src="http://i.imgur.com/TcUo2fw.png"/>
|
|
|
<br/>
|
|
|
<i><a href=https://www.infoq.com/presentations/Twitter-Timeline-Scalability>Source: Twitter timelines at scale</a></i>
|
|
|
</p>
|