20 Concepts

Notes from 20 System Design Concepts Explained in 10 Minutes

  1. Vertical Scaling → Add more resources like RAM or CPU
  2. Horizontal Scaling → Add replicas; each server can handle a subset of requests; can almost scale infinitely; don’t need beefy machines; adds redundancy and fault tolerance; eliminates single POF
  3. Load Balancer → a server known as Reverse Proxy; redirects incoming requests to the appropriate server; Round Robin (cycle through our pool of servers); Hashing incoming request ID; goal is to even the amount of traffic each server is getting; if servers are located all around the world, can route a request to the nearest location
  4. Content Delivery Networks → serving static files (images/videos/HTML/CSS/JS); network of servers located all around the world; does not run any application logic; work by taking files from the origin server and copying them into CDN servers; an either be pull or push basis; a technique for caching
  5. Caching → creating copies of data so that it can be refetched faster in the future; making network requests can be expensive, so our browsers sometimes cache data onto our disk, reading from disk can be expensive, so computer copies it into memory, but reading from memory can be expensive, so operating system will copy a subset of it into L1, L2 or L3 CPU cache
  6. IP Address → every computer assigned an IP address which uniquely identifies a device on a network
  7. TCP / IP → the Internet Protocol Suite, includes IP, TCP and UDP, TCP: files are broken down into individual packets and sent over the Internet, arrive at the destination, packets are numbered so they can be reassembled in the right order; if packets are missing, TCP ensures they will be resent as TCP is a reliable protocol; HTTP and WebSockets are built on top of TCP
  8. Domain Name System (DNS) → largely decentralized service that works to translate a domain to its IP address; when you buy a domain from a DNS registrar, you can create a DNA A record (stands for address), and then you can the enter the IP address of your server, so when you search and your computer makes a DNS query to get the IP address, it’ll use the A record mapping to get the address and then your operating system will cache it so that it does not need to make a DNS query every single time
  9. HTTP → use this protocol to view websites as TCP is too low level; it is an application layer protocol; client-server model, client initiates a request (includes 1. request header - metadata about the package, 2. request body: package contents)
  10. REST → API pattern; most popular; a standardization around HTTP APIs; making them stateless and following consistent guidelines
  11. GraphQL → API pattern; introduced by Facebook in 2015; idea is to only make a single request aka a Query, and you get to choose exactly which requests you want to fetch, means you can fetch multiple resources with a single request, and don’t end up overfetching data that is not needed
  12. gRPC → API pattern, though it’s really considered a framework; released by Google in 2016; meant as an improvement over REST APIs; RPC framework mainly used for server-to-server communication, but there is also gRPC Web which allows using gRPC from the browser; performance boost comes from protocol buffers (protobuf), comparing to JSON which REST APIs mainly use, upside: data is serialized into a binary format which is usually more storage efficient and sends less data over a network, downside: JSON is much more human readable since it’s just plain text
  13. WebSockets → application layer protocol; popular for real-time chat messaging’ avoids overhead with something like Polling; supports bi-directional communication, when you get a new message it’s immediately pushed to the receiver’s device and vice-versa
  14. SQL → relational database management systems (RDBMS) like MySQL or Postgres; more efficiently store data using data structures like B trees; fast retrieval of data using SQL queries; data is stored into rows and tables; RDBMS are ACID-compliant
  15. ACID → Durability: data is stored on disk; Isolation: different concurrent transactions will not interfere with each other; Atomicity: every transaction is “All or Nothing”; Consistency: foreign key and other constraints are other key constraints are enforced
  16. NoSQL → issue with consistency led to the creation of NoSQL; consistency makes databases harder to scale, so NoSQL databases drop this constraint and the idea of relations all together; there are many types of NoSQL databases: key-value stores, document stores, graph databases; if we don’t have to enforce any foreign key constraints, that means we can break up our database and scale it horizontally with different machines
  17. Sharding → technique to break up our database and scale it horizontally with different machines; have a shard key, decide which portion of the data to put on which machine
  18. Replication → to scale database reads, make read-only copies, called Leader-Follower replication, where every write gets sent to the Leader while every read can go either to a Leader or Follower; there’s also a Leader-Leader replication, where every replica can be used for read or write, but can result in inconsistent data, best to use it where you can have a replica for every region in the world for example, it can be complex to keep replicas in sync
  19. CAP Theorem → weigh trade-offs with replicated design; given a network partition in a database, we can only choose to favor either data consistency or data availability, “pick two of three”; note that consistency means something different than the one in ACID; more complete is the PACELC Theorem
  20. Message Queues → kind of like databases, have durable storage, can be replicated for redundancy, can be sharded for scalability; have many use cases; system receiving more data than it can process, good to introduce a message queue, so our data can be persisted before we are able to process it; obtain the added benefit that different parts of our application can become decoupled

For more System Design concepts, click here.