182 days ago · 8 min read1644 words · Tech · hide · Fediverse post

How do reservation systems prevent thousands of concurrent users from booking the same seat? 🤔Building such a system is challenging since it needs to handle high throughput, co-ordinate multiple actions (booking, payment, notification, etc) and prevent double booking. At its core, the problem is - To guarantee mutual exclusion while accessing a shared resource in a distributed system. Engineers solve this problem using a well known pattern - Distributed lock. The pattern safeguards the underlying resource from any side-effects of concurrent modification.Before understanding how distributed locks work, let’s revisit our concurrency fundamentals for a single node system. We will then evolve the solution and extend it to distributed systems.Subscribe nowSingle-Node In-memory SystemsLet’s say we have a booking system that stores the data in the memory. The application consists of:User threads - These handle concurrent user requests.Shared data structure - An array-like data structure that…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town