11: Design TicketMaster/StubHub | Systems Design Interview Questions With Ex-Google SWE

Поделиться
HTML-код
  • Опубликовано: 21 ноя 2024

Комментарии • 78

  • @knightbird00
    @knightbird00 10 дней назад +2

    Bookmarks
    3:45 Ticket claim approaches - no claim FCFS, with TTE, with TTE along with wait list [perhaps for all site like queueit]
    7:45 Data partition
    12:30 Claim expiration, fair claim etc

  • @landocodes
    @landocodes 9 месяцев назад +11

    Jordan you’re the sh*t bro thanks for taking the time out to create all these videos! This channel is by far the best resource I’ve found for system design.

  • @Ynno2
    @Ynno2 8 месяцев назад +3

    Ticket booking sites have waiting lists, but I've never seen one that has waiting lists for specific seats or rows. They have a waiting list (like a "deli ticket" system) *before* entering seat selection/checkout. Sometimes that's strictly FIFO, but in some cases you join a "lobby" and your position in queue is randomly or semi-randomly assigned when tickets go on sale. Buyers in the queue are then admitted to seat selection in batches.
    The point of these systems is to reduce load on the seat selection and checkout systems. I.e to avoid the thundering herd you mentioned a few times. The question to ask is how do you design a system to handle extreme QPS peaks by spreading out the load over time.
    The solution presented in this video where you shard by section or row doesn't really solve the hot shard or thundering herd problems.
    Front-row center is always going to be the most popular row. At least if I understand your design correctly, all buyers will simultaneously enter seat selection at the same time. And most of those people are going to compete for the same most desirable seats. Those will be very hot shards, which hundreds of thousands of people will be hitting simultaneously for popular events.
    Then once seats are selected, usually you have a few minutes to complete payment. So then you will have tens of thousands of people who managed to select seats hitting your payment systems at the same time.

    • @jordanhasnolife5163
      @jordanhasnolife5163  8 месяцев назад

      Yeah I covered that in like the first few minutes of the video. Agreed that it's not that crazy of a problem, hence why I think it's stupid that everyone bothers asking it. Agreed that the hold off approach is more practical, though I do suppose it can lead to a thundering herd when one person's timeout ends.

    • @AP-eh6gr
      @AP-eh6gr 7 месяцев назад +1

      @@jordanhasnolife5163 agreed, hot sharding has been mentioned here, and should be remarked as something to fix with the help of dynamic re sharding/autoscaling+loadbalancing

  • @DevGP
    @DevGP 9 месяцев назад +4

    Jordan, thank you so much for the uploads!! Appreciate all your videos !

  • @shreekss2539
    @shreekss2539 9 месяцев назад +2

    Thanks dude for the videos. I just started with the system design 2.0 playlist and already learned a great deal.

  • @siddharthgupta6162
    @siddharthgupta6162 9 месяцев назад +1

    Awesome content again. Thank you for all that you do, Jordan!

  • @MansiKishoreRanka
    @MansiKishoreRanka 4 месяца назад +1

    Thank you for making these videos. They are very helpful. Would it be possible to make a video on monitoring as well? Or maybe introducing a monitoring setup in one of the applications? Thanks again!

  • @mohamedmacow3610
    @mohamedmacow3610 7 месяцев назад +2

    Love these videoes man, helping me crank up my growth trajectory

  • @woahblow4127
    @woahblow4127 7 месяцев назад +1

    Fandango locks tickets when you go to the payment page using a separate database table with a ttl. There's a session timeout hook and back event to clear out the table as well. The actual available seats are still returned for the show for next user, but are greyed out by cross referencing against that other table.

    • @jordanhasnolife5163
      @jordanhasnolife5163  7 месяцев назад

      That doesn't surprise me, that's basically the first solution I cover. The second one is complete overkill and is really only in there because I have no idea what an interviewer will ask for :)

  • @sameer7483
    @sameer7483 9 месяцев назад +1

    Thank you so much for these videos. They are by far the best. A couple of questions, Can we CDC from a server, I see that in the final diagram? I thought we could have it only from database tables.
    Also, when should we consider using an In-memory message broker instead of Kafka? In most of your videos, you have used Kafka.

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад

      We're doing CDC from redis here, but even still CDC from a server would just be sinking to Kafka!

  • @fluffymattress5242
    @fluffymattress5242 6 месяцев назад +1

    Hey Jordan, really love your videos. Could you please attach the sources (if there are any) for videos that have " question specific" concepts like Fair claim implementations in this video, Route recreations in your Uber video etc...

    • @jordanhasnolife5163
      @jordanhasnolife5163  6 месяцев назад +2

      Sometimes there are sources, in this one there aren't really. This time around I've mostly been trying to avoid external sources, as I think that they cause me to laser in on one potential approach and not think about things rationally. That's not to say I haven't considered other approaches, I just am also using my old videos for inspiration, where I actually relied more heavily on sources.

  • @Luzkan
    @Luzkan 9 месяцев назад +2

    24:34 I thought about putting orders into a message que, but then, the clients can't receive an asap information whether they have claimed something or they are waiting in queue. If we do that as "Client -> ClaimService -> MQ -> DB" then ClaimService cannot tell the Client in real time what is happening with his claim after it publishes to the queue... or can it?
    Great video Jordan as always!

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад +1

      So in this case, the DB is a derived data store, the claim service is actually the source of truth for both bookings and claims, hence why we can tell the client in real time whether they have booked.
      Thanks and I hope this makes sense!

    • @Luzkan
      @Luzkan 9 месяцев назад

      @@jordanhasnolife5163 ah yeah, makes sense. Brain farted on that one, thanks

  • @tfk933
    @tfk933 6 месяцев назад +2

    The real answer is that I don't care at all about the high traffic scenario. That accounts for 1% of my total events, and those are so popular that 100% of tickets will be sold no matter what. It doesn't matter if the system is fair, of if the UX is terrible, or even if it goes down. That's just the difference between selling all the tickets in 1 minute and selling them all in 10 minutes. Same revenue. The important part is the UX for all the customers buying tickets to less popular events. If you put them off, you might actually fail to sell a ticket that you could have.

    • @jordanhasnolife5163
      @jordanhasnolife5163  6 месяцев назад +2

      This may be the case for you, and it may even be the case for ticket master, but I'm curious if it'll be the case for your interviewer

    • @tfk933
      @tfk933 6 месяцев назад +1

      @@jordanhasnolife5163 Probably not. Which is why I'm binge watching your channel.

    • @jordanhasnolife5163
      @jordanhasnolife5163  6 месяцев назад

      @@tfk933 Welcome good sir

    • @zephyrakash2003
      @zephyrakash2003 14 дней назад

      This comment has a separate like base. The horizon where software development meets sales and business !!

  • @abcxyz9637
    @abcxyz9637 2 дня назад

    Assigning N seats in a section to a group of k people each requesting {s_1, ..., s_k} seats is a Bin-packing problem. Simply allocating seats in FIFO order may lead to unfairness and sub-optimal allocation (people at the end of the list and requesting higher number of seats will be most impacted; and we want to sell as many tickets as possible). Although, it's not practically possible to solve Bin-packing in real-time, a simple optimization would be to maintain the sum of total seats requested by people for every section. In real-time, while the bookings are on-going, that sum must not exceed N. The actual seat allocation may be done offline e.g., seats can be finalized after the booking closes, and the users can be sent their tickets via mail/phone [AWS SNS] with actual seat numbers.

  • @rakeshvarma8091
    @rakeshvarma8091 6 месяцев назад +1

    Hi Jordan
    Can you help me clarify this:
    You said we are going to do a hash range partition on (EventId + SectionId + RowId) for OrderClaimServers.
    1. You are referring to consistent hashing here isn't it ?
    2. If we are doing a hash range partitioning, how can we ensure that seats with same rows end up on same partition ?
    Anyways, appreciate all your hardwork.

    • @jordanhasnolife5163
      @jordanhasnolife5163  6 месяцев назад

      1) Yes
      2) Because seats in the same row have the same event Id, section Id, and row Id :)

  • @yiannigeorgantas1551
    @yiannigeorgantas1551 Месяц назад +1

    Hey Jordan, quick question about 34:35. If we were to write to the replica or kafka synchronously, is that considered a "two phase commit"? Or does that term only apply when we try to do a distributed transaction across two services, with a third service coordinating the process?

    • @jordanhasnolife5163
      @jordanhasnolife5163  Месяц назад

      I'd say a two phase commit is a two phase commit if rather than pipelining writes like in synchronous replication, you have one coordinator making writes in a prepare and commit phase, hence the name "two phase" commit

  • @AjItHKuMaR-ns5yu
    @AjItHKuMaR-ns5yu 5 месяцев назад +1

    Hi Jordan. Could you please tell me how the reads would flow for a particular event. That is, when user logs in and searches for an event, how do we read for available seats? Does the request go to DB ( if so isn't the data stale as cache is current?), does it go to cache? ( if so, since each row is in different partition, do we need to query every row for an event and then aggregate???).
    Thanks!

    • @jordanhasnolife5163
      @jordanhasnolife5163  5 месяцев назад +1

      I think reading from the cache would be sufficient, and yeah as you mentioned depending on the front end settings here we may have to perform a query on a few caches.

  • @AjItHKuMaR-ns5yu
    @AjItHKuMaR-ns5yu 9 месяцев назад +1

    Hi Jordan. I am confused the concept of waiting for tickets. I took a look at the ticketmaster, a seat is either available or blocked, whether a use completes the payment or not. If the payment doesn't go through, the blocked seats are released for booking.
    My question is why would a user want to wait on a seat for 10mins when the chances of getting it are slim? wouldnt he just look for different seats in different section. I dont get why this waiting for tickets feature exists at first place. What are we exactly trying to solve?

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад +1

      Yeah you basically described why I don't like this problem.
      There are a million different ways to build a ticket booking site. What you just described is the "unfair solution", which I covered in this video as well. But that one's easier so felt I'd take things up a notch haha

  • @gokukakarot6323
    @gokukakarot6323 3 месяца назад +1

    Could you also discuss a raffle system, in any system design video like this later? Its something nike does to handle bots. I mean a third party service does it for them, but anyway seems alright.

    • @jordanhasnolife5163
      @jordanhasnolife5163  3 месяца назад

      I probably won't make a video on this in a while but I'd just batch everything in kafka, and then have some consumer that after a certain point in time picks the winners and then notifies the winners via some sort of fan out (email, notifications, etc).

  • @Adityaq3k
    @Adityaq3k 2 месяца назад +1

    Hi Jordan, how do you plan to invalidate a fencing token if no subsequent request comes in from the user? For example, if a user with userID 123 receives a fencing token like and then drops off, how would those reserved seats become available for someone else?
    Do we need to have some sort of cron jobs in background to set those particular rows back to available ?

    • @jordanhasnolife5163
      @jordanhasnolife5163  2 месяца назад

      You don't need to "invalidate" a fencing token. A server simply checks if it's seen a fencing token with a higher number before and that tells you whether to disregard this one.
      As for when to make seats "available" again, we use a TTL for that. The fencing token protects us against delayed packets from old lock owners.

    • @Adityaq3k
      @Adityaq3k 2 месяца назад

      @@jordanhasnolife5163 Got it. Thank you.

  • @LawZist
    @LawZist 9 месяцев назад +1

    great video

  • @senthilrajanr1
    @senthilrajanr1 9 месяцев назад +1

    Jordan, thank you so much. Can you please share the notes for all the videos. Thanks

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад

      Hey Senthil, when this series is over I'll upload all of the notes in batch!

    • @senthilrajanr1
      @senthilrajanr1 9 месяцев назад

      @@jordanhasnolife5163 Thanks a bunch.

  • @ariali2067
    @ariali2067 8 месяцев назад +1

    Hey Jordan, sorry I am getting a bit confused here. Is what you presented in the end basically a write through cache? And to keep data consistent between cache & DB -> we use change data capture instead of 2PC to speed things up? If this is the case, why you also mentioned write back cache at the beginning? That won't guarantee this cache & DB consistency at all right?

    • @jordanhasnolife5163
      @jordanhasnolife5163  8 месяцев назад +1

      Hi Aria - yes albeit it's not a true write back cache because it holds additional data to the bookings (namely the queues).
      As for your second question, yes. CDC should help us guarantee *eventual* consistency, which is different than two phase commit (that's what we'd use with a write through cache, not a write back cache which is eventually consistent)

    • @ariali2067
      @ariali2067 8 месяцев назад

      For such ticket purchasing system, is eventual consistency okay? If we serve all the read/write requests via cache and it's replicated, curious how can we guarantee atomic operations with cache? @@jordanhasnolife5163

    • @ariali2067
      @ariali2067 8 месяцев назад

      Thanks for the response. For this kind of ticket purchasing system, can we just guarantee eventual consistency? I assume we should have stronger guarantee. It seems what you mentioned here is that we use cache as source of truth and use write back cache to sync to DB. In this case, how can we guarantee in distributed settings (reads /writes) from caches are synced with each other? eg: one user read from cache1 see a seat is bookable and book it, and that write is not synced to cache2 and user from cache2 also booked it? Getting a bit lost here and appreciate your help! @@jordanhasnolife5163

  • @afuyewale5648
    @afuyewale5648 9 месяцев назад +1

    Jordan, what about saving the ticket claim on redis with ttl and redis can takes that off when time expires

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад +1

      Hey! I think that's ok but then you run into the two phase commit issue of having to store the booking into a database (I'm assuming you're talking about the "unfair" implementation)

    • @pe2317
      @pe2317 9 месяцев назад

      @@jordanhasnolife5163 why is that the case? Redis has master-slave replication.

  • @kaushikkomanduri4126
    @kaushikkomanduri4126 9 месяцев назад +1

    Hey jordan is it possible at all to share your beautifully well written (except for the narcissism) notes? 🥺👉🏻👈🏻

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад

      Lol - hey Kaushik! I'll do this eventually, but will probably do a bulk export once I finish my current series in like 2 months

    • @kaushikkomanduri4126
      @kaushikkomanduri4126 9 месяцев назад +1

      @@jordanhasnolife5163 hmm makes sense. anyways keep shit posting technical stuff dude. I will be a loyal subscriber XD

  • @3rd_iimpact
    @3rd_iimpact 9 месяцев назад +1

    Hey, Jordan, do you have any content on product architecture?

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад

      Not sure what you mean by product architecture but I'd just take a scroll through my existing videos and see what seems useful to you

    • @3rd_iimpact
      @3rd_iimpact 9 месяцев назад +1

      @@jordanhasnolife5163 Thanks for replying. Some companies have a product architecture round instead of system design. But yeah, I’ll have a look at your videos.

  • @gatodetaco
    @gatodetaco 9 месяцев назад +2

    What about a distributed lock?

    • @jordanhasnolife5163
      @jordanhasnolife5163  9 месяцев назад

      What for?

    • @gatodetaco
      @gatodetaco 9 месяцев назад

      @@jordanhasnolife5163 Ah let me clarify sorry. I meant for locking on ticket_id with TTL using something like redlock in order to avoid the double purchase problem. Great video btw thanks for illuminating us peasants.

    • @edgecase6788
      @edgecase6788 8 месяцев назад

      @@gatodetaco It wont scale imagine 10k million people waiting on distributed lock for some seat

  • @chaitanyatanwar8151
    @chaitanyatanwar8151 3 дня назад

    Thank you!

  • @pmandala1583
    @pmandala1583 6 месяцев назад +1

    Hi, Dont we need two phase commit to processes payment and update balance seats?

    • @jordanhasnolife5163
      @jordanhasnolife5163  6 месяцев назад +1

      In this case, no for the seat balancing given the cache is our source of truth. Maybe for payments, but you could also just let them claim the seat, ask for payment, and if it doesn't come by a certain time, revoke the seat.

  • @madhuj6912
    @madhuj6912 Месяц назад +1

    Can you some tell me is this product design or system design? I'm very confused with meta
    SD and PD

    • @jordanhasnolife5163
      @jordanhasnolife5163  Месяц назад +1

      I think they're basically the same, with PD having a slight emphasis on the API

    • @madhuj6912
      @madhuj6912 Месяц назад +1

      @@jordanhasnolife5163 thanks man for your reply.. Really appreciate it.. Got confused between two

  • @marcosoliveira1538
    @marcosoliveira1538 4 месяца назад +1

    Now I know why I did not get Taylor Swift tickets!
    Just kidding

  • @i-am-the-slime
    @i-am-the-slime 8 месяцев назад +1

    Fucking ticket master US wouldn't sell me a ticket with a German credit card. I hope you consider this in your design.

  • @akhilmittalji6816
    @akhilmittalji6816 Месяц назад +1

    27:37 How come DLL turned into a TreeSet for deleting scenario?

    • @jordanhasnolife5163
      @jordanhasnolife5163  Месяц назад

      These would basically be two separately maintained indexes. Perhaps gets a bit complicated when you accept an order and need to delete it from the treeset, could be short sighted on my end.

  • @fdddd2023
    @fdddd2023 4 месяца назад +1

    You're great guy but I think you overcomplicated that a bit - hellointerview has much simpler solution

    • @jordanhasnolife5163
      @jordanhasnolife5163  4 месяца назад

      This feels like you're breaking up with me
      Jk, I know this problem was particularly convoluted, because normal ticket master is just... use a database.