System requirements
Functional:
List functional requirements for the system (Ask interviewer if stuck)...
- user can use the system to send a request to book a ticket
- user can see the order status
- user can pay for the ticket
- user can cancel the ticket if they haven't paid for it
- the system can notify the user for the order update or the event update
Non-Functional:
List non-functional requirements for the system...
- availability: the system should have high availability
- scalability: the system should be scalable to support hundreds of millions of users
- reliability: the system should be recovered from the errors
- consistency: the system should support strong consistency for ticket booking
Capacity estimation
Estimate the scale of the system you are going to design...
100 million user
10 million active users: every month book 3 tickets
10*10^6 * 3 / 10 / 10^5 ~ 3 qps
It's not a write heavy system
read Qps: 10*3 = 30
API design
Define what APIs are expected from the system...
- POST: /book (userId, eventId, eventDetails)
- POST: /cancel (userId, orderId)
- POST: /pay (userId, orderId)
- GET: /find (orderId)
- GET: /search (userId, criteria)
Database design
- User Table: userId, name, email, phone
- Oder table: orderId, ticketId, createdTime, status
- Event table: eventId, eventStart, eventEnd, location, company
- Ticket: userId, eventId, seat(optional)
High-level design
- userClient
- Api GateWay
- Booking service
- Ticket Server
- Kafka
- Payment Service
- Notification service
Request flows
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...
Detailed component design
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...
Trade offs/Tech choices
Explain any trade offs you have made and why you made certain tech choices...
Failure scenarios/bottlenecks
Try to discuss as many failure scenarios/bottlenecks as possible.
Future improvements
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?