System Design | BookMyShow | System Design Interview | Movie Ticket Booking | System Design Tutorial

Ғылым және технология

Bookmyshow/Fandango system are like Online Movie ticket booking system is a platform where a user can search a movie in a given city and book it. In this video I will go through the basic system design for online movie ticket booking system, the various components and APIs used. I will also go through the most common concurrency issue faced in such system and how to tackle them. I will also through the choice of database whn dealing with such system.
Spare 15mins for the video and it will definitively help you clear your interview.
Requirement:
Person should be able to book ticket based on:
Current city
Movie that is playing
Theatre near him
Select a particular show
See the available seat and book it
System should handle Concurrency
System should be secure
Database should handle transactions as well as unstructured data
you can buy us a coffee at : www.buymeacoffee.com/thetechg...
system design (HLD & LLD): • System Design | Distri...
DS for beginners: • Arrays Data Structures...
leetcode solutions: • Leetcode 84 | Largest ...
github: github.com/TheTechGranth/theg...
github: github.com/TheTechGranth/theg...
facebook group : / 741317603336313
twitter: / granthtech

Пікірлер: 69

  • @shivag257
    @shivag2572 ай бұрын

    Nice explanation. What I did was instead of performing any lock on DB I kept the locking data at cache level so to have less updates on DB while my DB acted as source of truth for currently available seats. First call goes to DB fetch all the available seats then read cache and filters (remove) the booking in progress seats. When user tries to perform the payment a) it blocks the seat by adding the detail in the cache with some TTL b) it again verifies if that seat is available or not by calling cache. By this I tried saving my system from calling DB which have latency in order of ms while created dependency on cache having latency in order of ns. Though questions might pop up on a) distributed cache handling in this case, b) when should we put lock - when user clicks book now or when user clicks pay now. c) other bottlenecks related to system or user experience

  • @anonymoususer2498
    @anonymoususer24982 жыл бұрын

    Very good explanation. And here wanna say that the interviewer absolutely will ask the lock at db level. I agree with the use of RC(Read Committed). There are 2 ways to do it to prevent the dirty write : pessimistic lock & optimistic lock. pessimistic lock is usually not used since it's too heavy and concurrency unfriendly. optimistic lock is the preferred way and in most db(mysql/postgresql), it's implemented by MVCC. You can talk with the interviewer about all those details. There is a full explanation in 《DDIA》Chapter 7. Have fun ( : -

  • @oyrup
    @oyrup3 жыл бұрын

    Gr8 explanation.. Good efforts !

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    Thanks a lot. Hope it helped you!!! Do like the video and check out other playlist as well. Kindly recommend it to your friends as well :)

  • @wanderingfido
    @wanderingfido6 ай бұрын

    8:44 But the worry at this point would be should the seat be reserved before or after payment? What if, for example, some extremist finds a movie too politically controversial? And uses some threaded bot to repeatedly block seats without payments? Would a solution be to 'tenatively' reserve a seat for a limited time (ie ten minutes) until 'confirmed' via payment?

  • @sanjaikumar1011
    @sanjaikumar101110 ай бұрын

    Bro can u create Notification alert for Movie ticket booking in Bookmyshow For particular movie date and theatre Sounds good right

  • @southern-sunshine
    @southern-sunshine3 жыл бұрын

    How about controlling the ticket availability through flag column in db, instead of locking row in db ?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    When you update that flag column, even that time a row lock is required. Double check process cannot be bypassed I guess.

  • @parasgirdher399
    @parasgirdher3992 жыл бұрын

    Hi, Thanks for the video. I have 1 question. You said after those 3 calls (search by city, by theater, by movie) we'll have the timings of the shows, but I cannot see their storage & mapping as per the entities which you shared in the end. Could you please put some light on this that how we'll be getting those values & their mappings.

  • @TheTechGranth

    @TheTechGranth

    2 жыл бұрын

    Hi, This was created as a high level design video hence focus was more on overall architecture and common issue of concurrency. I promised that i will share database design for this but missed some how, will try to come up with a low level design for ticket booking service. In my opinion getMovieByTheatre will return some POJO which will have movie name, timing, some brief description. Now this POJO will be populated based on data pulled from database/cache. Like I have explained movie details can be on theatre side, so we can pull it from there and keep it in distributed cache. Does this make sense to your question?

  • @parasgirdher399

    @parasgirdher399

    2 жыл бұрын

    ​@@TheTechGranth Hi, Thanks for such a prompt reply. Yeah, we are halfway there in clearing this. So as you are saying we'll pull it from theater's api and keep it in the store at our end but how will we manage to update these timings in case there are some updates for these slots without giving user a bad experience .And also for adding a new movie or deleting an old one, will there be a scheduler running on our service which will keep checking these data from Theater's api after a particular interval of time (lets say every night) to check for new movies & their intervals or something else?

  • @TheTechGranth

    @TheTechGranth

    2 жыл бұрын

    @@parasgirdher399 yes this won't be a random process. Movie timing and movie release will have a fixed schedule, in middle of day, movie timing won't change. So a simple scheduler job can work for us here. Actually this is one thing we should keep in my while designing any system. We should try to keep things simple , once we have new requirements we can always refactor our code and if you have followed design principles and patterns, refactoring won't be tough. This is my opinion, ofcourse perspective can change

  • @parasgirdher399

    @parasgirdher399

    2 жыл бұрын

    @@TheTechGranth Thanks for the clarification.

  • @kvv6452

    @kvv6452

    2 жыл бұрын

    @@TheTechGranth Or can there be another actor like Theatre Owner who can interact with the system who can alter the show timings, update movies in a theatre or even can provide if theatre is open or not.

  • @mahahrishi
    @mahahrishi4 ай бұрын

    Bro but in real Book my show does not have the movie or theatre db . In real it should be an external real time feed from different cinima operators and the real challenge is to book and provide status in real time with third party data.. because other platforms are also using same data and punching booking orders to theatre database. I am not sure how to handle that. Is it simple poling or these platforms have did hard integration where these cinimas or theater push the data in message queues and book my show and paytm like players are on consumer side..

  • @rashitayal9452
    @rashitayal94522 жыл бұрын

    How to store seat arrangement? It can be different for multiple theatre.

  • @wanderingfido

    @wanderingfido

    6 ай бұрын

    Yeah, again, where's that _MovieSeat_ class?

  • @harishs8769
    @harishs876911 ай бұрын

    Super brother

  • @aakash1763
    @aakash17632 жыл бұрын

    Great video few doubts 1.) when booking object will be created like in design video of amazon you created an event then payment service will pick it so can we make an event based system here also like when booking is create an event is pushed and payment service will listen to it and if payment is successful payment will push another event like payment_successull which booking service will listen and update the state of the booking and if payment is unsuccessful it will send payment_unsuccessul event and then booking service will update the state of the booking and release the lock from the seat. 2.) Also if some theater wants to onboard itself on bookmyshow do they have to create an API and maintain a database at their end so that bookmyshow will call their API to get the seat? 3.) Could you mention the services name like search service because in this video that part was missing thanks

  • @TheTechGranth

    @TheTechGranth

    2 жыл бұрын

    1) yes that what payment gateway will do for us 2) yes new theatre has to expose a way for bms to lock seat, else same seat can be booked by 2 users 3) search functionality will be similar to the Amazon video Here I did not discuss about the point 1 and 2 because this question, when asked in interview, focus is generally on concurrency handling 🙂

  • @nipulsindwani117
    @nipulsindwani1173 жыл бұрын

    please answer the following queries: 1) why you have kept the theatre api/database separated from the other database section which you have shown 2) in case of multiple instances of application servers, how application servers contact with the payment gateway and all do we use another api gatway kind of thing on this side also? 3) why you have not explicity created a user profiling microservice as you did in ecommerce application design (reducing complexity or any other reason)?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    1) because the actual ticket will be with theatre and not with apps like bookmyshow or paytm 2) yes, we can use API gateway here as well, it was not included in design as the importance was given to ticketbooking part of application and handling concurrency there can be a microservice which deals with payment gateway and same can be called 3) we can create profile service but as i mentioned in point 2, that was not the focus point for this kind of application design, nonetheless while designing an actual application, you do need to include profile service

  • @nipulsindwani117

    @nipulsindwani117

    3 жыл бұрын

    @@TheTechGranth thanks for detailed reply

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    @@nipulsindwani117 No problem, glad to help. Do share with your friends :)

  • @Krishnaspiritualplanet
    @Krishnaspiritualplanet3 ай бұрын

    Very good

  • @sandhyaaa24
    @sandhyaaa243 жыл бұрын

    thank you :)

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    Do like and subscribe and share with your friends :) Check out the other system design videos as well on the channel :)

  • @AmitKumar-rc4pv
    @AmitKumar-rc4pv3 жыл бұрын

    Hi, It is really nice the way you explained. I have a question, which i was asked in one of the interview Let's there are multiple booking site (bookmyshow, paytm, etc), then how will handle the concurrency, how will maintain the booked seat and available seats, and the seats classification (silver, gold, platinum) is not fixed, if change on demands ?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    Seat is blocked on the theatre side and not on our application side, so it does not matter which app sends the request to theatre, the concept of concurrency remains same. What i mean is, suppose there is a race condition between you and me for booking a seat, so it does not matter if we both are using bookmyshow or I am using bookymyshow and you are using paytm. Theatre Api should have a mechanism to block the seat with the 1st request it receives and block it for say 5mins till it gets a notification of confirmed payment. You can give it a try, block a seat from bokmyshow and go to paytm, even if you have not made a payment from bookmyshow, that seat will not be available for booking from paytm app. So concurrency can be handled using some flag for each seat at DB level, it will not be easy to handle it on application layer because of the distributed nature of the system. Can you elaborate on the 2nd part, Do you mean 2 seats which are next to each other can be like, 1 from silver class and 1 from gold class?

  • @anuragpandey6760

    @anuragpandey6760

    3 жыл бұрын

    @@TheTechGranth i guess he is trying to say if silver gold platinum is demand based then how would it be reflected across multiple platforms if someone blocks the seats and doesnt book it, say last 11 seats are left and system puts the left 10 seat in gold bracket someone locks 11 seat and then doesnt book it mean while someone else is coming and trying to book so the price will be different

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    @@anuragpandey6760 why do you say the price will be different? Do you mean that, when 1st person booked seats were in silver category and after his booking is done, category got upgraded to gold?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    @@anuragpandey6760 and blocking the seat does not mean it is booked, if you need to incorporate this requirement of dynamically managing price then you need to have a flag which will tell if the booking is complete or is under progress. A blocked seat can be a case of booking in progress and unless it goes into booking complete state price should not change

  • @anuragpandey6760

    @anuragpandey6760

    3 жыл бұрын

    @@TheTechGranth yes that was the point of demand based say seats are filling fast and when last 10 seats are left the price gets inflated. How could such functionality be given. Since lock period is say 5 minutes but if i trigger price hike with lock of seat then there is chance it wont get booked.

  • @saurabhvaish7667
    @saurabhvaish76673 жыл бұрын

    Hii bro , good explaination for overall system design on high level . But from next time can you go little in depth , like what are the challenges to achieve this and how to solve them.

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    This video was prepared to get everyone started on and familiarized with the high level system design of movie ticket booking system. But I see what you are talking about, point noted.

  • @VinodKumar-vd9ou
    @VinodKumar-vd9ou Жыл бұрын

    Don't keep the booking history in RDBMS, because with time it will hugly make the search operation very slow so a better approach is put the history data to SOME REPORTINF DATABASE LIKE TERADATA or sometging like that.

  • @Asha-se4wv
    @Asha-se4wv3 жыл бұрын

    what could be flow for uploading new movie/movie trailer in the system?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    You mean something like netflix or amazon prime?

  • @Asha-se4wv

    @Asha-se4wv

    3 жыл бұрын

    Yeah

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    @@Asha-se4wv That will be another system all together. I have made a video on that as well, do check out: kzread.info/dash/bejne/gHaDmpqJfKqvmdY.html

  • @shashankbhatt8102
    @shashankbhatt8102 Жыл бұрын

    Informative video. Any suggestions on how to get access to theatre's API?

  • @wanderingfido

    @wanderingfido

    6 ай бұрын

    A theatre chain's website will usually have a section called something like 'developer resources'.

  • @neelsheth7706
    @neelsheth7706 Жыл бұрын

    From where I can get cinema sheat available API

  • @wanderingfido

    @wanderingfido

    6 ай бұрын

    What the sheat are you talkin' bout, mo?

  • @Pritishshorts333
    @Pritishshorts3332 жыл бұрын

    Concurrency not explained.

  • @anantjain5147
    @anantjain51473 жыл бұрын

    how can i get its source

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    github.com/TheTechGranth/thegranths/tree/master/src/main/java/SystemDesign

  • @satyanveshvanapalli9905
    @satyanveshvanapalli99053 жыл бұрын

    can u add how the data base tables design and the relation ships

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    Will post that as a pinned comment here soon

  • @parasgirdher399

    @parasgirdher399

    2 жыл бұрын

    @@TheTechGranth Waiting..

  • @wanderingfido

    @wanderingfido

    6 ай бұрын

    I've been waiting so so long for a _post_ like you. . .to come into my liiife. . .🎶🎵🤭

  • @shivan8509
    @shivan85093 жыл бұрын

    did you make a complete tutorial?

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    on?

  • @shivan8509

    @shivan8509

    3 жыл бұрын

    on movie ticket project?

  • @shivan8509

    @shivan8509

    3 жыл бұрын

    I would like to do a project to gain experience and a done project could help maybe ticket booking project ☺️

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    @@shivan8509 This video is the system design for BookmyShow but certainly does not have the complete implementation. you can google for that and I am sure you can find it. I do not have the complete implementation else would have shared

  • @shivan8509

    @shivan8509

    3 жыл бұрын

    @@TheTechGranth thank you very much, even without the implementation it was very helpful

  • @wanderingfido
    @wanderingfido6 ай бұрын

    You need to dig deeper into the _Theatre -> Rooms -> Seats_ relationship.

  • @wanderingfido
    @wanderingfido6 ай бұрын

    14:41 Where's the class _MovieSeat_ ? You're blueballing us. 🤭

  • @gurmeetchawla8362
    @gurmeetchawla8362 Жыл бұрын

    concurrency part is no explained well in this video. There is a need to go a level deeper in that.

  • @wanderingfido

    @wanderingfido

    6 ай бұрын

    The risk of Sequence Diagrams is Analysis Paralysis.

  • @rabindrakumar949
    @rabindrakumar9493 жыл бұрын

    This is really not the design. This is a generic architecture of platform.

  • @TheTechGranth

    @TheTechGranth

    3 жыл бұрын

    if you mean a low level design, then no it is not. It is just a high level design of how you will approach to design a system where you have to book a ticket. It will get you started on what all components will be required to build a system like bookmyshow and how you will handle the problem of concurrency encountered in such systems. This will also let you understand how to select a database, when you are designing a system like this.

  • @raftar_the_explorer
    @raftar_the_explorer Жыл бұрын

    Poor design

Келесі