I have 4 web applications, that have a common reference to an Hibernate implementation but that run on different Tomcat instances. And so, for example, a connection pool configured in Hibernate with a min size of 3 (with c3p0
), will result in 12 connection open (3 for each instance) when all the projects are running .
I'd like to "share" the Hibernate implementation with the instances (and so to have always 3 connections open instead of 12), and I was wondering about the best solution to achieve it.
Any tips?
Thanks
I'd like to "share" the Hibernate implementation with the instances (and so to have always 3 connections open instead of 12), and I was wondering about the best solution to achieve it. Any tips?
This is not a good idea. In short, a connection pool should be sized to contain enough connections to serve incoming concurrent requests without having them to wait for a connection to become available. With 4 applications, you'll very likely need more than 3 connections. There is something wrong (or not clear) with your logic.
My tip would thus be to allocate enough resources and to size your thread pools and connection pools appropriately to serve the concurrent requests each application is supposed to handle, and this without exhausting the pool.
One approach could be to create an additional backend service which runs Hibernate and which is connected to the frontend services via a Web Service. This way there would be one Hibernate instance.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With