System Design Primer · llms.txt
The System Design Primer
Donne Martin's The System Design Primer (CC BY 4.0), the guide to designing large-scale systems, reorganized into 35 chapters: core trade-offs, building blocks from DNS to databases, and worked system design and object-oriented design interview questions. Also 16 extra chapters written for this site on topics the primer doesn't cover, such as rate limiting, consistent hashing and consensus.
Start here
Why system design matters, how much to study, and how to run an interview answer.
Core trade-offs
The tensions every design balances: speed, scale, availability and consistency.
- Performance vs scalability: A service is scalable if it results in increased performance in a manner proportional to resources added. Generally, increasing performance means serving more units of work, but…
- Latency vs throughput: Latency is the time to perform some action or to produce some result.
- Availability vs consistency: In a distributed computer system, you can only support two of the following guarantees:
- Consistency patterns: With multiple copies of the same data, we are faced with options on how to synchronize them so clients have a consistent view of the data. Recall the definition of consistency…
- Availability patterns: There are two complementary patterns to support high availability: fail-over and replication.
Building blocks
The components a request passes through, from DNS to the database.
- Domain name system: A Domain Name System (DNS) translates a domain name such as www.example.com to an IP address.
- Content delivery network: A content delivery network (CDN) is a globally distributed network of proxy servers, serving content from locations closer to the user. Generally, static files such as…
- Load balancer: Load balancers distribute incoming client requests to computing resources such as application servers and databases. In each case, the load balancer returns the response from the…
- Reverse proxy (web server): A reverse proxy is a web server that centralizes internal services and provides unified interfaces to the public. Requests from clients are forwarded to a server that can fulfill…
- Application layer: Separating out the web layer from the application layer (also known as platform layer) allows you to scale and configure both layers independently. Adding a new API results in…
- Database: A relational database like SQL is a collection of data items organized in tables.
- Cache: Caching improves page load times and can reduce the load on your servers and databases. In this model, the dispatcher will first lookup if the request has been made before and try…
- Asynchronism: Asynchronous workflows help reduce request times for expensive operations that would otherwise be performed in-line. They can also help by doing time-consuming work in advance,…
- Communication: HTTP is a method for encoding and transporting data between a client and a server. It is a request/response protocol: clients issue requests and servers issue responses with…
- Security: This section could use some updates. Consider contributing!
Reference
Numbers to memorise, more practice questions, and real-world architectures.
- Appendix: You'll sometimes be asked to do 'back-of-the-envelope' estimates. For example, you might need to determine how long it will take to generate 100 image thumbnails from disk or how…
System design questions
Worked solutions with use cases, constraints, diagrams and scaling discussion.
Object-oriented design questions
Class design exercises with Python solutions.
About the primer
The flashcard decks, topics still being written, credits, contributing and the license.
- About the primer: The provided Anki flashcard decks use spaced repetition to help you retain key system design concepts.