Design Quora
Learn to design a system similar to Quora.
What is Quora?
The illustration below depicts that information-seeking through other people can be more instructive, even if it comes at the cost of additional time.
Seeking information through search engines can lead to dead ends because of content unavailability on a topic. Instead, we can ask questions of others.
Requirements
Let’s understand the functional and non-functional requirements below:
Functional requirements
A user should be able to perform the following functionalities:
- Questions and answers: Users can ask questions and give answers. Questions and answers can include images and videos.
- Upvote/downvote and comment: It is possible for users to upvote, downvote, and comment on answers.
- Search: Users should have a search feature to find questions already asked on the platform by other users.
- Recommendation system: A user can view their feed, which includes topics they’re interested in. The feed can also include questions that need answers or answers that interest the reader. The system should facilitate user discovery with a recommender system.
- Ranking answers: We enhance user experience by ranking answers according to their usefulness. The most helpful answer will be ranked highest and listed at the top.
Non-functional requirements
- Scalability: The system should scale well as the number of features and users grow with time. It means that the performance and usability should not be impacted by an increasing number of users.
- Consistency: The design should ensure that different users’ views of the same content should be consistent. In particular, critical content like questions and answers should be the same for any collection of viewers. However, it is not necessary that all users of Quora see a newly posted question, answer, or comment right away.
- Availability: The system should have high availability. This applies to cases where servers receive a large number of concurrent requests.
- Performance: The system should provide a smooth experience to the user without a noticeable delay.
Design and building blocks
We’ll use the following building blocks for the initial design of Quora:
-
Load balancers will be used to divide the traffic load among the service hosts.
-
Databases are essential for storing all sorts of data, such as user questions and answers, comments, and likes and dislikes. Also, user data will be stored in the databases. We may use different types of databases to store different data.
-
A distributed caching system will be used to store frequently accessed data. We can also use caching to store our view counters for different questions.
-
The blob store will keep images and video files.
Components
The design of Quora will be composed of the following building blocks and components:
- Web and application servers: A typical Quora page is generated by various services. The web and application servers maintain various processes to generate a webpage. The web servers have manager processes and the application servers have worker processes for handling various requests. The manager processes distribute work among the worker processes using a router library. The router library is enqueued with tasks by the manager processes and dequeued by worker processes. Each application server maintains several in-memory queues to handle different user requests. The following illustration provides an abstract view of web and application servers: