简体   繁体   中英

High Hibernate Connection Pool Size

I currently run a game in which I use Hibernate as my ORM. Recently, we had many players log into the game all at the same time. This threw a Hibernate

Exception in thread "main" org.hibernate.HibernateException: The internal connection pool has reached its maximum size and no connection is currently available!

I have my pool properties set to 10. My immediate thought is to simply increase the pool size to 100, or even 1000, but I'm not sure what the impacts of this are. My guess is a high pool size could bog down a system when there are 100+ threads running concurrently to the database.

Would performance be the primary aspect impacted by high pool sizes? Is there anything else I should consider when setting a pool size?

The maximum number of connections you could use is equal to the maximum number of threads your app has for handling requests. The real number would be less based on the kind of work that your thread does besides connecting to the database.

You should test that your database can deal with that number of connections.

Connections take a fair amount of memory, so you should look that your Java server has enough memory to handle them too.

Also your connection pool should have some kind of "wait timeout" you can set, before launching that exception. So a thread can wait for a connection to be released.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM