Table of Contents[Hide][Show]
- 1. What do you mean by system design?
- 2. What are the most important characteristics of a system designer?
- 3. What exactly is the CAP theorem?
- 4. What do you understand by load balancing?
- 5. What is the difference between asynchronous programming and parallel programming?
- 6. What is the difference between horizontal and vertical scaling?
- 7. What exactly do you mean by latency, throughput, and system availability?
- 8. What are ACID properties?
- 9. What exactly is sharding?
- 10. What is CDN?
- 11. Why use CDN?
- 12. What is the difference between sharding and partitioning?
- 13. What exactly is caching?
- 14. What are CDN edge servers?
- 15. What are the different Consistency patterns for system design?
- 16. What do you mean by optimistic locking?
- 17. What exactly do you mean by "leader election"?
- 18. What’s your approach for designing a TinyURL-like URL shortening service?
- 19. What’s your approach to designing twitter?
- 20. Create the newsfeed system for Facebook
- 21. What is a system's BASE property?
- 22. What Is Load Balancing With IP Address Affinity Technique?
- 23. What exactly are Cache Replacement (or Eviction Policy) algorithms?
- 24. What exactly do you mean by distributed transaction?
- 25. What exactly is starvation?
Before you begin, we recommend reading our introductory guide on System Design to refresh your fundamental knowledge.
When interviewing for a position that requires system design knowledge, you have the chance to talk about your background and demonstrate your ability to develop complicated systems.
When speaking with a potential employer, the way you express your expertise might assist you to demonstrate that you are a competent candidate for the position.
You can prepare for your job interview by learning basic design concepts and thinking about how you will respond to inquiries about them. We’ll go over some typical system design interview questions and answers in this post to help you prepare for your next interview.
1. What do you mean by system design?
The process of establishing system characteristics including modules, architecture, components, and their interfaces, and data based on predetermined criteria is known as system design.
It is the process of defining, creating, and designing systems to meet a company’s or organization’s specific goals and objectives. System design is more about system analysis, architectural patterns, APIs, design patterns, and gluing it all together than it is about coding.
2. What are the most important characteristics of a system designer?
- User interaction
- External API call
- Offline processes
3. What exactly is the CAP theorem?
According to the CAP (Consistency-Availability-Partition Tolerance) theorem, a distributed system cannot ensure C, A, and P all at the same time. It can only deliver two of the three assurances at most. Let’s use a distributed database system to assist us to comprehend this.
- Consistency: This specifies that data must stay consistent once a database transaction is completed. For example, all queries should return the same response after a database update.
- Availability: The databases must be available and responsive at all times.
- Partition Tolerance: Even if communication becomes problematic, the database system should continue to work.
4. What do you understand by load balancing?
Load balancing is the process of efficiently dispersing incoming traffic among a set of backend servers. These are referred to as server pools. Modern websites are built to handle millions of queries from customers and respond to them quickly and reliably. More servers will be needed to handle these demands.
In this case, it’s critical to divide request traffic efficiently among each server to avoid overburdening them. The load balancer functions as a traffic cop, intercepting requests and routing them among available servers so that no one server is overburdened, potentially degrading application performance.
5. What is the difference between asynchronous programming and parallel programming?
When you run anything asynchronously, it implies you don’t have to wait for it to finish before you can go on to something else. Parallelism refers to the simultaneous execution of many tasks.
When you can break jobs into different chunks of labor, parallelism works effectively. Async and Callbacks are a means (tool or mechanism) to represent concurrency, i.e. a group of entities that could communicate and share resources.
6. What is the difference between horizontal and vertical scaling?
The addition of new computing equipment to a network that spreads the processing and memory demand across a dispersed network of devices is referred to as horizontal scaling. Simply said, new server instances are added to the current pool, and the traffic load is efficiently spread between these devices.
Vertical scaling refers to the notion of expanding a single computer’s resource capacity by adding RAM, efficient CPUs, or migrating to a new machine with higher capacity. The server’s functionality can be increased without requiring any programming changes.
7. What exactly do you mean by latency, throughput, and system availability?
Performance is an essential aspect of system design since it contributes to the speed and reliability of our services. The three most important performance measures are as follows:
- The time it takes to deliver a single message in milliseconds is called latency.
- The amount of data successfully transferred through a system in a particular period of time is referred to as throughput. Bits per second are used to measure it.
- The amount of time a system is available to react to queries is defined by its availability. System Uptime / (System Uptime+Downtime) is the formula for calculating it.
8. What are ACID properties?
- Atomicity: It assures that database alterations are either all or none.
- Consistency: Data values in the database are consistent.
- Isolation: It refers to the separation of two transactions.
- Durability: Data is preserved even if the server fails.
9. What exactly is sharding?
Sharding is the technique of dividing a huge logical dataset into many databases. It also refers to horizontal data splitting because the data will be stored on several computers. As a result, a shared database can handle more queries than a single huge computer.
10. What is CDN?
11. Why use CDN?
- Considering static resources make up around 80% of a website, adopting a CDN reduces the strain on the origin server significantly.
- As there is less distance to travel, information will be provided faster to website owners who have visitors from many geographic areas.
- Users of CDNs also benefit from the capacity to quickly scale up and down in response to traffic surges.
12. What is the difference between sharding and partitioning?
Database Sharding – Database sharding is a method of partitioning a single dataset into numerous databases so that it can be stored on different workstations. Larger datasets can be broken into smaller chunks and stored in several data nodes, increasing the total storage capacity of the system.
By spreading the data across many machines, a shared database can handle more queries than a single system.
Database Partitioning is the process of dividing stored database objects (tables, indexes, and views) into separate pieces. To increase controllability, performance, and availability, large database objects are partitioned.
In some cases, partitioning can improve speed when accessing partitioned data. Partitioning can reduce index size and increase the chance of locating the most needed indexes in memory by acting as a leading column in indexes.
13. What exactly is caching?
Caching is the technique of keeping file copies in a temporary storage area known as a cache, which speeds up data access and reduces site latency. Only a certain amount of data can be stored in the cache.
As a result, determining cache update techniques that are most suited for the business objectives is critical.
14. What are CDN edge servers?
The CDN servers that cache material acquired from your origin server or storage cluster are known as edge servers. Point of presence is a term that is frequently used to describe edge servers (POP).
The edge servers are physically positioned at a POP. At that POP, information might be cached by many edge servers.
The ability to provide sections of a website from several places reduces the distance between the visitor and the web server, resulting in lower latency. CDN edge servers accomplish this precise goal.
15. What are the different Consistency patterns for system design?
Every read request should retrieve the most recently written data, according to the CAP theorem. When many data copies are accessible, synchronizing them so that customers receive fresh data on a continuous basis becomes a difficulty. The following are the possible consistency patterns:
- Weak consistency: Following a data write, the read request may or may not be able to obtain the updated data. This level of stability is ideal for real-time applications such as VoIP, video chat, and multiplayer gaming.
- Eventual consistency: Reads will eventually view the most recent data within milliseconds after the data is written. The data is duplicated asynchronously in this case. DNS and email systems are examples of this. This works effectively in systems with high availability.
- Strong consistency: Following a data write, future readers will view the most recent data. The data is copied synchronously in this case. This can be observed in RDBMS and file systems, which are appropriate for data transfers.
16. What do you mean by optimistic locking?
Optimistic locking is a mechanism in which you read a record, note a version number (alternative ways include dates, timestamps, or checksums/hashes), and then double-check that the version hasn’t changed before writing it back.
When you write the record back, you use the version to filter the update to ensure it’s atomic. (i.e., hasn’t been changed between when you check the version and when you write the record to the disk) and update it all at once.
17. What exactly do you mean by “leader election”?
In a distributed system with numerous servers contributing to the application’s availability, there can be times when only one server is responsible for updating third-party APIs, as multiple servers might cause issues when utilizing the APIs.
This server is known as the primary server, and the procedure for selecting it is known as leader election. When the leader server fails in a distributed system, the servers must notice the failure and pick a new leader. Using a consensus technique, this approach is best suited for high availability and strong consistency applications.
18. What’s your approach for designing a TinyURL-like URL shortening service?
TinyURL transforms a long URL into a single, unique short URL. These technologies can also accept a short URL and return the complete URL.
What are some of the crucial qualities?
- Make a URL that is shorter than the original.
- Keep the longer URL and replace it with the shorter one.
- Allow for redirection in short URLs.
- Short URLs with custom names are supported.
- Handle several inquiries at once.
What are the most prevalent problems?
- How do you keep track of database storage?
- What happens if the user load exceeds expectations?
- What if two persons use the same custom URL?
Consider the following suggestions:
- Hashing is a notion that can be used to connect old and new URLs.
- REST API can be used to handle front-end communication and balance the heavy load.
- Multithreading is a notion that allows you to handle several requests at once.
- Original URLs are stored in NoSQL databases.
19. What’s your approach to designing twitter?
- Sending tweets
- Following other users
- Tweet feed/newsfeed
- System is scalable
- Loads quickly
- System is reliable
You can start thinking up your Twitter API design when you’ve established the criteria. This is how it would appear:
To begin, we’ll sketch up the API’s key endpoints. Here are a few examples:
The architecture that will enable these characteristics can then be sketched out. We can begin with the user who submits a server request. We can install additional API servers behind a load balancer to assist route bigger traffic levels to fulfill the scalability need. We’ll need to add a database to store our tweets now.
It’s important to remember that the API we provide should be scalable. To make this service scalable, we can have one of our API servers read from a separate cache for our newsfeed. While doing so, we should also use a feed provider to keep our feed cache up to date.
20. Create the newsfeed system for Facebook
The newsfeed on Facebook allows users to see what is going on in their friends’ circles, favorite pages, and organizations they have followed.
What are some of the essential characteristics?
- Create a newsfeed based on posts from other system entities the user follows.
- Text, pictures, audio, and video can all be used in Newsfeed postings.
- In real-time, add fresh content to the user’s newsfeed.
What are some of the most common issues?
- What if the new post takes a long time to appear in the news feed?
- Can the algorithm manage a spike in user activity?
- What posts should be displayed first in the news feed?
Consider the following suggestions:
- Examine the fanout mechanism for distributing posts to followers.
- Examine how sharding can be used to efficiently handle high user loads.
- A user’s feed data should not be duplicated across numerous servers. Sharding can instead be done based on user IDs.
21. What is a system’s BASE property?
The BASE features are ubiquitous in NoSQL databases that have recently emerged. A BASE system does not provide consistency, according to the CAP theorem. This is a made-up acronym that corresponds to the CAP theorem’s following property of a system:
- The term “basically available” means that the system will be available at all times.
- A soft state means that the system’s state can vary over time, even if no input is provided. This is due mostly to the model’s eventual consistency.
- Given that the system does not receive input during that period, eventual consistency means that the system will become consistent over time.
22. What Is Load Balancing With IP Address Affinity Technique?
Another prominent method of load balancing is IP address affinity. The client IP address is connected with a server node in this method. One server node handles all requests from a client IP address.
This method is simple to implement since the IP address is always accessible in the HTTP request header and no further settings are required. If your clients are likely to have cookies deactivated, this form of load balancing can be advantageous.
23. What exactly are Cache Replacement (or Eviction Policy) algorithms?
Cache algorithms (also known as cache replacement algorithms, cache replacement policies, or cache eviction policies) are optimization instructions, or algorithms, that a computer program or a hardware-maintained structure can use to manage a cache of data stored on the computer.
Caching boosts speed by storing recently used or often accessed data in memory regions that are quicker or less expensive to access than traditional memory storage. When the cache is full, the algorithm must decide which items to remove in order to make a place for new ones.
24. What exactly do you mean by distributed transaction?
A distributed transaction is any circumstance in which a single event causes the alteration of two or more distinct sources of data that cannot be committed atomically.
It becomes much more complicated in the world of microservices since each service is a unit of work, and most of the time numerous services must collaborate to make a business successful.
25. What exactly is starvation?
When a thread is unable to acquire regular access to shared resources, it is said to be starving. This occurs when “greedy” threads or threads with higher “priority” make shared resources inaccessible for lengthy periods of time.
Consider an object that provides a synchronized method that frequently returns late. If one thread repeatedly calls this method, other threads that require frequent synchronized access to the same object will be often blocked.
A brainstorming session is all that the system design interview entails. We’ve addressed the most common System Design interview questions in this post.
A comprehensive grasp of the method you are taking when creating a specific system is critical to passing a System Design interview.