List functional requirements for the system (Ask the chat bot for hints if stuck.)...
2) Product Mangemetn- Allow admin to add or delte product
3) Inventory Mangemetn-Real time tracking of products
4) Concurrency and fairness : Rate Limiting and queing mechanics to fairly allocate products to the users.
5) Performance monitoring: Tools to monitor system performance and health during sales and bottle neck
List non-functional requirements for the system...
1) System should be highly scalable
2) System should be fault tolorent
3) System should have low latency
These non functional requirements are very essential in a flash sale system as voilating a single can cause huge loss to the organization
Estimate the scale of the system you are going to design...
Total number of registered users 500,000
Peak concurrent Users during flash sale 50,000
As only 5-10 % of the customers will make it to the checkout approximately 2500 -5000
Define what APIs are expected from the system...
/v1/admin/products - This api is used to update the count of the list of products.
Request Body
{
List of products
}
/v1/admin/products - This api is used to get all the products which are present
As the main goal of the system is handle many concurrent users so we will not be sticking with user registration
Defining the system data model early on will clarify how data will flow among different components of the system. Also you could draw an ER diagram using the diagramming tool to enhance your design...
For storing the count of the items which are part of flash sale we will be storing those in redis database as key value pair where key will be the product name and the value will be the count of the product.
For items which are not the part of flash sale we will be storing them in the sql database as the system is read heavy and and the sql databases provide us acid guarantees which nosql does not provide.
You should identify enough components that are needed to solve the actual problem from end to end. Also remember to draw a block diagram using the diagramming tool to augment your design. If you are unfamiliar with the tool, you can simply describe your design to the chat bot and ask it to generate a starter diagram for you to modify...
Each user request is forwarded to dns server which in turns forwards the request to the api Gateway api gateway based on the api will forward the requset to the load balancer which manages the api server for those requests for the read requests the call is made to both redis and sql databse fo getting the products we will be using redis to handle the products of the flash sale as the operations in redis are atomic and it is very faster on read which will guarantee low latency if the product is not there in the redis we will be reading it from the database we will be defining on each product in redis to guarantee that the product is deleted after flash sale is over periodically we will be flusing the count of products in databse ensure the database is also consistent with redis.
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Each user request is forwarded to dns server which in turns forwards the request to the api Gateway api gateway based on the api will forward the requset to the load balancer which manages the api server for those requests for the read requests the call is made to both redis and sql databse fo getting the products we will be using redis to handle the products of the flash sale as the operations in redis are atomic and it is very faster on read which will guarantee low latency if the product is not there in the redis we will be reading it from the database we will be defining on each product in redis to guarantee that the product is deleted after flash sale is over periodically we will be flusing the count of products in databse ensure the database is also consistent with redis.
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
Each user request is forwarded to dns server which in turns forwards the request to the api Gateway api gateway based on the api will forward the requset to the load balancer which manages the api server for those requests for the read requests the call is made to both redis and sql databse fo getting the products we will be using redis to handle the products of the flash sale as the operations in redis are atomic and it is very faster on read which will guarantee low latency if the product is not there in the redis we will be reading it from the database we will be defining on each product in redis to guarantee that the product is deleted after flash sale is over periodically we will be flusing the count of products in databse ensure the database is also consistent with redis.
Explain any trade offs you have made and why you made certain tech choices...
1) Redis is costly
2) Using dynamodb instead of redis can gurantee durability
Try to discuss as many failure scenarios/bottlenecks as possible.
1) Redis stores everyting in inmemory database which does not gurantee
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?