System requirements


Functional:

  • Buy tickets for an event
  • View upcoming events
  • View booked events
  • Sell tickets
  • User authentication
  • Search for an event



Non-Functional:

  • Reliable (2 users can't book same ticket)
  • Secure
  • Fault tolerant
  • Handle large volumes of users during popular events




Capacity estimation

Estimate the scale of the system you are going to design...






API design

GET /tickets

  • Params: search parameters (optional)
  • Returns: list of events

POST /buy

  • Params: ticket id(s), timestamp, user id

POST /buy/confirm

  • Params: payment info
  • Returns: success/failure


Database design

  • SQL database
  • Event: id, artist, venue, date, description
  • Ticket: id, seat info, event id
  • Booking: id, event id, ticket id
  • Artist: id, name, description



High-level design

Components

  • API Gateway
  • Load balancer
  • Ticketing service
  • Payment service
  • DBs
  • Caches






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

  • Use LRU for caching events
  • Cache should be invalidated when the event has passed
  • Use cache write-back policy
  • Shard the ticket database by events
  • Replicate the booking database




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?