Task Table:
~30KB per row
User Table:
~25KB per row
On average, 5 to 20 tasks per user per day
100,000 users per day
2000000 * 30 = 60000000KB a day -> 60GB per day inserted into the user Table
External:
Task Table:
User Table:
Client sends task to POST endpoint
Read tasks from DB -> find tasks that need to be executes -> Tasks where execute time has passed -> Normalize time by 10 seconds
Because the system will be read heavy, we would want to have replicas to reduce the load in the primary database
Shard the database -> shard databases by task time -> Further shard the shards that have overwhelming amount of tasks
Find tasks that need to be executed
Enqueue the tasks by priority
If task fails, task priority increases
Higher the priority, the stronger executor node the script is sent to
Keep track of it executor nodes are available by heartbeats -> use zooKeeper to track it
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...
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...
Explain any trade offs you have made and why you made certain tech choices...
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?