System Design Notes

How to Approach

  1. Understanding the user requirements
  2. Coming up with a high level design
  3. Scaling the design

Notes from harvard scalability lecture

  • Vertical scaling means adding more RAM/CPU etc.
    • this will have physical limits and might blow your budget
  • Horizontal scaling means we can use cheaper less capable hardware, but more of them

Components

Load balancer

Spread out requests across several servers, each of which maintains a replica of our application server.

DNS round robin

Each DNS request can be used to send a different IP address. So each new request will go the next available sever. Can use something like BIND(Berkely Internet Name Daemon). Google uses something like this?

Limitations
  • Does not take into account load of each server
  • DNS responses will likely be cached on client, so a high traffic client will likely keep hitting the same server with every request, so in that case this technique will not help us
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
                     ________________
| |
| CLIENT |
| WEB BROWSER |
|________________|
||
||
_______\/_______
| |
| DNS SERVER |
|________________|
||
||
_______/ \_______
/ \
/ \
____________________ ____________________
| | | |
| SAN FRANCISCO | | SAN FRANCISCO |
|____________________| |____________________|
| ______________ | | ______________ |
| | | | | | | |
| | WEB SERVER | | | | WEB SERVER | |
| | LOAD BALANCE | | | | LOAD BALANCE | |
| | PROXY | | | | PROXY | |
| |_____ _____| | | |_____ _____| |
|________| |________| |________| |________|
|| __ __ ||
||<=====||==================||=====>||
\/ \/ \/ \/
____________________ ____________________
| | | |
| SAN FRANCISCO | | NEW YORK |
|____________________| |____________________|
| ______________ | | ______________ |
| | | | | | | |
| | APP SERVER | | | | APP SERVER | |
| |______ ______| | | |______ ______| |
| ______||______ | | ______||______ |
| | | | | | | |
| | DATABASE |<==================>| DATABASE | |
| |______________| | | |______________| |
|____________________| |____________________|

Reference

  1. HTTP(S) load balancing

Reference
More about HTTP Headers
Load balancing concepts

Reverse proxy

Reference

Message Brokers

Reverse Proxies

Example: Design Pinterest

Users

Constraints

High level design

Real life examples

Aman many more good ones at QCON!

References

  1. System design primer
  2. Hired in Tech
  3. Reddit discussion
  4. Clean Architecture Book (requires subscription)
  5. System Design Interview for IT
  6. Building Software Systems At Google and Lessons Learned
  7. Building a garbage collector
  8. Software Design patterns
  9. The Guardian’s move to Postgres