Bookmyshow system design: focussing on seat booking feature.

Websites like Bookmyshow and MakeMyTrip ensures one seat should be allocated to only one User, In this video, I have tried to showcase the idea behind how they achieve this thing while two users are trying to book the same seat.
I hope you will like the concept. Please share your views by leaving comments on this video.

Пікірлер: 89

  • @VikiSangani
    @VikiSangani4 жыл бұрын

    Very nicely explained. Pls keep making such videos and share the knowledge. Thank you.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    viki sangani thanks for such nice words

  • @dharanyuvi6951

    @dharanyuvi6951

    2 жыл бұрын

    @@SunnyGuptaTech Check my comment , i posted one limitation in ur design

  • @GayathriNCSekhar
    @GayathriNCSekhar2 жыл бұрын

    Very well explained and right when I needed to get some clarity, this video came to my hands and it helped! Thank you

  • @learnsharegrow7294
    @learnsharegrow72943 жыл бұрын

    Very common system design concept made easy. Thanks for sharing.

  • @umangmalhotra1222
    @umangmalhotra12222 жыл бұрын

    Should have discussed about Optimistic Locking and Pessimistic Locking as well in this video.

  • @sat08527
    @sat085272 жыл бұрын

    Good and clean explanation. Expected few seconds more on how to handle scenarios to remove user 1 entry from pre-booking table after some timeout or session close in case user1 does not proceed further.

  • @kdeekshith9600
    @kdeekshith96005 жыл бұрын

    I would be very happy to thanking you Sunnny for your such initiative.very few people make things in a different way and u r one of them.great job keep it up.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    5 жыл бұрын

    k deekshith thank you very much for your precious comments

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

    Thank you so much for so clear explanation.

  • @ramanandjaiswal7196
    @ramanandjaiswal71963 жыл бұрын

    Beautifully explained. was looking out for explanation for this particular use case on web but couldn't find well explained article/video.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Thanks for your kind words. Please subscribe.

  • @NguyenTuan-ek1pv
    @NguyenTuan-ek1pv3 ай бұрын

    Thanks for your video.

  • @aaryashgamerz
    @aaryashgamerz5 жыл бұрын

    Good explanation of conflicting demand and it's resolution by optimistic looking.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Thank you :)

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

    This was very informative. Thanks.

  • @rahuldevgupta4513
    @rahuldevgupta45133 жыл бұрын

    Thanks bhai, Superb Explanation!

  • @suryakantlokhande8144
    @suryakantlokhande81444 жыл бұрын

    really nice demo , your effort is much appreciated .

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    Thanks Suryakant.

  • @tanmayawasthi6487
    @tanmayawasthi64874 жыл бұрын

    Thanks, Sunny. Nicely explained.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Glad you liked it. Please subscribe to this channel if not done already. :)

  • @tushargoel5522
    @tushargoel55224 жыл бұрын

    You have explained w.r.t to BookMyShow users only. In actual scenarios, tickets are booked on 3rd party (theatre, pvr etc..) in that case multiple requests can come for a seat from different sources. In that case how to maintain that? I am thinking some 2 approaches either directly taking locks on central DB or to use event-driven architecture. What do you say?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Hi Tushar Would you elaborate a bit more on the 2 approaches. I didn't get the question completely.

  • @genuineprofile6400
    @genuineprofile64002 жыл бұрын

    Excellent video. Can you please also explain how concurrent booking of Hotel rooms are handled? As they are of date based booking. Thanks for this amazing concept.

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

    To the point, very informative. Thanks you for the video.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    Жыл бұрын

    Glad it was helpful!

  • @dhananajaykrishna8259
    @dhananajaykrishna82593 жыл бұрын

    "Pre-booking" table can be maintained by BMS for the users booking through its app. But what if another user is booking the same seat using an app say PAYTM. How will the data consistency be maintained in their database for the booking entry created in BMS's database.

  • @dharanyuvi6951

    @dharanyuvi6951

    2 жыл бұрын

    Bro there will be no 2 different Databases for ur case.., Only one db (from BMS) will serve the purpose. Remaining services can uses the BMS APIs, or other techs to ensure seat in the theatre

  • @aniljuneja175

    @aniljuneja175

    2 жыл бұрын

    this will be done by theater who are running the shows. There are 2 approaches. 1. Different seats will be assigned to different ticket platform so that concurrencr requiremnt will only exist for single payment platform. 2. each ticket platform should call particular theater api to book tickets on user behalf. for second case we will require distributed lock to be taken using customized code or use isolation level serializable.

  • @prashant1king1
    @prashant1king15 жыл бұрын

    Very informative and well explained! Keep it up! 😇😎

  • @SunnyGuptaTech

    @SunnyGuptaTech

    5 жыл бұрын

    Thanks Prashant.

  • @nikeshdevaki
    @nikeshdevaki4 жыл бұрын

    @Sunny Gupta Can you also explain how blocked seat which was not booked gets unblocked after sometime?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    Hi @nikesh devaki , You might run some background job that will check that seated which are not booked and still not available as their entry is being made in the pre-booking table. You can remove those entries after some time interval. For example BookMyShow gives you 8 minutes to complete your transaction.

  • @ravikumarkumashi7065
    @ravikumarkumashi70652 жыл бұрын

    very nicely explained, thank you for such an amazing easy to understand content

  • @SunnyGuptaTech

    @SunnyGuptaTech

    Жыл бұрын

    Glad it was helpful!

  • @shubhamchandra9258
    @shubhamchandra92582 жыл бұрын

    Awesome demo + design trick. Good work.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    Жыл бұрын

    Glad you liked it!

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

    Nicely explained...Thanks

  • @tarunrawat1281
    @tarunrawat12813 жыл бұрын

    We should also use transaction in this case right ?

  • @TheKshitijagrawal
    @TheKshitijagrawal2 жыл бұрын

    This seat booking will be confirmed only after payment so what are you going to do in between seat selection and payment. What if user does not do payment then are you going to run some process to delete the rows. I think it's better to have seats available as inventory and then play with status -> Available, TenativelyBooked, Booked

  • @justsomeguy113
    @justsomeguy1133 жыл бұрын

    Thank you so much for this design. Will this work well if we have a very popular show for which, for example, 100,000 people all want to book the same front row seat as soon as the tickets go on sale?

  • @aashishgoyal1436
    @aashishgoyal14364 жыл бұрын

    Thanks for the awesome explanation

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    Thanks Aashish

  • @zainulkhan8381
    @zainulkhan838110 ай бұрын

    What if we increase a column isBooked of Boolean type and change the variable accordingly for each seat booked

  • @DurgeshYadav-bc5nm
    @DurgeshYadav-bc5nm2 жыл бұрын

    what if the database is sharded and so the pre booking table data is sharded too. How to handle concurrency in such a scenario.. ? I think we have to put the locking mechanism on the application server and use a distributed cache like Redis etc to ensure concurrency across different application server instances. Also, we shouldn't be using a database for intermediate stages, we should be using cache and remove item from cache when the booking for that transaction is complete with payment

  • @jyotisman212
    @jyotisman2124 жыл бұрын

    very well explained if possible then do this with simple codding. secondly if i have single server then how can i lock seats using js?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    Sure may be in near future I will try to code this. Using JS (javascript), you might need to fire Ajax request, and on server side you can handle that in a way i explained.

  • @raviedpuganti9794
    @raviedpuganti97944 жыл бұрын

    good explanation. thank you.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    ravi edpuganti you are welcome 🙏

  • @ghanshyam014
    @ghanshyam0144 жыл бұрын

    It's good demonstration of bookmyshow architecture design ever in a very less time with clarification 😉😊 And your effort made it so interesting ...🤙 Please make more videos...

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Thanks a lot 😊 Sure i will put more videos. Please subscribe.

  • @ghanshyam014

    @ghanshyam014

    3 жыл бұрын

    @@SunnyGuptaTech nhi karunga bhaiya, you replied after one month 😉😄😜

  • @ghanshyam014

    @ghanshyam014

    3 жыл бұрын

    Sunny 🌄bro, it's gonna more than one year and you have only 7 video..🤔 Why??? In this lockdown event every one has been crossed in millions.... So what about you?? What you were doing I mean doing...🤪 You have such a massive knowledge and talent.. you must have a very good content with clear and soothing voice.... 😉 Your demonstration and illustrations of every content is very well with perfection..🍁🌿 Despite on you have not much enough video..

  • @ghanshyam014

    @ghanshyam014

    3 жыл бұрын

    @@SunnyGuptaTech how are you Sunny bhaiya 🤗

  • @ghanshyam014

    @ghanshyam014

    3 жыл бұрын

    @@SunnyGuptaTech hello Sunny bhaiya 🤗 I hope you are doing well.... Please post more videos... Look , now I subscribed also 😊

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

    Good one. One doubt... can someone bring the database down by having a large number of conflicting bookings? Is there a better way to handle it?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    Жыл бұрын

    Any distributed lock will work.

  • @backtobasics6865
    @backtobasics68653 жыл бұрын

    so if someone is booking 10 seats, it will create 10 entry??? does'nt looks good design

  • @sahildhiman7675
    @sahildhiman76752 жыл бұрын

    How will we maintain the pre booking table ,in case an entry is logged into the pre booking table but the corresponding seat is not booked by users after entering details onto pre booking table.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    2 жыл бұрын

    You have to write a cron and delete the entries from pre booking which are longer then certain time duration and make that seat available again.

  • @nands4410
    @nands44102 жыл бұрын

    How is unique constraint evaluated in real time?

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

    Good

  • @TheSahilandsahil
    @TheSahilandsahil3 жыл бұрын

    Sunny bhai please let me know how the seat layout is made from admin side

  • @gauravsinghchauhan
    @gauravsinghchauhan5 жыл бұрын

    If your is booking 3 seats and 2 are valid and 1 causes unique constraint violation. How will you handle that?

  • @animesh3436

    @animesh3436

    5 жыл бұрын

    It will iterate through all 3 seats and check if all three can be inserted or not. Ideally, as soon as a person clicks on a seat, the seat should be marked as reserved i.e someone is trying to book it. Once the payment is complete, the seat's status to change to Booked. There should be an expiration time for reservation too (for eg:- If payment fails within 10 mins, then change the status to Active and notify the user's about the availability.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    Hi Gaurav, If you are selecting three seats and all three are not valid. So you should ideally not be able to complete that transaction.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    @@animesh3436 Thanks Animesh for your valuable comments.

  • @TheSuchendra
    @TheSuchendra5 жыл бұрын

    Very well explained. Can you also do a video on ola/uber please?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    5 жыл бұрын

    Suchendra Kumar Sure. Will try to do the same.

  • @algorithmsguide5076

    @algorithmsguide5076

    4 жыл бұрын

    @@SunnyGuptaTech Please do more videos like these.

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

    What if 1 seat is available and 2 tries to book ticket how it is handled

  • @SunnyGuptaTech

    @SunnyGuptaTech

    Жыл бұрын

    I have presented the same scenario. One User will be able to make an entry in pre-booking table and another won't as there is a unique constraint on that table.

  • @hsekollukog149
    @hsekollukog1493 жыл бұрын

    Sir can i have a contact with u, I need to discuss something related to it. It will be kind enough, if you acknowledge this comment and respond.

  • @chandrabhan3501
    @chandrabhan35013 жыл бұрын

    But how 5 minutes session works ?

  • @aniljuneja175
    @aniljuneja1752 жыл бұрын

    one problem in there aslets say one user book seat 5,6,7 and other user book seat 7,8. By this approach it will allow seat 8 to be booked by user 2. in this way , my guess is we are not doing justice to ACID properties and number of seat user wants to book. We should tell user 2 to go back and choose some other seat. Let me know what you think.

  • @SunnyGuptaTech

    @SunnyGuptaTech

    2 жыл бұрын

    No Anil. It won't allow its happening in a transaction, whole transaction will fail.

  • @charan775
    @charan7754 жыл бұрын

    threate_id, seat_id, show_id should be unique right? not threate_id, seat_id, show_id, user_id

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Yup I mentioned the same.

  • @mevimalkumar
    @mevimalkumar3 жыл бұрын

    Very well explained. Keep it up

  • @SunnyGuptaTech

    @SunnyGuptaTech

    3 жыл бұрын

    Vimalkumar Bohara Thank you. Please subscribe to my channel.

  • @dharanyuvi6951
    @dharanyuvi69512 жыл бұрын

    Sunny this design will fail when it got reached the excessive traffic to the service Reason : Lack of concurrency control Means - when 2 transactions are occuring at the same time for the same seat then both will get the result as seat is not booked , since its just a read request Then both will get into update query to book a seat - which will lead to a double booking for a single seat. Solution : DB Isolation Serializability (OR) need to use exclusive lock systems in oracle or postgres

  • @genuineprofile6400

    @genuineprofile6400

    2 жыл бұрын

    There is a uniqueness constraint on the Pre-booking table. That itself will not allow double booking.

  • @jyotisman212
    @jyotisman2124 жыл бұрын

    what about multiple seats?

  • @SunnyGuptaTech

    @SunnyGuptaTech

    4 жыл бұрын

    All those seats could be the part of same transaction. Either all will be booked or nothing will be booked.

  • @jyotisman212

    @jyotisman212

    4 жыл бұрын

    @@SunnyGuptaTech but if someone choose A1,B2 and another one choose A1,A2 then how can we prevent seconde one for further process? i have prepared a code that if a person A choose seat number A1,B2 and person B choose seat number A1,C2 at the same then system will check the seat number is it already exists or not if exists then fetch the seat number from table and compare it with the data given by A or B and if found that no data in ta database then the put the data of A in data base and redirect him to next checkout area ( let the seats first choose by A ) and for B redirect to the error page as the seat numberA 1 is already choose by A. my code ok when two people book same seats no difference but its not run when onely some specific seats are match I dont know how solve it.

  • @aatifnazar8203
    @aatifnazar820310 ай бұрын

    this doesnt work at scale

  • @saiyashwanth1991
    @saiyashwanth19913 жыл бұрын

    using DB for non complete transaction is bad.

  • @dharanyuvi6951

    @dharanyuvi6951

    2 жыл бұрын

    yes, i too felt the same

  • @ramjishkl
    @ramjishkl2 жыл бұрын

    This is naive way and not correct for large scale distributed systems ,there is somethings called distributed locks and optimistic locking .

Келесі