List non-functional requirements for the system...
Estimate the scale of the system you are going to design...
Define what APIs are expected from the system...
GET api/events
get events by user id and time range
request
{
user_Id: 'u123',
invitee: ['[email protected]', '[email protected]']
from: 1624957228 // unix timestamp, easy to convert to local time
to: 1624958228
}
response
{
events: [
{
event_id: 'e123',
user_id: 'u123',
email: '[email protected]',
event_name: 'interview',
event_desc: 'interview description',
from: 1624957228,
to: 1624957228
},
.....
]
}
POST api/event/create
create an event
request
{
user_id: 'u123',
event_name: 'interveiw',
event_desc: 'xxx',
from: 1624958228,
to: 1624958228,
invitee: ['[email protected]', '[email protected]'] // optional
}
response
{
event_id: 'e134',
status: 200,
error_msg: 'conflict with xxx' // error message, e.g. there is conflict event
}
POST api/event/manage
update/delete event
request
{
event_id: 'e123',
user_id: 'u123',
action: 'cancel', // 'update'
event_name: 'new event', // updated event name
}
POST api/event/invite
invitee accept or decline the event
request
{
user_id: 'u345',
action: 'accept' , // accept or decline
reason: 'no time' // accept or decline reason
}
response
{
status: 200,
error_msg: '...'
}
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...
User
user_id: pk, uuid
email: string
name: string
Calendar
calendar_id: pk, uuid
user_Id: fk
name: string
desc: string
timezone: Timezone
Event
event_id: pk, uuid
name: string
desc: string
from: int
to: int
Notification
notif_id: pk, uuid
event_id: fk
method: string // push notif, SMS, call...
user_id: fk,
effect_time: int,
see diagram
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...
discuss data model
Calendar
calendar_id: pk, uuid
name: string
desc: string
timezone: Timezone
Event
event_id: pk, uuid
name: string
desc: string
from: int
to: int
Calendar <> Event is many to many relationships
CalendarEvent
id: pk
event_id: fk
calendar_id: fk
role: string // invitee or host
Explain any trade offs you have made and why you made certain tech choices...
Sharding would be important as the use case scales.
org_id (Organization ID) would be a good choice as a sharding key. Most meetings are scheduled within one organization, including mostly employees of the organization. By sharding the data with org_id, accesses would be heavily localized, making caching effective.
Some organizations would be bigger, or more active, than others. As such, we need to carefully plan which organizations are supported by which DB nodes. An idea of consistent hashing - dynamically adjusting the responsibility of each node - can be applied to RDBs, but are harder to implement than some NoSQL DBs. As such, we should carefully project the workload of each organization and assign it to an appropriate DB node.
Try to discuss as many failure scenarios/bottlenecks as possible.
Most major components, e.g., Meeting Service, Notification Service, Cache, Message Queue, are either stateless or support horizontal scaling. We should take advantage of such feature for fault tolerance (e.g. when one node goes down, another can take over) and scalability. We should monitor these nodes for service latency and resources. Auto-scaling can be applied to some components, e.g., Meeting Service.
Database is a little more tricky as RDB is not horizontally scalable.
Primary-Secondary configuration (with read only replicas) can be used to provide fault tolerance and scalability. As discussed earlier, sharding also provides scalability.
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?
Meetings have this important property: once it is finished, the data will be less important. Things like descriptions, names, or invitees, wouldn't change.
This presents an opportunity for optimization in the Database. We can have a service that periodically checks finished meetings, and move that data out of the main DB to a secondary storage. The history of past meetings could be important, so we would store it in a less expensive, less performant storage.
This would allow us to keep the main DB smaller, improving scalability and fault tolerance.