Airline Reservation System - Distributed Transactions, Serialisation, Linearisation, Consistency

Поділитися
Вставка
  • Опубліковано 28 чер 2024
  • Join the discord community to share more learnings on system design and distributed systems:
    / discord

КОМЕНТАРІ • 76

  • @abhishtsingh6073
    @abhishtsingh6073 Рік тому +22

    This was one of the best system design videos I have seen. You didn't brush over important concepts, went into good low level details and first principles and compelled me to take out my notebook and take notes!
    I really wish you make more of these!

  • @neetadhavade
    @neetadhavade 9 днів тому

    really underrated video. Deserves more likes

  • @shivaakrish
    @shivaakrish Рік тому +1

    This is one of the most underrated video! It deserves more views.

  • @manjeetkumar
    @manjeetkumar Рік тому +1

    You explained flight booking flow in quite detailed manner while focusing on all important topics. Which i really liked. I have seen so many videos on system design, usually people don't dive deep into these concepts. You did everything in balanced way, which makes this presentation perfect.

  • @yashsaliya4475
    @yashsaliya4475 Рік тому

    your explanations made me understand how to ask questions with the interviewer and how to discuss the details of the system
    overall fantastic experience 💯

  • @VishalThakur-wo1vx
    @VishalThakur-wo1vx 3 місяці тому +1

    Great video. I have some feedbacks.
    1. Talk about Orchaterator vs Choreographer pattern. Booking Service is acting as a Orchasterator . We can also use decentralized system like Kafka.
    2. 2PC is generally not practical to achieve distributed transaction. A better approach would be SAGA pattern and having compensating events.
    3. Also, talk about creating some derived data. For example, is a flight is booked completely . Keep this info in cache and keep cache in sync with DB so that cancellation would mark this booked flight to available.

  • @user-dn1wl3ej7z
    @user-dn1wl3ej7z 4 місяці тому

    Great video !! Clearly explained everything in a simple manner. Thanks so much.

  • @ishaarora3
    @ishaarora3 Рік тому +3

    Great explanation. Appreciate that you took into account the scale part and actually discussed the numbers. Thats an important part and some interviewers like to ask it for mainly senior roles. Thank you!

  • @manueldiera6781
    @manueldiera6781 4 місяці тому

    Such a great video, excellent content presented in a very well balanced way. Thanks!

  • @santoshbhatnagar2155
    @santoshbhatnagar2155 3 місяці тому

    Really nice and in-depth video.

  • @amazingmanish
    @amazingmanish 19 днів тому

    40:15, You may not need to rollback after payment booking. What you can do is have a SQS queue in place and a scheduler will update the Booking Info let's say after 10 mins.

  • @sajeethabegum4740
    @sajeethabegum4740 7 місяців тому

    Concepts are clearly explained and Easy to understand. Thanks for making this video.

  • @AmitAgrawal-xu8uk
    @AmitAgrawal-xu8uk 2 місяці тому

    Very Nicely explained !!! Best video for this topic ..thanks for sharing

  • @vinitamaloo107
    @vinitamaloo107 Рік тому

    Such a detailed video. Thank you!

  • @sristijaiswal1013
    @sristijaiswal1013 Місяць тому

    Very detailed video. Thanks a lot.

  • @sandeepbaldawa9146
    @sandeepbaldawa9146 Рік тому

    Beautifully explained! good one

  • @aunghtayoo337
    @aunghtayoo337 Рік тому

    Thanks for the quality content.

  • @alphabeta644
    @alphabeta644 11 місяців тому +4

    Is it possibly or advisable to switch between optimistic lock and pessimistic lock on the fly? For example, if the airline seats are

  • @andersondamasceno
    @andersondamasceno 5 місяців тому

    Very good explanation. Will aid me in my quest of learning system design.

  • @YouTubers-rj9xv
    @YouTubers-rj9xv 11 місяців тому +1

    Anna please don't stop uploading videos. We love you 💘 excellent teacher.

  • @mallikarjunmannam8225
    @mallikarjunmannam8225 11 місяців тому

    nice explanation and great work

  • @squ34ky
    @squ34ky 11 місяців тому

    Excellent analysis.

  • @rahulsinghishere
    @rahulsinghishere 5 місяців тому

    Thanks, this is very useful for me, really appreciate your efforts

  • @ahokai
    @ahokai 11 місяців тому +2

    great video and thank you for sharing. I have a few comments. 1) about calculating TPS, it should not be considered using a daily estimated traffic, because traffic normally is not distributed evenly and it fluctuates. It is important to think about TPS as exactly "how many transactions does your system need to support per sec in the worst case scenario at any given time of the day". 2) avoid using distributed locking, 2-phase commit is complex and should be avoided. use some sort of recovery mechanism instead. 3) not sure about locking seats using DB locks, you can use DB to lock rows, tables or even columns for certain DBs but what you need here is some locking mechanism that you will need to design on top of DB locks to achieve atomicity or simply an in-memory cache can also do the job. 4) optimistic locking is designed for high concurrency and pessimistic locking kills concurrency.

    • @koeber99
      @koeber99 7 місяців тому

      You said to "avoid using distributed locking." Well then how do you handle/create a ticketing system (ticket master), with millions of users but only 100K seats event for every popular concerts/ sporting events? In big events, there will be high demand in a short period (hours) trying to buy the few tickets.

  • @LeoLeo-nx5gi
    @LeoLeo-nx5gi Рік тому +1

    Thanks a ton!!! Quite clear and amazing

  • @heathergrey_
    @heathergrey_ 11 місяців тому

    this is so so helpful thank you!!!

  • @DipanshaChhabra
    @DipanshaChhabra 9 днів тому

    truely awesome

  • @SunnyKumar-ud9gp
    @SunnyKumar-ud9gp 3 місяці тому

    The content is amazing

  • @chandranshudubey150
    @chandranshudubey150 Рік тому

    Very Nicely Explained.

  • @RM-bg5cd
    @RM-bg5cd 10 місяців тому +1

    One thing you could do for the payments is simply process them later. At the moment what you need to fetch from the user is a payment method and this is something you can setup with Stripe. So if you manage to get a payment method, temporarily store in the database along with your booking and the seats, and bundle that in the same unit of work, you could then use a transactional outbox pattern to process the payment later. If something’s wrong with the users payment method you remove the seats and make the booking available again, this would free you from dealing with the refund service altogether and turns the system into a more event and domain driven system.

    • @koeber99
      @koeber99 7 місяців тому +1

      In the real world, I don't think the business side of the company is going to like this approach. The company wants to lock in the sale! The customers would assume their airline tickets are booked and go to the bed at night then straight to work in the morning. They may not see your notifications for hours or even days after the failure. What do you do with the seats in the meantime? Hold them? What happens if the customer changes their mind? Then you hold on for seats for 24 hours for nothing! If you don't hold the seats, then I miss my flight. In my opinion, it's better to fail fast! The customer would pull out another credit card and buy the ticket! The money goes into the company bank account!

  • @AnubhavApurva
    @AnubhavApurva 11 місяців тому

    Thank you!

  • @gopalgowda9899
    @gopalgowda9899 11 місяців тому

    good job gentelmen!

  • @freezefrancis
    @freezefrancis Рік тому

    Very well explained.

  • @tonyyang8424
    @tonyyang8424 10 місяців тому +1

    I think in the reality, when customers are searching "available" flights, they are expected to get flights with availble seats, not the flights without seats. This means in the search path, we also need to visit some kind of inventory table to query available seats.
    Also, the flight table does not consider the situation that with one flight like "AA101", the flight will re-fly for the same routes iteratively, it is not one row can suffice that in the flght table.

  • @royalgoa
    @royalgoa Рік тому

    Hey, I have a question on the flight information and flight seat information table.
    I am trying to understand how you handled concurrency in the system. Are you implementing concurrency control using materialized conflicts? Are you going to have a record present for each flight-seat in the table even before a booking happens and then use locks to handle concurrent requests for the same seat?

  • @niranjhankantharaj6161
    @niranjhankantharaj6161 10 місяців тому +3

    In scaling estimates for flight seat info table,100B*100*100*365 = 365,000,000B ~ 365 MB... i see its 3.65GB. should that be 365 MB? please explain.Thanks!

  • @adityakirankorlepara4500
    @adityakirankorlepara4500 Рік тому

    Very well explained

  • @TheKshitijagrawal
    @TheKshitijagrawal Рік тому +2

    Suggestions - for flight information table, we have primary key as flight id but most relational dbs create unique index on primary key across partitions so we shall better than flight id and departure date as composite primary key. Though I like the idea of departure date as partition key. Here, we are assuming that if same plane does multiple round trips between two destination, each will have a separate flight id on given day. Also, instead of booking open, we can call that column as booking status - instead of just open and close, there could be more status like flight cancelled.

    • @ethanz4928
      @ethanz4928 10 місяців тому

      I thought each flight is unique in this world isn’t it?

    • @TheKshitijagrawal
      @TheKshitijagrawal 10 місяців тому

      @@ethanz4928 of course flight Id is unique. The concern here is not about uniqueness but accessing data faster for most common queries. As far as possible query shouldn't require search across partitions.

  • @shubh191
    @shubh191 3 місяці тому

    Thank you very much sir for informative video. This is really very helpful. It would be great if you could create video for coding for this airline system

  • @guitarkc5522
    @guitarkc5522 6 місяців тому

    fantastic video, would be even better to show how the site architecture will interact with multiple GDSs, airlines, and NDCs in real life scenarios

  • @uditagrawal6603
    @uditagrawal6603 10 місяців тому

    Date should also be part of seat information as booking status for a seat would be specific to date, same seat can be booked on one day and not on another.

  • @akhileshkumar-jy4ql
    @akhileshkumar-jy4ql 11 місяців тому

    Very informative

  • @saelkhlouf1695
    @saelkhlouf1695 Рік тому

    Thanks man, could you tell me which tool do you use for the drawing ??

  • @quarantine_made_me_do_it9014

    Great explanation! Thank you so much for the video. One question though, you mentioned towards the end that databases should support linearization/consistency, can you please tell how to actually achieve consistency in such a distributed storage system with multiple read/write nodes?

    • @edgecase6788
      @edgecase6788 8 місяців тому

      yes i agreee i did get same question in google and and I got offer.

  • @ishaancse1994
    @ishaancse1994 5 місяців тому

    Really helpful

  • @sweetphilly2
    @sweetphilly2 10 місяців тому

    The flight id in the Flight Seat Info is technically a Foreign Key, right? Seeing two PKs throws me off since I'm pretty sure you can't have two in a table

  • @lokeshmehta9591
    @lokeshmehta9591 10 місяців тому

    this is called content.

  • @santoshbhatnagar2155
    @santoshbhatnagar2155 3 місяці тому

    how does the movie booking companies handle the locking part, does this decision depends on the criticality of the usecase, for example we are okay with the user to retry here, we can take an optimistic locking and in other ways we choose pessimistic locking.

  • @Gerald-iz7mv
    @Gerald-iz7mv 7 місяців тому +1

    Can you use saga pattern instead of a 2 phase commit?

  • @jeremyshi4082
    @jeremyshi4082 5 місяців тому

    one small nitpick, the partition key on departure date doesn't make lots of sense. It can easily introduce scatter and gather problem if user searches a range of date. srce-destination is a good choice based on the access pattern.

    • @Adi-yi6qq
      @Adi-yi6qq 5 місяців тому +1

      Departure date partition key makes perfect sense. Why would anyone search for flights using a date range? Nobody provides such a feature either. Flight search is always done for a single date.

    • @Alex233xx
      @Alex233xx 5 місяців тому

      some src destination can be hotter than others, so it wouldnt make a good partition key. partition on flight id with departure date as sort key is probably a better option imo

  • @rumtek3559
    @rumtek3559 8 місяців тому

    No stones unturned !

  • @prabuddhadas935
    @prabuddhadas935 11 місяців тому

    i liked the the sound of water pouring

  • @rahulaga
    @rahulaga Рік тому

    nice content !! appreciate if you can zoom in bit.

  • @Gerald-iz7mv
    @Gerald-iz7mv 7 місяців тому

    Is pessimistic and optimistic lock implemented as a feature of the database?

  • @kidsarena4821
    @kidsarena4821 8 місяців тому

    Search service can have caching to reduce db read queries as most data may be static

  • @atabhatti6010
    @atabhatti6010 7 місяців тому

    Your flight seat information estimate (25:07) is off by a factor of 10.

  • @ankur20010
    @ankur20010 10 місяців тому

    Why can't we say that the search service should also be highly consistent? What if it is not consistent? If it is not. It can show seats as available which are actually not available

  • @chrishabgood8900
    @chrishabgood8900 11 місяців тому

    you need row locking so the seat will not be available

  • @abdulgafoormn
    @abdulgafoormn 5 місяців тому

    Scenario :
    Lets say while booking a seat, a seat is locked and ttl is set.
    After payment and updating booking status, it should update the seat state to 'BOOKED'.But we know that the same row is already locked and the update would fail, which would make the entire booking fail.

  • @user-bv2uc4rs9k
    @user-bv2uc4rs9k 7 місяців тому +1

    Hello, we are dedicated IT service team providing dedicated IT service to your business, we are looking forward to hearing from your team

  • @soumik76
    @soumik76 11 місяців тому +1

    You've completely ignored the complexities of search. How do you search for 1- stop and 2-stop international flights? Which db would you use? How would you distribute that kind of data?
    You'd need a graph db to sort this out. You don't even mention that