[pgpool-general: 77] Re: num_int_children and max_pool

Tatsuo Ishii ishii at postgresql.org
Fri Dec 9 14:55:18 JST 2011


> I'm using pgpoolII-3.1.1. The documentation states that
> num_init_children is the maximum number of 'active' connections from
> clients to the pgpool instance. It also states that 2*num_init_children
> can be queued.
> 
> So, I set up num_init_children to 2, and had two psql shells connected
> to postgres. Then I started another 4 psql shells, and those were
> waiting for connection (I don't even get a password prompt), as
> excpected. But I also expected that any subsequent connections attempts
> would result in 'connection refused'. I was able to 'queue' over 50
> connectins, way over 'num_init_children*2'.
>
> Now, is there a way to tell pgpool to stop accepting connections after
> certain limit? I need pgpool to reject connections.

Pgpool does something like this when setting up socket to accept
connections from pgpool clients.

	backlog = pool_config->num_init_children * 2;
	status = listen(fd, backlog);

So I guess it is up to OSs behavior when pgpool set backlog parameter
of listen(2). I would like to know if there is any better way to
control listen queue.

> Also, I'm not sure what should I set max_pool to. If I allow 1000
> connections to pgpool, and set max_pool to 5, I actually need to allow
> postgres to accept 5000 connections to be sure that everything will be
> working ok. And then when that 1000 connections disconnect from pgpool,
> pgpool will still maintain 5000 connections to the postgres backend, no
> matter that the most I'll be able to utilize is 1/5 of those.
> 
> Am I missing something here?

First of all, you can set max_pool lower than 5 (say 2) even if you
have 5 different users. In this case if 3rd user is comming, the
oldest connection to backend is disconnected and new connection is
establised for the user. So functionaly you will have no problem, the
pernalty is establishing connection overhead.

Also pgpool has following directives to control idle connections to
backend.

connection_life_time = 0
                                   # Connection to backend closes after being idle for this many seconds
                                   # 0 means no close
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp


More information about the pgpool-general mailing list