A high performance distributed inventory locking system designed to prevent race conditions in high-traffic e-commerce environments.
Spring Boot 3, AWS(S3), Redis, Next js 15, PostgresSQL(supabase), hosting - render, vercel
-
The Problem: Traditional database locking (PostgreSQL) causes deadlocks and high latency when 10,000+ users try to buy a limited-stock item simultaneously.
-
The Solution: Implemented Redis Lua scripts to handle inventory validation atomically in-memory before persisting data to the database.
- High concurrency - optimized to handle 10k+ requests per second. (RPS)
- Deadlock Reduction - Decoupled validation from persistence, slashing DB contention by 80%.
- Atomic Locking - Used Redis Lua scripts to ensure "Exactly-once" processing for inventory updates.
- CI/CD & Security - Automated testing with GitHub Actions and security scanning with CodeQL.
- Frontend (Next.js): flash-guard.vercel.app
- Backend (Spring Boot): flashguard.onrender.com
[x] core redis locking logic.
[x] spring boot API integration.
[x] AWS S3 image hosting.
[x] Advanced analytics dashboard.
The API is fully documented and tested using Posstman.
- Postman Collection: You can find the raw JSON collection here
- How to test:
-
- Import the collection into postman.
- Set the
base_url. - Run the "Stress Test" folder ot simulate inventory lockinng.
{
"oversold": 0,
"successfulLocks": 8,
"avgLatency": 54.0939,
"productId": 6,
"totalRequests": 10000
}- Unit tests: JUnit & Mockito for service logic.
- Stress testing: simulated 10k concurrent users to validate redis performance.
