Multiple sessions writing to one DB table as a possible source for dead requests and work queue as a solution
===

Consider web application (Grails, Oracle) with lots of active users at specific time and high DB load during usage. JavaMelody monitoring data shows a spike of threads at a certain point that rendered application unresponsive though Tomcat web server was running fine. Later after restarting server it is noticed that application under heavier load gets some dead requests (running for more than 7 hours and not ending). All requests seemed to be stuck on application's audit writing. Audit writing is a basic insert into AUDIT table and is done at the end of almost every request.

Correct me if I am wrong, but I suspected that several requests trying to insert data to the same table at relatively the same time might be the problem here. If the first part is at least partially correct, I think I need to change implementation of auditing to use some kind of work queue. And the question here is what is the correct way to do it (passing the information from request to some queue and not waiting for audit to be written and implementation of the queue itself).