0
0
LLDsystem_design~3 mins

Why booking tests availability and concurrency in LLD - The Real Reasons

Choose your learning style9 modes available
The Big Idea

What if a simple mistake in booking could cause chaos for hundreds of patients waiting for tests?

The Scenario

Imagine you run a small clinic and manage test bookings using a simple paper calendar. Patients call in, and you write down their appointments by hand. Sometimes two patients get booked for the same time slot because you missed updating the calendar quickly enough.

The Problem

This manual method is slow and prone to errors. You can easily double-book a test slot, causing confusion and unhappy patients. It's hard to know in real-time which slots are free, and managing many bookings becomes overwhelming as your clinic grows.

The Solution

By designing a system that tracks test availability and handles concurrency, you ensure that no two bookings overlap. The system updates instantly, preventing double bookings and showing real-time availability. This makes managing appointments smooth and reliable.

Before vs After
Before
if slot not in booked_slots:
    booked_slots.append(slot)
else:
    print('Slot already booked')
After
lock(slot)
if slot not in booked_slots:
    book(slot)
unlock(slot)
What It Enables

This approach enables seamless, real-time booking management that scales effortlessly as demand grows.

Real Life Example

Online appointment systems for COVID-19 tests use availability and concurrency controls to prevent overbooking and long wait times.

Key Takeaways

Manual booking leads to errors and double bookings.

Concurrency control prevents overlapping appointments.

Real-time availability improves user experience and scalability.