Azure multiple webrole write to database at the same time, causing problems
I have an ASP.NET MVC application, that suffers a horrible afflictio开发者_如何学运维n. In one of the post methods the user is able to submit an update. This update takes maybe 10 seconds to compute, and impatitient users sometimes click more than once. I belive this is causing a database update race condition, and I don't know what to do. Where should I save the "isUpdating"-variable in order to block such repeat requests? It can't be a webrole instance, since those are independent, and my user may end up on one or the other. Nor can it be the database, because of the race condition. I'm sure there must be a stanard way. I could for example see a scenario where I restrict users to specific webroles. Is that possible, or is there a better way?
In this case it would probably be better to write the information from the user to a queue, then return the page to the user straight away.
Then have a worker role that picks the information out of the queue and updates the database.
精彩评论