We assuming DAU or 20,000, with each user logging activities once a day on average.
Accounting for spikes in usage, for capacity planning, lets assume all updates show up in the same hour. We have about 10 updates per second, which is well within the capabilities of nearly any NoSQL or SQL database.
We should also size what is needed for the social sharing features. Assuming 10 activities per second being shared with 10 friend each
PUT /activity/:activity-id -> Shareable-URL
{
type (e.g. "running")
duration
distance
}
POST /weekly-goal/:goal-id
{
type (e.g. "running")
duration
distance
start_date
end_date
}
GET /activities?start=:starttime&end=:endtime -> Activity[]
Activity {
type
duration
distance
upload-date
}
GET /weekly-goals?start=:starttime&end=:endtime -> Goal[]
Goal {
type (e.g. "running")
duration
distance
start_date
end_date
}
User
Goal
Activity
Use Postgres for storage
FrontEnd terminates the connections from client and serves the API. It stores User, Activity and Goal data in Postgres.
In enques content generation requests to the Shared Page Generator.
The Shared page generator generates content that can be shared, and uploads it to blob storage, and puts the URL in Postgres.
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?