Тёмный

Design a Hotel Reservation System like Expedia & Kayak | System Design 

Code with Irtiza
Подписаться 12 тыс.
Просмотров 23 тыс.
50% 1

Let’s design a hotel reservation system similar to Expedia, Kayak, or Booking.com. We will talk about suitable databases, data modeling, double booking issue, and different ways we can scale the application.
Notes: pdfhost.io/edit?doc=6dd1fcf3-...
System Design Playlist: • System Design Beginner...
🥹 If you found this helpful, follow me online here:
✍️ Blog / irtizahafiz
👨‍💻 Website irtizahafiz.com
📲 Instagram / irtiza.hafiz
00:00 High-Level Features
01:27 Performance Considerations
03:30 API Design
05:52 What Database to use?
08:45 Data Model
12:34 Reservation Flow end to end
14:50 Make Reservations Idempotent
18:18 Database Locking & Constraints
22:25 How to Scale? Sharding & Caching
28:37 Database Change Data Capture to update the cache
30:10 Summary
#systemDesign #programming #softwareDevelopment

Опубликовано:

 

4 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@ashishrawat770
@ashishrawat770 Год назад
Wow!, so many concepts in a single video. Thanks a lot brother!!
@irtizahafiz
@irtizahafiz 8 месяцев назад
Glad you found it helpful! Cheers.
@jannismucke588
@jannismucke588 2 года назад
Thank you for your clear explanation. Keep it up
@irtizahafiz
@irtizahafiz 2 года назад
Glad it helped : )
@prajyotlawande193
@prajyotlawande193 3 месяца назад
Excellent explanation. 👌🏼
@sweetpotatoeater3169
@sweetpotatoeater3169 2 года назад
Amazing content
@timewarptrio11
@timewarptrio11 Год назад
very helpful!
@rajeshkishore7119
@rajeshkishore7119 5 месяцев назад
Excellent, room booking could have been covered with more detailed with rdbms isolation support
@rudeadyet1992
@rudeadyet1992 Год назад
thanks for this. very helpful. looking forward for the actual application video tutorial, that would be awesome.
@irtizahafiz
@irtizahafiz 8 месяцев назад
That's an idea I am playing around with. It's just a ton of effort and I am not sure how many people will actually watch a 2-3 hours long video.
@thijs7448
@thijs7448 7 месяцев назад
@@irtizahafiz Would be very interesting
@rudeadyet1992
@rudeadyet1992 7 месяцев назад
@@irtizahafiz I would enjoy and appreciate every bit of it and sure everyone would as well! :)
@jacob5253
@jacob5253 Год назад
It might be helpful to include some talk/discussion for ASYNC MQ / retries wherever possible in this system, this kind of system might not be scaled to that condition, but it's worth discussing with interviewer.
@irtizahafiz
@irtizahafiz Год назад
Yeah! Those are always good things to discuss with interviewer. Also, if the interviewer really cares about it, they will also prompt the candidate to talk about async processes.
@lunaxiao9997
@lunaxiao9997 Месяц назад
For peak hours, there should be a lot writes too
@lihewang6532
@lihewang6532 Год назад
I am a little confused by is_available column in Room table. Should it also have a Date column? since the room is usually available on certain date and not available on other date.
@shrimabaskar
@shrimabaskar Год назад
I think it would benefit to talk a bit about the service architecture, is there going to be multiple services (each with its own database) or a monolith. In case of a micro service architecture, we have to make sure we do distributed transactions.
@irtizahafiz
@irtizahafiz Год назад
Thank you for the suggestion! I tried to keep it simple to give a high level picture rather than dive into the details which might confuse some people.
@ziggyzhang4156
@ziggyzhang4156 Год назад
I feel like if the system is anywhere near expected large scale and we are already talking about sharding databases, distributed transaction in this case is inevitable. Unless we have both entire reservation table and inventory table living together on a single database instance node with no sharding, we need something like 2 phase commit to achieve distributed transactions.
@ziggyzhang4156
@ziggyzhang4156 Год назад
And regarding you using row versioning as optimistic locking approach, I'm not sure if that will work if that database change also needs to be a part of a distributed transaction using two phase commit? Basically by using 2PC in Prepare phase, an explicit lock has to be acquired on both inventory and reservation databases, as otherwise between Prepare and Commit, another thread could be changing the value if Prepare phase only ensures what it's about to write at the time was the up-to-date value.
@hecheng5049
@hecheng5049 Год назад
Great content! Have one question please. For user try to search the hotel by location(latitude, longtitude), I am thinking try to use Quartree to split the world to small grids, for each grid we can hash to a key, and value would be the hotel lists. These data we can use for our indexer service, we do not need to search the location in huge world map data anymore. But how we can store this Quartree data and how we can sharde the data please? if sharding the data by the grid key, what if some grids(locations) are too popular, then data servers are overloading.
@stephanbranczyk8306
@stephanbranczyk8306 7 месяцев назад
Personally, I'd use geohashing instead of quadtrees. They're similar concepts, but with geohashing, you'd just store a String for the geohash you want and you'd keep indexes of your hotel ids that way. As to server overloading, same idea, you could cache some of those indexes. Also, it's not like your list of hotels will change very much. (disclaimer: I'm not an expert. If I made a mistake in my reasoning, I'd welcome any correction).
@erfannariman
@erfannariman 2 года назад
Nice video as always, thank you for that! Just to be sure, in this data model, aren't you missing some kind of "fact" table. So if you want to look up when someone made a reservation, that is not possible with this data model, right?
@irtizahafiz
@irtizahafiz 2 года назад
Hi! Glad you enjoyed it : ) The idea I was going with here is that your "reservation" table will be the source of truth for all reservations. You can have a foreign key of "guest_id" for every reservation so that you can easily look up active/cancelled reservations by the guest_id.
@tello9504
@tello9504 2 года назад
Daaaamn, nice! Can you talk about how to calculate costs ?
@irtizahafiz
@irtizahafiz 2 года назад
Hi! Yes! I do have a video on that coming up, on how to do back of the envelope estimations to get a sense of scale.
@Luduin
@Luduin Год назад
I found this by chance. You don't do videos showing the coding or have the repository with such codes do you? As usual, i try to follow tutorials both to learn and to check if i can find different solutions. Im a beginner.
@irtizahafiz
@irtizahafiz Год назад
Hi, sorry! These are more from a conceptual point of vide. Don't think it's practical to code all these up. If you do want to look at some code though, for all my app builds in this channel, I link the code in the video description.
@hazemabdelalim5432
@hazemabdelalim5432 Год назад
you didn’t discuss the consistency in replica ? ( read after write ) ? also how would u handle the intersections between dates ?
@irtizahafiz
@irtizahafiz 8 месяцев назад
If you want strong consistency, you can either use a relational DB or tune your non-relational DB to have consistency (at the expense of availability).
@michealzhang8776
@michealzhang8776 2 месяца назад
Nice design Bro, if you could share the system diagram that would be great!
@irtizahafiz
@irtizahafiz 2 месяца назад
Thank you for watching! Unfortunately, I lost all the system diagrams :(
@senwang8670
@senwang8670 5 месяцев назад
on "How to avoid multiple users reserving the same room", isn't the reservation based on room type not specific room_id? you just need to increase the total_reserved value. The problem should be how to avoid over booking.
@user-eq4oy6bk5p
@user-eq4oy6bk5p 2 года назад
Can idempotency key be generated on client side? I've seen a client application passes UUID as idempotency token and backend will check if the client has passed the same key
@irtizahafiz
@irtizahafiz 2 года назад
Hi! Yes you can generate it on the client side too. But I would recommend just generating a reservation_id on the backend, so that you can use the unique constraint on your database rather than relying on client.
@jonamep
@jonamep 10 месяцев назад
How would be treated reservations that are not continuous ? For instance a user that booked day 1 and day 4 of the month only.
@irtizahafiz
@irtizahafiz 7 месяцев назад
That's a great question! I don't think I can answer that without going into specifics. I will make a note for a future video.
@Anteater23
@Anteater23 8 месяцев назад
How does the database keep track of how many rooms a particular hotel has on a specific date??
@irtizahafiz
@irtizahafiz 7 месяцев назад
You can just store by in a relational table.
@joesmith8462
@joesmith8462 Год назад
Great content. Where would you recommend we go for the actual API? If you have a specific subset of 1000 hotels, would you aim to make deals directly with the channel managers or obtain rates from somewhere like an aggregator or bed bank which would sacrificing a big portion of the commission? Any feedback deeply appreciated!!!!!!!!
@schan263
@schan263 5 месяцев назад
Your design doesn't support multiple rooms reservation?
@irtizahafiz
@irtizahafiz 5 месяцев назад
It should be relatively easy to expand to that use case.
Далее
System Design: Hotel Booking
44:11
Просмотров 56 тыс.
Кто Первый Получит Миллион ?
27:44
Introduction to Payment Systems | System Design
40:56
How I would design a reservation system
6:44
Просмотров 17 тыс.
Database Design for a Hotel Management System
12:14
Просмотров 11 тыс.