No design is good or bad, it’s just about the fulfillment of the requirement in optimized way
If you have been asked or preparing for system design interviews and looking for perfect system design for food delivery app or service then find out what perfect means for you. So, as the first part of any system design process, we’ll proceed to find what this service or app must perform.
Step 1: Requirement Gathering
So a basic food delivery service should have these features-
- Restaurant Listing and Search – Users can search for a restaurant
- Food Listing and Search – Can search for foods in the restaurant
- Order and Payment – Can order food and make payment
- Delivery – Can track the delivery
Now based on the requirements we are having, let’s try to find out the users involved-
- Back-end Service Agent – For restaurant listing
- Restaurant Owners – Food Listing
- Customers – Ordering
- Delivery Executive – Delivery of food
Now that we found our end users and also the services we are offering. Let’s try to design the architecture to fulfill it-
Here we have our Service to handle all the requirements and MySQL as database. Its the simplest System design anyone can think of for this type of app.
Is there anything wrong here? No This can serve our needs but what will happen if we grow? Millions of orders? at that point, our system will not able to scale.
So, to design a system we must find out the scalability required, for 10 orders per day our above system is very good. It is a wrong practice to design the above system without having scalability considerations.
So, let’s dive into the next step-
2. Understanding Scalability requirement
This understanding helps us decide how to break our service, which database to use, and other requirements.
For this, we should think of these questions-
What will be the geographical scaling i.e. is this app for the purpose of serving only a city or in future the vision is to grow globally? – Let’s assume it is planned Globally
How many Customers are we expecting in the short and long term? – 1 billion
How many Restaurants? – 1 million
How many searches and orders a day? – 1 billion searches and 2 million orders a day can go up to 5 million a day
Based on all of these we can calculate which all components are critical and required to have isolated responsibility?
From the above figures, we get to understand that we must build a scalable application that can handle a huge customer base and must make the restaurant searchable and must separate out the order processing service as traffic can vary.