A

Guide for your System Design Interview
System design is such a broad topic. To become an expert, you need to read many books, articles, and solve real large scale system design problems.
You can dive into each topic in the appendix of this article if you have time.
A system design interview, however, can be cracked with a systematic approach in a short time.
This article teaches a step-by-step approach to owning your system design interview.
Think of a system design interview as an open-ended discussion in which you'll be expected to work with your interviewer, just as two team members would, to solve a real problem related to the company's goals.
One can hardly be an expert on all the systems listed. And you are not expected to be. Your thought process behind your design choices is more important than the final design.
The shortcut is to familiarize yourself with the topics that system design interview questions may involve and how to approach them. You'll also need to be able to
- methodically explore different directions
- ask the right questions
- understand best practices and common pitfalls of distributed systems

System Design Interview: A Step-by-Step Approach
The system design interview is an open-ended conversation you'll be expected to lead. Try using the following steps to guide your discussion:
Step 1 - Clarify the Goals
Clarifying ambiguities early in the system design interview is critical. For that reason, ensure you understand the basic requirements by asking clarification questions. Start with the most basic assumptions:
- What is the goal of the system?
- Who are the users of the system? What do they need it for? How are they going to use it?
- What are the inputs and outputs of the system?
Even if you're asked about a well-known product, you should still share your assumptions about it with your interviewer. You may find that you and your interviewer don't have the same assumptions about products like Twitter, Pinterest, or Reddit. In addition to helping you focus, it demonstrates product sensibility and good teamwork.
Step 2 - Identify the Use Cases
Now that you understand the system, you should describe the feature set you'll discuss. Try to define all the features and all the components you think of in order of importance to the user. You don't have to get it right on your first attempt, but make sure you and your interviewer agree. Ask clarifying questions, such as:
- Do we want to discuss the end-to-end experience or just the API?
- What clients do we like to support (mobile, web, etc.)?
- Do we require authentication? Analytics? Integrating with existing systems?

Take a few minutes to discuss this with your interviewer, and write it down.
Step 3 - Design for the Right Scale
The same feature set requires a very different approach for different scales. It's essential to determine the scale to know whether your data can fit on one machine or whether you need to scale the reads. You might ask:
- How many requests per second, requests types, data written per second, data read per second?
- What's the average expected response time?
- What is the expected read-to-write ratio?
Different answers require very different designs, so getting the scale right is key to success.
Step 4 - High-level Architecture Design
Start with covering the end-to-end process based on the goals you've established. This might include detailing different clients, APIs, backend services, offline processes, network architecture, and data stores and how they all come together to meet the requirements. Sketch the important components and the connections between them, but don't go into details. Usually, a scalable system includes webserver (load balancer), service (service partition), database (primary/secondary database cluster plug cache). This is also an excellent point to identify the system's entry points, such as:
- User interaction
- External API calls
- Offline processes
This will allow the conversation to drill down into potential performance bottlenecks and decisions about separating responsibilities. Whichever approach you choose to start with, remember to always start simple and iterate.

Step 5 - Component design
For each component, you need to write the specific APIs for each component. You might need to finish the detailed OOD design for a particular function. You might also need to design the database schema for the database.

Tradeoffs
Throughout the process of designing a system, almost every decision will involve a tradeoff. Being able to describe them in real-time, as you're suggesting solutions, shows that you understand that complex systems often require compromises and allow you to demonstrate your knowledge in the pros and cons of different approaches.
A few common examples might include the following:
- What type of database would you use and why?
- What caching solutions are out there? Which would you choose and why?
- What frameworks can we use as infrastructure in your ecosystem of choice?

Practice is Key
While you can definitely hone down the theory by yourself, the last piece of the puzzle is practice.
Make sure to apply these steps time and time again. Check out the hot questions listed below.
It's the combination of knowledge, technique, and practice, that'll enable you to land your dream job.

Products and Systems
The following papers/articles/slides can help you to understand the general design idea of different real products and systems.
- MapReduce: Simplified Data Processing on Large Clusters
- Bigtable: A Distributed Storage System for Structured Data
- The Google File System
- The Chubby lock service for loosely-coupled distributed systems
- Dynamo: Amazon's Highly Available Key-value Store
- Introduction to Memcached
- Cassandra Introduction Features
- Introduction to HBase
- Introduction to MongoDB
- Introduction to Redis
- Storm
- Introduction to Zookeeper
- Kafka
- YouTube Architecture
- Scaling Pinterest
- Google Architecture
- Scaling Twitter
- The WhatsApp Architecture
- Flickr Architecture
- Amazon Architecture
- Stack Overflow Architecture
- Pinterest Architecture
- Tumblr Architecture
- Instagram Architecture
- TripAdvisor Architecture
- Scaling Mailbox
- Salesforce Architecture
- ESPN Architecture
- Uber Architecture
- DropBox Design
- Splunk Architecture

Hot Questions and Reference
There are some good references for each question. The references here are slides and articles.
Design a CDN network
Reference:
Design a Google document system
Reference:
Design a random ID generation system
Reference:
Design a key-value database
Reference:
Design the Facebook news feed function
Reference:
- What are best practices for building something like a News Feed?
- What are the scaling issues to keep in mind while developing a social network feed?
- Activity Feeds Architecture
Design the Facebook timeline function
Reference:
Design a function to return the top k requests during past time interval
Reference:
- Efficient Computation of Frequent and Top-k Elements in Data Streams
- An Optimal Strategy for Monitoring Top-k Queries in Streaming Windows
Design an online multiplayer card game
Reference:
- How to Create an Asynchronous Multiplayer Game
- How to Create an Asynchronous Multiplayer Game Part 2: Saving the Game State to Online Database
- How to Create an Asynchronous Multiplayer Game Part 3: Loading Games from the Database
- How to Create an Asynchronous Multiplayer Game Part 4: Matchmaking
- Real Time Multiplayer in HTML5
Design a graph search function
Reference:
- Building out the infrastructure for Graph Search
- Indexing and ranking in Graph Search
- The natural language interface of Graph Search and Erlang at Facebook
Design a picture sharing system
Reference:
Design a search engine
Reference:
Design a recommendation system
Reference:
Design a tinyurl system
Reference:
Design a garbage collection system
Reference:
Design a scalable web crawling system
Reference:
Design the Facebook chat function
Reference:
Design a trending topic system
Reference:
- Implementing Real-Time Trending Topics With a Distributed Rolling Count Algorithm in Storm
- Early detection of Twitter trends explained
Design a cache system
Reference:
Get one-to-one training from Google Facebook engineers
Top-notch Professionals
Learn from Facebook and Google senior engineers interviewed 100+ candidates.
Most recent interview questions and system design topics gathered from aonecode alumnus.
One-to-one online classes. Get feedbacks from real interviewers.
Customized Private Class
Already a coding expert? - Advance straight to hard interview topics of your interest.
New to the ground? - Develop basic coding skills with your own designated mentor.
Days before interview? - Focus on most important problems in target company question bank.