Wrap Up
In this chapter, we presented a design for a hotel reservation system. We started by gathering requirements and calculating a back-of-the-envelope estimation to understand the scale. In the high-level design, we presented the API design, the first draft of the data model, and the system architecture diagram. In the deep dive, we explored alternative database schema designs as we realized reservations should be made at the room type-level, as opposed to specific rooms. We discussed race conditions in depth and proposed a few potential solutions:
-
pessimistic locking
-
optimistic locking
-
database constraints
We then discussed different approaches to scale the system, including database sharding and using Redis cache. Lastly, we tackled data consistency issues in microservice architecture and briefly went through a few solutions.
Congratulations on getting this far! Now give yourself a pat on the back. Good job!
Chapter Summary
Chapter Summary
Reference Material
- Microservices: https://en.wikipedia.org/wiki/Microservices
- What Are The Benefits of Microservices Architecture?: https://www.appdynamics.com/topics/benefits-of-microservices
- gRPC: https://www.grpc.io/docs/what-is-grpc/introduction/
- Source: Booking.com iOS app
- Serializability: https://en.wikipedia.org/wiki/Serializability
- Optimistic and pessimistic record locking: https://www.ibm.com/docs/en/rational-clearquest/10.0.7?topic=clearquest-optimistic-pessimistic-record-locking
- Optimistic concurrency control: https://en.wikipedia.org/wiki/Optimistic_concurrency_control
- Change data capture: https://docs.oracle.com/cd/B10500_01/server.920/a96520/cdc.htm
- Debezium: https://debezium.io/
- Redis sink: https://debezium.io/documentation/reference/stable/operations/debezium-server.html
- Monolithic Architecture: https://microservices.io/patterns/monolithic.html
- Two-phase commit protocol: https://en.wikipedia.org/wiki/Two-phase_commit_protocol
- Saga: https://microservices.io/patterns/data/saga.html
Finished reading?
Mark it complete to track your progress.