List functional requirements for the system (Ask interviewer if stuck)...
List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Assume that there are 10,000 DAU, each user has 500 tags on average. So there are 500*10,000 = 5,000,000 tags in total
Assume that each user add 5 tags per day, then there are 50,000 tags added per day
if 20% of the datas added per day are updated, then 50,000 * 20% = 10,000 updates per day;
Assume each tag is 80 bytes, then we need at least 5,000,000 * 80 bytes = 0.4 Gb
Define what APIs are expected from the system...
RESTful APIs:
@Create
void create(String tagName)
@Batch_Create
void batchCreate(List
@Update
void update(Tag tag)
@Delete
void delete(Tag tag)
@Get
List
List
List
List
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...
Data model:
Tag {
id: int (autoincrement),
name: varchar,
metadata: varchar
}
TagCategory {
id: int,
name: varchar,
}
TagToCategoryMapping {
tagId: int,
categoryId: int
}
Choice of Database:
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...
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?