Strategy Battle ArenaHigh-Contention Head-to-Head

Side-by-Side Concurrency Race

Compare overselling behavior, lock contention latency, and Redis-DB drift under identical traffic.

UNSAFE BASELINEReady

Unsafe DB Baseline

Performs read-modify-write without conditional checks. Under 100 concurrency, multiple threads read the same positive stock, resulting in severe overselling (negative DB stock).

Accepted

0

Rejected

0

Oversold

0 (SAFE)

Throughput

—

Redis Stock:0
MySQL DB Stock:0
Drift Inconsistency:0
INTERMEDIATEReady

MySQL Conditional Lock

Uses `WHERE stock >= quantity`. Prevents overselling (0 oversold), but high concurrency creates severe InnoDB row lock queueing and HikariCP connection pool saturation.

Accepted

0

Rejected

0

Oversold

0 (SAFE)

Throughput

—

Redis Stock:0
MySQL DB Stock:0
Drift Inconsistency:0
INTERMEDIATEReady

Redis Lua Pre-Deduct

Single-threaded Redis Lua script gates capacity at lightning speed (<2ms). Rejects 95%+ excess requests at cache boundary, but can drift if DB fails after Redis decrement.

Accepted

0

Rejected

0

Oversold

0 (SAFE)

Throughput

—

Redis Stock:0
MySQL DB Stock:0
Drift Inconsistency:0
GOLD STANDARDReady

Redis Lua + Compensation

Golden standard. Redis Lua gates incoming burst traffic and immediately triggers compensating rollback (`reservation-compensate-once.lua`) if downstream DB fails. Zero oversell, zero drift.

Accepted

0

Rejected

0

Oversold

0 (SAFE)

Throughput

—

Redis Stock:0
MySQL DB Stock:0
Drift Inconsistency:0