Tips/Approach to tackle System Design
Introduction to System Design
The aim of this blog is to explain why companies ask system design question during the interviews. How you as an interviewee could tackle such a broad topic and tips on becoming a better software architech in general if you are currently designing a system.
Following topics are covered in detail in this blog. Feel free to skip to any topic you would like to read in detail.
- Need for System Design in Interview.
- How to tackle System Design if you are a complete beginner.
- Structure of System Design.
- General tips to keep in mind during the interview.
- Common system design topics to read
Need for System Design in an Interview
If you are a software engineer with more than 2 years of experience then you are probably interacting with the different components of technology stack on day to day basis. For example, interacting with the database, storing information to the cache, etc. You are probably aware of most of the components within the architecture.
Companies expect candidate to have a high level understanding of this components. Knowing about most of the components means that the candidate would take less time getting use to current company stack and delivering production quality code. Also, in real world scenario you would be designing services for the company and have to discuss about various decisions with your co-workers. System design gives a better idea about how would you communicate with your potential co workers while solving a problem.
How to tackle System Design if you are a complete beginner.
Honestly, Being good at designing system needs knowledge about broad range of topics. The skill develops with experience, once you deal with different systems over the course of 7-10 years.
But you don’t have to wait so many years to have a basic understanding of system design. You can accelerate your understanding process by knowing about the core components like load balancer, gateways, protocols, databases, etc and knowing at least one technology behind the scenes implementing these core components and being able to talk about it in detail.
Maybe you already know about technologies like relational database SQL, non-relational database NoSQL, cloud storage options like blob storage, etc. The key is to fill in the missing information and learn about few topics that you don’t have much idea about and having a good understanding about one technology implementing that idea.
The next section explains general structure you should follow during an interview. Keep in mind take the next section as grain of salt since the interviewer could have completely different expectation regarding system design or wants to focus more on specific topic. The topic below gives a good framework that I have experienced with and talked about with other senior engineers about system design interview expectation.
General structure of System Design Interview
Phase 1 : Requirement gathering and end user expectation.
Generally system design questions are vague and does not include all the necessary details about the expectation of how the system is going to be used by end user. This is a good time to take a step back from all the complicated components and technologies that you already know about and think from the end user’s perspective.
For example given a question: Design a messenger system like facebook messenger
Some key questions that you could ask are:
- Is the end user going to only send private one-on-one message or is this also going to be used for group chat?
- What is the volume of end user or how many messages per second we need to process?
- Are users able to send media like photos/videos through the messenger?
Asking this sort of questions to the interviewer could help you in expectation setting. It could give you a hint on what the interviewer is expecting. It would give the interviewer a hint that the candidate is thinking deeply about the scalability and usability of the system.
Phase 2 : Decide on few features you would need to support
After the previous phase of asking questions write down 3-4 core functionality that your system is going to support.
For example:
- Sending and receiving 1-to-1 private message
- Sending a media like picture
- Sending a group message
- Checking for message sent, received and read functionality
Phase 3 : Draw a high level diagram.
- User
- Load balancing layer
- Server layer
- Cache Layer
- Database layer
Don’t go into much detail about a specific topic in detail. Just mention few key points why you are taking certain decisions. Like going with the Relational database since the system is write heavy. You don’t have to mention a particular technology.
Phase 4 : Talk about the database schema or the Api
If you are going with the relational database then draw at least user table, conversation table, etc. Define the rows that would be present in the schema and any constrains that you would have on certain columns.
You can also define how REST Api between two components in the system could look like. What headers, protocols you are planning to use. How can the end user make a call to one of the Api.
Phase 5 : Dive deeper into certain component.
At this point you could ask the interviewer what specific topic he/she would like you to focus on and dive deeper into.
Mostly at this point there would be questions regarding the edge cases and providing optimizations for the current system that you have drawn. You could start diving deeper into making the current system more reliable and improving the end user experience. For example suggesting to have CDN layer so that the user can access the content faster,etc.
General tips to keep in mind during system design
- System design is not a monologue, it’s a collaborative interview. You should be talking about 70%-80% of the time and rest should be feedback and conversation from the interviewer. Always take a pause after making a point or completing a single layer.
- Think about the problem from end user’s perspective to better form features that you are going to talk about and the considerations you are going to make.
- Don’t have a set architecture in mind. If you try to forcibly fit an architecture for some other system it’s not going to work. You need to be flexible according to the requirement of the system.
- Take advantage of visual aids like whiteboard and try to name things in your systems. Like server names could be N1,N2 and N3. It would make easier to convey your thoughts to the interviewer. It’s similar to programming where it’s a good practice to have well defined variable names.
- Be aware of current technologies. Read about system design of current big tech companies and startups. They usually have a marketing blog about their current tech stack. Talk to people and senior devs at tech conferences about their system design approach for solving a particular problem.
Common System Design Topics To Read
- Design a messenger system.
- Design a url shortner system.
- Design a social media system(Twitter).
- Design a cab booking system(Uber/Lyft).
- Design a parking lot system.
- Design a hotel room booking system.