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…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.