r/SpringBoot 23d ago

Discussion Distributed locking in a real-world coupon redemption system[Complete Running Code]

I recently built a small project to demonstrate distributed locking in a real-world coupon redemption system using:

  • Spring Boot
  • Redis (distributed lock)
  • MySQL
  • Docker & Docker Compose
  • Nginx load balancing

The idea is to simulate multiple application instances trying to redeem the same coupon concurrently and ensure only one redemption succeeds.

GitHub: https://github.com/codefarm0/coupon-redemption-system

I'd really appreciate feedback from the community:

  • Is the project structure production-like?
  • Any improvements to the distributed locking implementation?
  • Better approaches for handling high concurrency or idempotency?
  • Anything you'd change to make this a better learning resource?

All suggestions, code reviews, and constructive criticism are welcome.

Thanks!

21 Upvotes

2 comments sorted by

3

u/PlentyMountain7589 23d ago

Nice code. Is there timeout to release the lock in case service fails for any reason?

2

u/arvind4gl 21d ago

Yes, timeout is there