Geek read: System Design Interview by Alex Xu
Intro
I have always liked designing systems and architectures, and a couple of years ago, I was looking for an interesting resource on systems design — let’s say for some “logic puzzles” in designing systems. Back then, I came across SystemsExpert. It was nice, and it covered interesting patterns and interview questions. After finishing the materials on SystemsExpert, I looked for another resource that covered example system design tasks. This is how I found “System Design Interview” by Alex Xu.
Structure
The system design interview covers 16 different example interview questions (systems to design) on around 270 pages.
The author has a structured way of approaching systems design interview questions. Each system is different, so we are learning completely different approaches and architectural patterns, but going through the following set of steps:
- Understand the problem and establish the design scope
- Propose high-level design and get buy-in
- Design deep dive
- Wrap up
If you would like to get more info on the whole approach, a more detailed description is also available on Xu’s website:
What types of systems to design are covered?
- Rate Limiter
- Consistent Hashing
- Key-value Store
- Unique Id Generator in Distributed Systems
- Url Shortener
- Web Crawler
- Notification System
- News Feed System
- Chat System
- Search Autocomplete System
- Youtube — this chapter is free online here
- Google Drive
What can I learn?
- Scaling from 0 to millions—there is a whole chapter that covers something just perfect for beginners: types of DBs for different systems, types of scaling, database replication, sharding, caching, CDNs, stateless vs. stateful architectures, systems decoupling with queues, and many more. Of course, it’s not a deep dive, but I would love to have this book at the beginning of my career. This chapter is free: check it here.
- Estimation strategies for storage and traffic and getting an intuition regarding latencies. This chapter is free: check it here.
- How to approach such questions and tasks when designing a system with the four-step system described above. This chapter is free: check it here.
- Rate limiting algorithms like token bucket, leaking bucket, fixed window counter, sliding window log, sliding window counter
- Consistent hashing algorithm based on a hash ring and why is it important in a systems
- CAP theorem and related trade-offs. (C vs A)
- Many advanced techniques for designing distributed systems like consistent hashing, versioning, and conflict resolution with vector clocks, Merkle trees, quorum algorithms, and many more
- Types of unique identifiers
- Push vs. Poll communication
- Trie data structure
- How to communicate with the interviewer
- How to communicate clearly design decisions with examples
- How to design all of the mentioned systems in an interview version
All concepts are described in a really clear way. However, you might need to dig deeper and look for extra resources for the harder concepts. Especially in the chapter about building key-value stores, which covers hard topics like consistency, versioning & conflict resolutions, quorums, data replication, and so on in less than 25 pages.
URL Shortener Workshop & Why This Book Matters
Last month, at AWS User Group Wrocław, I was one of the helpers in a system design workshop organized by our fellow Lambda People. During the workshop, teams were challenged to build a URL shortener based on AWS. There were a couple of tasks, and new requirements were coming with every task, so obviously, designed systems were getting more complicated.
Extra Tasks
Task 1: Scanning
URL must be scanned in order to be used.Task 2: Domain Blocking
Ability to block redirection to specific domains or links containing keywords.Task 3: Mails
Sending mails to author or URL.Task 4: Link Tracking
Track the number of times shortened links are opened.Task 5: Link Expiration Time
Set a time limit for shortened links to be active.
It was a nice and fun experience, but it showed me that this book is important. It provides some methodology and structure for approaching these kinds of challenges. It is especially important to get started, get buy-in, and TALK. That was the biggest blocker I saw. Collecting requirements and transforming them into an actual system is a critical part of systems design.
URL Shortener seems easy, right? Think about how you would solve it for a second. There are plenty of different approaches.
“Architecture is the business of trade-offs”
- Gregor Hohpe
Okay. Have you considered what it means that the link is short? How short link is considered a short one? How can we shorten that link? What are different approaches, and what are their pros & cons? How do we avoid/deal with collisions? What are the implications? There are many things to consider in each system design task, even as simple as this one.
Only some engineers have a chance to design systems every day at work, and even if they do, they do not design all kinds of systems. This book is a great companion for starting or pushing ourselves to think about potential solutions for many different types of systems. It is just a brain exercise.
Summary
This is a great read for engineers on all levels.
If you are a junior or mid-level engineer, it is a must-read, and that’s it — end of story. It is less than 300 pages long and has many diagrams and tables. You will learn a lot. It is not a big investment, money or time-wise. There are no excuses.
For more senior engineers, it will be a great read. Even assuming that you know everything described by the author in the book, there is a huge value in facing some of those design questions. Most probably, you have never faced building all types of systems covered. You can improve your back-of-the-envelope estimation skills and brainstorm about building each type of architecture. If you are a super-brainiac, you can even think about a design that will optimize different system features, such as reliability, high availability, cost, performance, or something else. Apart from that, there are usually extra questions that could be discussed with an interviewer.
Where can I get it?
You can read it online by buying access on the author’s website:
You can buy paper book on Amazon (my preference):