Scenario is straightforward to explain, but may have an intricate answer:
Make a situation in which you have one write only mysql database. Then you've about five to six read only databases. The write database includes a count for the inventory. You've 100s of 1000's of customers banging away only at that particular inventory item, only limited quantity. For argument's sake, say 10 products.
What's the easiest method to make sure that only 10 products get offered? If there's a 200ms delta between your time the read-only slaves get up-to-date, can't the integrity from the count get old, thus selling inventory you don't have?
How does one solve/scale this issue?
The fundamental means to fix concurrent customers will most likely cover that as well. At some stage in the "buy" transaction, you have to decrement the inventory (around the write-server). Through whatever method, enforce that inventory can't go below zero.
If there's one item left, and 2 people trying to purchase it, you will be at a complete loss.
The replication latency is the same factor. Two customers visit a product available, but when they struggle to purchase it, it's gone. A great choice for your scenario covers both replication latency along with a user simply snatching the final item from under another user.
Everything is dependent on when and what window you choose to lock the actual table for that update.
A. If you need to be 100% sure a product is going to be tried to be purchased only if its surely available. You'll have to lock the product for that particular user the moment you list it to him (and that means you will temporarily decrement the inventory stock)
B. If you're okay with showing the main one off "sorry, we simply went sold-out" message. you need to lock the product right before you bill (well, you could do this that whenever transaction is done. but at the expense of the very furious customer)
I'd chose approach A for securing, and might be flag a "selling out soon" warning for products with really low stock left. (if it is a really frequent situation, you can proly also count the amount of concurrent customers striking around the item and provide a far more accurate warning)
In the business perspective, you wouldn't like to become so have less stock (less than the amount of concurrent purchasers) This really is inevitable obviously at "christmas" occasions when its okay to become sold-out :)