Engineering12 min read

Building a Real-Time Inventory System at Scale

A deep dive into how we architected our inventory management system to handle thousands of concurrent bookings with sub-second latency and zero double-bookings.

V
Vikram Patel
Staff Engineer
January 15, 2026
Building a Real-Time Inventory System at Scale

The Double-Booking Problem

In a rental marketplace, double-booking is the cardinal sin. When two customers try to book the same item for overlapping dates, exactly one should succeed — instantly, consistently, and without race conditions.

Sounds simple? At scale, it's anything but. With 50,000+ active listings, 10,000+ daily booking attempts, and users spanning multiple time zones, our initial PostgreSQL-based availability check couldn't keep up. We experienced a 0.3% double-booking rate during peak hours — unacceptable for a trusted marketplace.

Architecture Overview

Our solution combines three layers:

1. Redis-Based Locking — When a booking attempt begins, we acquire a distributed lock keyed to the listing ID and date range. The lock has a 30-second TTL (time-to-live) to prevent deadlocks if a process crashes.

2. PostgreSQL with Range Types — We use PostgreSQL's native daterange type with exclusion constraints to enforce non-overlapping bookings at the database level. This serves as our source of truth and provides a safety net if the Redis layer fails.

3. Event-Driven Sync — All availability changes are published to a Kafka topic, consumed by our search index (Elasticsearch) and notification service. This ensures that listing availability is updated across the platform within 500ms of a booking confirmation.

Performance Numbers

After the migration:

- Double-booking rate: 0.000% (zero incidents in 6 months) - Average booking confirmation time: 180ms (down from 2.3 seconds) - Concurrent booking capacity: 5,000+ per second - Availability query latency (P99): 12ms

The system has handled peak loads during Diwali season (3x normal traffic) without any degradation.

Lessons Learned

Building this system taught us several valuable lessons:

1. Defense in depth matters — Redis handles the fast path, but PostgreSQL constraints catch edge cases. Never rely on a single layer for data integrity.

2. Idempotency is essential — Every booking operation is idempotent. Network retries, app crashes, and timeout scenarios all produce correct results.

3. Observability first — We built comprehensive dashboards before the migration. Every lock acquisition, release, and timeout is tracked in Prometheus and visualized in Grafana.

4. Test with chaos — We ran chaos engineering experiments (random Redis node failures, artificial network partitions) during staging. The system handled every scenario without data inconsistency.

Share
V
Written by
Vikram Patel
Staff Engineer

Welcome Back

Or continue with

Don't have an account?

Checkout

Partial delivery or collection alert

Include multiple pickup or delivery methods.

Providers Delivery
Range Rover Sports Special Edition..

Range Rover Sports Special Edition..

1
1 Unit
136369999
Oct 12 - 14 (3 days)
Courier Delivery
Toyota Land Cruiser 4WD..

Toyota Land Cruiser 4WD..

1
1 Unit
136369000
Oct 12 - 14 (3 days)
Self-pickup
Fancy Chair for parties and..

Fancy Chair for parties and..

1
1 Unit
13636999
Oct 12 - 14 (3 days)
Pickup Location
AutoParts Store - Main Branch

123 industrial road, sector 5 Mumbai,
Maharashtra 400001

Range Rover Sports Special Edition..

Range Rover Sports Special Edition..

1
1 Unit
136369999
Toyota Land Cruiser 4WD..

Toyota Land Cruiser 4WD..

1
1 Unit
136369000
This product is available for self-pickup only
Fancy Chair for parties and..

Fancy Chair for parties and..

1
1 Unit
136369999
Oct 12 - 14 (3 days)
Pickup Location
AutoParts Store - Main Branch

123 industrial road, sector 5 Mumbai,
Maharashtra 400001

Yay! You saved ₹300

Coupon Applied!

Bill details

Items totalSaved ₹9,999
₹12345112345
Delivery charge
₹12FREE
Handling charge
12345
Grand total124802
Your total savings9999
Includes ₹30 savings through free delivery

Cancellation Policy

You can cancel your booking anytime before 24 hrs of pickup or delivery for a full refund. After that, a fee may apply. If we cancel due to an issue on our side, you'll get your money back in full.

Messages

Rahul Sharma

Rahul Sharma

10:30 AM

Is the camera still available for rent?

2
Priya Patel

Priya Patel

Yesterday

The bike was amazing, thanks!

Amit Verma

Amit Verma

Monday

Sending the location now.

Provider Type

Select your provider type

This choice impacts your rental process and compliance requirements

Individual Provider

You are a single service provider.

Business Provider

You are a business with multiple service providers.

Please Note: Your selection will affect the types of items you can list and verification process you'll need to complete

Welcome Back

Or continue with

Don't have an account?

Select Location

Select Delivery Location

Your saved addresses

Home

Kalyani Business Centre,3rd Floor, Office No. 305, R. B. Kadam Marg, Opposite Mahalaxmi Garden, Shahupuri East, Kolhapur - 416012

Phone number: 0231-9988776

Home

Shree Vasant Vihar, Flat No. 502, Tower B, S. R. Patil Road, Near Rajaram Maharaj Mandir, Gokul Nagar, Kolhapur - 416008

Phone number: 0971-9656789