List functional requirements for the system (Ask the chat bot for hints if stuck.)...
1) User should be able to create an account
2) Users can upload the photo from their device
3) Users can follow unfollow other users
4) Users should see the a feed of photo from users they follow
List non-functional requirements for the system...
1) System should be highly available
2) System should be fault tolorent
3) System should be scalable
Estimate the scale of the system you are going to design...
Lets assume instagram has 1000,000 daily active users and each users views 10000 profiles in a day then number of actions =10^6 *10^3=10^9 and qps =10^9/10^5=10^4
Lets assume if a single server can handle 10^5 transactions then total servers required to 10^9/10^5 =10^4
Define what APIs are expected from the system...
1) /register-user -> The following api is used to register a user it returns status 200 in case of sucessfull registration and 400 if user enters any wrong infromation and status 500 in case of server issue.
2) /upload-photo - The user can upload a photo using the following api it return status 201 if photo is sucesfully uploaded and status 400 if it's a bad request
3) /add-follower- This api is add a follower for a particular user
4) / remove-follower
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...
As the system is heavier on the read side so we will use relational database to store user related information and for storing follower tables we will have a seperate table follower that will have follow follower relationship for photos and videos we will have a seperate table that will store the url of the photo and video these photo and videos will then be stored in s3
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...
For Authentication we will use cloud service like aws cognito that will maintain a user pool that will store all the users details all the users request will go through api gateway that will implement rate limiter to prevent denial of service attack and then the api call will be forwarded to api server in case of read request the the api queries the relational database to get the url of the image and then fetched the image and displays on the screen. If a user uploads the photo then the photo will be stored in s3 and after getting the url from s3 it will be stored in relational database. After each upload option the an event will be stored in queue and whenever the follower of that user comes onlines then he reads all the events of the queue after a day the event is deleted from queue in case of celebrity users who are having millions of followers the pull model will cause high overhead so in this case the event is pushed into the userFeed queue and once user comes online he wil read events from that queue.
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...
For Authentication we will use cloud service like aws cognito that will maintain a user pool that will store all the users details all the users request will go through api gateway that will implement rate limiter to prevent denial of service attack and then the api call will be forwarded to api server in case of read request the the api queries the relational database to get the url of the image and then fetched the image and displays on the screen. If a user uploads the photo then the photo will be stored in s3 and after getting the url from s3 it will be stored in relational database. After each upload option the an event will be stored in queue and whenever the follower of that user comes onlines then he reads all the events of the queue after a day the event is deleted from queue in case of celebrity users who are having millions of followers the pull model will cause high overhead so in this case the event is pushed into the userFeed queue and once user comes online he wil read events from that queue.
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...
For Authentication we will use cloud service like aws cognito that will maintain a user pool that will store all the users details all the users request will go through api gateway that will implement rate limiter to prevent denial of service attack and then the api call will be forwarded to api server in case of read request the the api queries the relational database to get the url of the image and then fetched the image and displays on the screen. If a user uploads the photo then the photo will be stored in s3 and after getting the url from s3 it will be stored in relational database. After each upload option the an event will be stored in queue and whenever the follower of that user comes onlines then he reads all the events of the queue after a day the event is deleted from queue in case of celebrity users who are having millions of followers the pull model will cause high overhead so in this case the event is pushed into the userFeed queue and once user comes online he wil read events from that queue.
Explain any trade offs you have made and why you made certain tech choices...
1) Using s3 as the store for image and videos will guarantee avalability and scalability
2) As the system is read heavy so using relational database is right choice
Try to discuss as many failure scenarios/bottlenecks as possible.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
We can use machine learning to allow users to create picture of themself based on the discription provided by them.