Using innoDB tables and mysqli wrapper in PHP for queries.
We are currently having an issue where we're getting a spike in traffic requesting the same script 1,500 times per second.
The situtation is that the first X amount of users to access the script win a prize.
The prize is a single record on a table "prizes" that has a count of the # claimed and the # alotted.
Once the used amount >= the alotted amount, we stop awarding prizes.
What is happening is a number of requests to the script are READING the row at the same time before other instances of the script can UPDATE the row, thus showing them each that there is still a # of prizes left to be claimed. This causes us to award more than the alotted amount.
Any ideas on how to circumvent this?