Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There is movie ticket booking application of n-tier application which contains web,business,data,and we api layer in asp.net mvc .suppose 1000 of users make request at the same time to book the same seat .how to prevent another users from booking.Whether we should include some other component in the application.Please guide me the best solution in terms of architecture also.

What I have tried:

Checked with updated date column in database so that can handle another users from updating into database.but this not handles concurrency.
Posted
Updated 27-May-19 11:37am

See the answer here how to handle database concurrency: c# - What's the best way to manage concurrency in a database access application? - Stack Overflow[^]

And this CodeProject article: 6 ways of doing locking in .NET (Pessimistic and optimistic)[^]

Here is an overview of locking mechanisms by the writer of C# in a Nutshell: Threading in C# - Part 2 - Basic Synchronization[^]
 
Share this answer
 
v3
Comments
Prasad Nikumbh 28-May-19 13:02pm    
I don’t need to check and hit the database multiple times..suppose there are 1000 users at a time..one first user should get booked..and other should block..how to identify that if sending request simultaneously.
The "first" user puts the "booking" in "suspense". The others get bounced.

If after 5 minutes (for example) the booking is "confirmed" (payment confirmed), then the booking is "reserved", else it is returned to the pool (time based trigger(s)).
 
Share this answer
 
Comments
Prasad Nikumbh 28-May-19 13:03pm    
Yes u r ryt but how to identify which is the first user..if multiple request comes at a time..simultaneously.
when you put in suspense you need to decrement the overall inventory else there is no point of doing this.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900