Re: Per thread Connection memory

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Per thread Connection memory
Дата
Msg-id n8nh7k$hr9$1@ger.gmane.org
обсуждение исходный текст
Ответ на Re: Per thread Connection memory  (Ankur Kaushik <ankurkaushik@gmail.com>)
Список pgsql-admin
> Application Using Java Program , They have there java Pool system,
> when this Java pool memory full , tomcat need to restart in every 30- 60 min

You should configure your connection pool in the Java application to _release_ those connections

e.g. if you are using the Tomcat 7 pool, I would configure something like maxIdle="10", minIdle="5" and maxActive="150"
andthen you need to define a timeout when an idle connection is closed by the pool, e.g.
minEvictableIdleTimeMillis="300000"to close an idle connection after 5 minutes.  

Depending on your workload you might want to close that faster (e.g. after 1 minute).

> Most queries found in processlist is which full the Java memory pool , Hibernate is used in Application

Those queries look suspiciously like the query that is used by DatabaseMetaData.getTables().

I think the c3p0 connection pool has a pretty stupid default configuration where the validation query (that is used to
checkif a connection is still "alive") uses exactly that call. And I also think this is configured to be called each
timea connection is returned to the pool - which imposes a huge (and unnecessary load) on the database server.   

If that is the case you should configure a different validation query that is less invasive. Something like:
preferredTestQuery="select42", once that is configure c3p0 will no longer call the (expensive)
DatabaseMetaData.getTables()method. It's one of the many reasons I don't like the c3p0 pool. I think Tomcat7's pool is
amuch better choice (I'm _not_ talking about DBCP, but about the new "native" pool introduced with Tomcat7) 

I also recommend to _not_ test the connections when the pools hands them out or if they are returned, because those
validationquery will then put too much load on the database server.  

It's better to configure the pool to validate the connections when they are idle. Again, how you configure this,
dependson the pool you are using.  


> Please Let me know in Postgresql  pgbouncer  is essential use for handling multithread applications?

No, if you already have a connection pool in your application, then you don't need another one.

pgBouncer (or pgPool) are usually used for either load balancing or if the applications themselves don't do pooling.

Thomas

В списке pgsql-admin по дате отправления:

Предыдущее
От: jaime soler
Дата:
Сообщение: Re: Per thread Connection memory
Следующее
От: jaime soler
Дата:
Сообщение: Re: 9.5 repo question