Friday, April 26, 2024

How To Prepare For Low Level Design Interview

Don't Miss

Example Question : Design Youtube

How to crack LLD (Low Level Design) Interview? | OOD & Design Patterns | GeeksforGeeks

View the full answer to how to “Design YouTube” here.

“How would you design a large-scale, distributed system and video-sharing platform such as YouTube?”

Note that an interviewer asking such a question is not expecting a truly complete answer. YouTube today is obviously an incredibly complex system. Keep it simple. These system design questions are ultimately looking to see if you can:

  • Pull together a small set of requirements from an ambiguous question.
  • Define a minimum viable product according to these basic requirements.
  • Produce a high-level architecture with all the components necessary to implement your design.
  • Discuss the tradeoffs between components and algorithms, and explain your choices.
  • Provide an additional level of detail on any given component or design decision depending on where your interviewer wants to deep-dive.
  • How Would You Design An Api

    APIs are kind of like the bridges that connect the roads of major software products. As a result, they are a central part of the system design of major apps like Instagram, YouTube, Twitter, etc.

    Lets say you were asked, very broadly, to design an API for a website. Here are some examples of how you could go about this:

    Ask clarifying questions

    • Define how the API will be accessed by users
    • Consider the provider side of the API and the services/databases that will be accessible

    Drill down on your design

    • Should an API gateway be used to improve security?
    • Will there be an authentication process to access the API?
    • Will you use a REST API or something different?

    Bring it all together

    • Does your API meet all of the original requirements? Are there any additional considerations, or areas that could use further refinement?

    To learn more about API design, check out this mock interview from Exponent, on designing the Twitter API:

    Summarize And Answer Questions

    Last but not least is the final step of your system design interview answer. This concluding step will consist of, once more, reviewing the system requirements and summarizing and justifying all the design decisions you made along the way.

    Be sure to thoroughly explain why you think these decisions are the most prudent regarding their tradeoffs. Don’t forget to mention possible alternatives you could have taken along with their tradeoffs.

    It is likely your interviewer will also ask you questions about aspects of your design here.

    Recommended Reading: What To Say In An Exit Interview

    Data Processing And Storage

    It should come as no surprise that you’ll need access to a massive amount of storage space to build a crawler capable of crawling the entire web.

    For a rough estimate, let’s do some quick math: If the average size of a crawled webpage is, let’s say, 200 KB, and our web crawler was to store 1 million, or 10^6, pages, we’d need 2 terabytes worth of storage.

    Now, that’s conservatively speaking. Today, there are more than a billion pages on the modern web.

    If each page was 200 KB, that would be 0.2 petabytes of data. So long story short, our crawler will need a lot of space. However, deciding on our storage system depends on how we plan to use our web crawler.

    For instance, let’s say we were building our web crawler to download and store web content to archive offline.

    In this case, we’d need to compress and store our crawled contents, and we could do so with cloud storage.

    However, suppose we were building our web crawler for searches in real-time. In that case, we may find that a distributed system would be better served for search and querying.

    Regardless, the amount of data necessary makes it impractical to store in memory. So instead, the memory will need to be continuously uploaded to a storage system. If not, the web crawler will run out of usable memory as it executes.

    This is known as an “ETL” approach or “extract, transform, load.”

    Lld Or Low Level System Design

    GitHub

    LLD is about coming up with the class diagrams, methods, the relations between classes, program specifications and other low level details for a given system. In these type of interviews, a candidate is expected to create a modular, flexible and reusable design for software by using Object Oriented Design Principles and Design Patterns. Some popular questions are: Design a Parking Lot, Design a Banking Management System etc.

    You May Like: How To Interview A Realtor

    General Problem Statement And Overview

    The initial introduction to the interview usually goes for a few minutes, during which you will introduce yourselves, and the interviewer will give you your question.

    Your goal here is to listen closely to understand the problem being presented. The question will either be a high-level design question or a lower-level design of a frontend component. The question will likely relate somehow to the product the company builds. Or a specific highly used component within the product. So doing some initial practice runs using the companys product you are applying for can help get you in the right frame of mind before the interview.

    How would you go about designing the frontend of a chat application like Slack?

    How would you build the frontend of a photo sharing application like Instagram?

    How would you go about designing an infinite scrolling newsfeed?

    How would you design a combobox / typeahead component ?

    What To Expect In The Interview

    Now we have a good idea of what interviewers are looking for when running these interviews and what to avoid. Lets switch our attention to the interview itself.

    Most frontend system design interviews will be centered around either a high-level design question, like how would you go about building instagram?, or a lower-level design question, like how would you go about designing and infinitely scrolling newsfeed?

    Generally, the format for a one-hour interview will look roughly something like this:

    • Initial intro and question ~ 5 minutes
    • Understanding the problem and requirements gathering ~ 5 minutes
    • The design phase ~ 25 minutes
    • Optimizations, adaptability, deep dive questions. ~ 20 minutes
    • Ad-hoc questions. ~ 5 minutes

    As you move through the interview stages outlined below, youll want to be aware of both the amount of time spent in one section and the concrete design artifacts you need to create for each section.

    You May Like: Google Cloud Platform Interview Questions

    Tell Me About Some Of The Code Writing Best Practices For Low

    With a complex code, there are higher chances of vulnerability to errors. Certain code quality standards, if implemented, reduce the risk of potential errors and project failures. Interviewers may like to test your knowledge about coding standards in the development of software programs. Emphasise the importance of structure, readability and cleanliness in your answer.

    Example: “While writing code for LLD, it is necessary to writewell-structured code whilefollowingclean coding practices for classes and methods. It is important that instead of trying to fit design patterns into the code forcefully, we check if it is possible to naturally solve a given problem using any available design pattern. Another best practice of writing code is to make it simple and readable, as complex code is prone to errors.”

    Related: 40 Design Pattern Interview Questions

    Is It Necessary To Use Multi

    Introduction – Low Level Design | Coding Interview Series | The Code Mate

    Its often noticed that the interviewer generally asks the candidate to make the design multi-threaded. This is generally asked towards the end of the interview. The interviewer is trying to gauge how well you can apply concurrency constructs to a problem.

    The primary goal of multi-threading is to use resources efficiently. You need to identify how you can break your code into independent tasks. You should revise concurrency concepts before the interview.

    Lets say you are developing the backend of a Movie Booking system. You are handling the successful booking of tickets. In such a case, the system would perform multiple operations. It would first update the database and then send a notification to the user.

    If you closely observe, these two tasks are independent. The second task doesnt need to wait for the first task to complete. So, two threads can be launched. The first thread will perform an database update and the second thread you manage notification. Thus, we have achieved parallelism and have used resources efficiently.

    Recommended Reading: How To Ace Your First Job Interview

    How To Prepare For System Design Interviews

    As you can see from the complex questions above, there is a lot of ground to cover when it comes to system design interview preparation. So its best to take a systematic approach to make the most of your practice time, and we recommend the three steps below.

    For extra tips and resources, take a look at our system design interview prep guide and our list of 19 system design interview tips from ex-interviewers.

    Example Project From My Resume:

    Built a timetable management system in Flask. The students and faculty can visualize their timetable, check for clashing courses as well as add their timetable to Google Calendar. Used pytest for unit testing. Travis builds and tests each commit to the GitHub repository. If the tests pass, it pushes the docker image to dockerhub and deploys the application to Heroku. Also setup ELK stack for monitoring and logging.

    You May Like: Entry Level Engineering Interview Questions

    Optimizations Deep Dives And Adaptability Questions

    Alrighty, were in the final stages of the interview now. Lets finish strong.

    In this phase the interview will usually switch to a phase where the interviewer asks more probing questions. They will typically end up being how you would adapt the design to meet a new set requirements. Either functional, like how would we go about supporting real time collaboration? or non-functional, like how would we go about supporting 100x more data for larger customers?.

    This is a good chance to demonstrate your technical depth on a particular subject and your adaptability. Theres no hard and fast rules here. What you discuss will depend on what the interviewer wants to probe more on. But its very likely the topic of frontend performance will come up. So youll want a solid understanding of performance fundamentals if you lack real experience in this area, to ensure you can discus this aspect in depth.

    Here are some example questions you might expect to see in this phase of the interview:

    A customer has raised a support ticket about bad performance and you are tasked to investigate, what do you do ?

    Similar to the initial question they will usually be open ended to see how you take an ambiguous problem statement and drive towards a solution. In this case theyre looking for general debugging ability and performance knowledge. Which can roughly be broken down to:

  • Reproducing reliably.
  • Identifying the root cause.
  • To recap this phase of the interview

    How To Solve Low

    GitHub

    Solving an LLD problem in an interview can be done easily if we divide the solution into multiple stages and focus on solving these stages one by one. LLD problems can be broadly categorized into 2 types: Standalone applications, and web applications.

    Solving an LLD problem can be divided into mainly 3 stages:

    1. Clarify & Gather Requirements: The low-level design interview questions are intentionally open-ended/ unstructured similar to real-life conditions. Ask the relevant questions regarding the problem and gather the complete requirements of the system. Don’t assume anything beforehand and always clarify with the interview the assumptions you want to take. Write down the requirements & assumptions and discuss them with the interviewer.

    3. Code: Finally once the thoughts are structured using Class Diagram, Use Case Diagram, and Schema Diagram , the Candidate can start writing the code. Apply the Design Patterns, Object-Oriented Principles & SOLID Principles wherever is possible to make the system reusable, extensible, and maintainable. Make sure the code is well structured and follow the clean coding practices to make the classes and method clean. Don’t try to fit design patterns to code but check if a given problem can be solved using any available design pattern. Take care of the readability of code while taking care of all of the above. Yes, software engineering is hard.

    Also Check: What Do I Need For An Interview

    My Preparation Strategy For System Design Interviews With Silicon Valley Companies

    In software engineering, system design defines the components, modules, interfaces, and data for a system to meet specified requirements. Most companies do not ask system design to freshers. However, when I was interviewing for a Full-Time Software Engineer role, a few companies had system design interview rounds.

    In this blog post, I will talk about the various type of system design interviews and how I prepared for them.

    Low Level System Design

    • Step by step approach to solve the low level system design question.
    • How to ask clarification questions in interview.
    • How to identify the objects and relations form the requirement.
    • How to draw class diagram from the requirement.
    • How to implement classes using the class diagram.
    • Where to focus on low level system design interview.
    • How to tackle the low level system design in real interviews

    You May Like: How To Prepare For An Accounting Interview

    Guidelines For High Level Designs

    As you being to design solutions to use-cases its helpful to be constantly asking – what is the user trying to do here? to help frame your solution. Asking this helps prevent creating solutions to problems that arent relevant and helps you stay focussed on driving a solution forward that keeps things simple.

    As you practice on real examples its good to keep things simple. No need to over-complicate things. The majority of times solutions wont be ground breaking new designs. A good enough solution is one where it solves the specific use-case in front of you, and you have analyzed its trade-offs and called out any potential limitations. This is much better than an over-engineered solution that attempts to solve everything at once.

    It can be helpful to apply different lenses to look at the problem from different view points. Especially if you get stuck or not sure how to move things forward. Switching lenses can help you enumerate different potential solutions and considerations that apply to your solution.

    The users viewpoint

    Thinking in terms of how the user will actually use the system, and being able to visualize that, can help uncover edge cases and different user experiences you may need to take into consideration.

    For example when navigating away from an infinite scrolling list, when the user comes back would they expect the scroll position to be in the same spot of the list when they went back?

    The architects viewpoint

    The maintainers viewpoint

    How Would You Design A Social Media App

    Low-Level System Design of a Cache – Mock Interview

    For this question you’ll typically be asked to design a specific app, such as Twitter, Instagram, etc. For this example, well assume the interviewer asked you to design Twitter. Here are some considerations for answering this question:

    Ask clarifying questions

    • Is the interviewer looking for a design of the core features, or a high-level overview of the whole service?
    • What are the constraints of the system?
    • What are your assumptions?

    Design high-level

    • Back-of-the-envelope calculations: average KBs per tweet, size of new tweet content per month, read requests and tweets per second, etc.
    • High-level components: write, read, and search APIs types of databases SQL vs NoSQL etc

    Drill down on your design

    • Potential bottlenecks: adding a load balancer with multiple web servers, scalability issues, fanout service slowing down tweets and @replies, etc.
    • Components that you could dive into: how a user views the home timeline or posts a tweet, the intricacies of the database design, etc.

    Bring it all together

    • Consider: does the final design address the bottlenecks youve identified? Does it meet the goals you discussed at the beginning of the interview? Do you have any questions for the interviewer?

    For a full answer to this question, take a look at the video guide below from Success In Tech or this text guide from donnemartin on GitHub.

    Recommended Reading: How To Create A Presentation For An Interview

    Questions About Experience And Background

    Here are 12 questions you may encounter regarding specific details in your work history and educational qualifications:

  • Tell me about your background in software development.

  • Outline your experience in system design.

  • Which object-oriented languages do you know?

  • Which technologies do you have experience using in your past roles?

  • What is your process for reviewing code that another person wrote?

  • Tell me about a recent project you worked on.

  • Which design patterns do you use most often?

  • Describe an object-oriented system you designed successfully.

  • Describe a difficult bug you fixed in a large application.

  • How do you ensure quality and fix errors?

  • What were your responsibilities in your previous position?

  • What project management tools are most useful in your role as a software engineer/developer?

  • Related:

    Make Use Of Parallelization

    Finally, we can use parallelization to ensure that the web crawler is efficient and reliable.

    This means that we design our processes to work in tandem with one another. There are a few ways to do this:

    • Implement the crawler with a multi-threaded or asynchronous approach
    • Run multiple instances of the crawler as different processes on a single machine
    • Run multiple machines that share a job queue

    You’re not limited here to just one choice. If anything, it’d be best to use all three to achieve the best result.

    You May Like: How To Prepare For A Star Interview

    Tips And Strategies For Cracking Lld Interview

    Low-level Design rounds have become an integral part of the Tech hiring process. Few companies call it the Pair Programming round or Machine Coding round. Most of the companies ask open-ended questions like Design a Vending Machine in this round.

    I have seen many candidates getting confused between High-level Design and Low-level Design rounds. Once I asked a candidate about an LLD problem, and they started attacking it as an HLD problem. Its important to know the distinction and communicate during the interview.

    HLD rounds assess an individuals ability to design high-level components and scale the system. Whereas LLD gives insights into how well a candidate can model the software.

    In this article, Ill share the necessity of the LLD round and its importance. Ill also cover the necessary skills, strategies, and resources to crack the LLD interviews.

    Candidates spend hours grinding Leetcode and memorizing common data structure problems. Additionally, they also dedicate time for System design and Behavioral interviews. Most of you may ask Why one more round? Is it needed? Isnt it overburdening and burning out the candidates?

    Its important to take software maintainability into account while developing any feature. The written code will be managed by other members of the team. Code readability and understandability play a significant role in the process.

    Sequence diagram for Movie Booking System

    Following is a sample Activity diagram of a Movie Booking system:

    More articles

    Popular Articles