After doing some investigation* I have learned that I could potentially have a concurrency problem.

I'm currently building a Tournament Platform in ASP.NET MVC 5 with Entity Framework 6. So far, I've never had concurrency problems (Mostly because they fell into the overly-optimistic scenario). I ask money for people to enter (through PayPal) in some tournaments which are limited in quantity (say max. 32 players). What would happen if 50 people at the same time would try to enter the tournament?

So this presents a situation very similar to the "single quantity" or "shopping system cart problem with stock" links that I refer above. Unfortunately none of them actually come up with actual answers. Nonetheless, I have the advantage that the user must pay beforehand "to put the product in the basket". This means that there is no way of "reserving" or "gathering" the "product" before actually paying for it.

So far, what I'm thinking on doing is the following: The user clicks for registering into the site. It checks if there max capacity has not been reached. Then, it creates a "temporary placeholder" for the user to process the payment. So when others check, it will check both: the users who are currently registered and the ones in the temporary placeholder.

But there could be a flaw in my way of thinking:

1st) What if,in the moment the user is about to enter, the limit was not hit, but 10 seconds later, when he is about to commit his purchase, the max players number has been reached?

I could check exactly before the payment is sent, but what if there are many users doing the same thing? ...

I could order them through a timestamp and "sort-them-out" in a ordering and only select the first 32... would that work?

* Integrating with a payment provider; Proper and robust OOP approach
How do I handle online payment for items with single quantity?
Optimistic Concurrency: Overview
shopping system cart problem with stock
How do I verify if 3rd party payment succeeded?

  • 1
    PayPal can set up a storefront with limited-quantity items, so you may not need to worry about this. I don't know if you can programmatically add items, though (probably, I would imagine). Jun 4, 2016 at 14:18
  • :o! That's super interesting! I'll look deeper into that!
    – Jose A
    Jun 4, 2016 at 14:32

1 Answer 1


Look at the way TicketMaster and similar sites do it.

What they do is take the item off the shelf for a brief period of time and start a transaction while the user consummates the payment. If the user fails to complete the payment during that brief period, the entire transaction is cancelled, the item goes back on the shelf, and the user has to start over.

  • It makes sense. I'm going to do exactly as you say. I'll give them a 1-minute timer for finishing the payment.
    – Jose A
    Jun 3, 2016 at 20:55
  • 1
    Ticketmaster gives you 3 minutes to commit. 1 minute is not a lot of time to complete a payment. You can also give them a button to put the item back on the shelf during the 3 minute window. Jun 3, 2016 at 20:55
  • Thanks for the tip. It's a tournament system in which the user would pay immediately and fall back to PayPal. I think that the 3 minute is a good timespan anyways.
    – Jose A
    Jun 3, 2016 at 21:45
  • What about concurrent requests to take the last item off the shelf hit? If you allow 2 people to concurrently start a 3 minute timer to buy the last ticket, and both complete and pay, then you've over-sold. Jan 13, 2017 at 18:32
  • 1
    @jinglesthula: If you design your system properly, based on a database that has ACID capabilities, you should never have this problem. One person will get the lock, the other person will be locked out. Jan 13, 2017 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.