   [web] JSP Servlets and eventqueue
  Hello,I need some advice from experienced web developers.Currently I am working on a browser game using hybrid technology.This is I got a MySQL server, a C++ application and tomcat+jspIt the whole system as follows.client ->JSP -> encode commands as strings -> MySQL command queue(just a innodb table)MySQL command queue -> decode commands -> C++ App -> update MySQL databaseMySQL database -> JSP -> client(some browser)The problem is the last step, I need to guarantee it is executed after the C++ has updated the MySQL database, otherwise the refreshed page would contain old information and I had to refresh once again. I see only two optionsa) using AJAX  set some timer and then load the actual page contentb) since each servlets a threaded, I had to sleep/schedule the servlet thread some time maybe 500 msa) is an elegant solution but involved a lot of more work and you need &#106avascript on the client sideb) on the other hand delaying the servlet is a simple and effective solutionWhat do you think which way should I go?   
  hi,just one question..why use C++ and not Java?and again, why C++ for something on browser?   ;  Why not?I am not using C++ to generate the webpages, thats done with java servlets JSP JSTL ...The C++ backend just reads in the command queues and handles all the game logic.I see no reason not to use C++ there.C++ is my prefered language anyways.Anyways I decided to use Ajax to load the page content with a tiny delay of 50-100 ms.   ;  well.. exactly because of the delay between Client->Server->Client..using Java..  you would have a JSP->Java->MySQL->Java->JSPyou dont need to pass by MySQL twice, and also encode strings..not sure what kind of game you want to do..  but something big with lot of requests per sec would raise the delay a lot..i am working on a strategy browser-game just like Tribal Wars/ Travian right now.. something like this would destroy my project..   ;  The world isn t always as easy as it seams.The reason I use the approach with an event queue is that I need to guarantee the in order execution.How would you handle all these events otherwise? when the user refreshes his page?Thats even worse because you unevenly distribute the work over time leading to spikes with lot of work to do.Imagine a user has 1000 events since his last refresh, you had to handle all these events before you return the latest state .At peak times this will make your game unplayable.My archtecture will run pretty smoothly even at peak times since it distributes work over time. And parsing a few hundred strings costs you nothing.The other advantage of event queues is, you can split them depending on their locality.Fights taking place in the other half of your game world could be placed in a second event queue effectively halving the work one update process has to perform.With your setup you have to trigger state updates by user actions which is no option.All browsergames I know of (space battle games...) use some sort of externally triggered update mechanism.   