tags:

views:

99

answers:

2

Hello,

i have a grails application with a webflow. I store my inner flow objects of interest in the converstaion scope. After entering and leaving the flow a few times, i see that the single user connected to the DB (MySql) generates a lot of threads on the MySql Server which are not released. The processlist in mysql show me the threads in sleeping mode and a netstat on the client shows me established connections to the mysql server. I assume the connections are held active and not released. But why is that? What do grails exactly do when entering and leaving a flow? Why are so many connections opened and not closed?

Any help would be appreciated.

regards, masiar

A: 

Grails uses hibernate, which in turn uses connection pooling; these are idle connections, waiting for traffic.

You can learn more about Hibernate's connection pooling at: https://www.hibernate.org/214.html

This is actually desirable behavior; it can take a non-negligible amount of time to open a new connection, much more time than it takes to send a query down an open one.

"Premature optimization is the root of all evil" - unless you are seeing a performance problem related to the database, I'd leave this alone.

Tim Howland
A: 

Think of the hibernate pooling like a steady and ready pool of cars having their engines turned on at all time for you or your buddies to jump in and go to anywhere you want..., well no, to the database. No need to wait for a taxi or to jump start your own car before you are up and running... all good here

Conversations are meant to stick around as long as they are needed. Often you dive down into workflows and upon finishing them, you return to your old, and thus still alive conversation. It is meant like that... all good here too

raoulsson