Provided by: pgbouncer_1.3-1_i386
pgbouncer - Lightweight connection pooler for PostgreSQL.
pgbouncer [-d][-R][-v][-u user] <pgbouncer.ini>
The windows environment serves as the following options.
pgbouncer.exe [-v][-u user] <pgbouncer.ini>
Furthermore, this option is specially offered for windows-service.
<windows service registration>
-addengine [servicename] config.ini
-delengine [servicename] config.ini
pgbouncer is a PostgreSQL connection pooler. Any target application can
be connected to pgbouncer as if it were a PostgreSQL server, and
pgbouncer will manage to connect to the server, or to reuse one of its
The aim of pgbouncer is to lower the performance impact of opening new
connections to PostgreSQL.
In order not to compromise transaction semantics for connection
pooling, pgbouncer supports several levels of brutality when rotating
Most polite method. When client connects, a server connection will
be assigned to it for the whole duration it stays connected. When
client disconnects, the server connection will be put back into
Server connection is assigned to client only during a transaction.
When PgBouncer notices that transaction is over, the server will be
put back into pool.
Most aggressive method. The server connection will be put back into
pool immidiately after a query completes. Multi-statement
transactions are disallowed in this mode as they would break.
The administration interface of pgbouncer consists of some new SHOW
commands available when connected to a special virtual database
Basic setup and usage as following.
1. Create config file. Details in pgbouncer(5). Simplest:
template1 = host=127.0.0.1 port=5432 dbname=template1
listen_port = 6543
listen_addr = 127.0.0.1
auth_type = md5
auth_file = users.txt
logfile = pgbouncer.log
pidfile = pgbouncer.pid
admin_users = someuser
2. Create users.txt file:
3. Launch pgbouncer:
$ pgbouncer -d pgbouncer.ini
4. have your application (or the psql client) connect to pgbouncer
instead of directly to PostgreSQL server.
$ psql -h 127.0.0.1 -p 6543 -U someuser template1
5. manage pgbouncer by connecting to special administration database
pgbouncer and issue show help; to begin:
$ psql -h 127.0.0.1 -p 6543 -U someuser pgbouncer
pgbouncer=# show help;
NOTICE: Console usage
SET key = arg
6. If you change some changeable configuration settings in the
configuration file, you can reload the file with:
COMMAND LINE SWITCHES
Run in background. Without it the process will run in foreground.
Note: The windows environment should use the special option for
Do a online restart. That means connecting to running process,
loading open sockets from it and using them. If there is no active
process, boot normally. Note: The windows environment is not
Switch to user on startup.
Increase verbosity. Can be used multiple times.
Be quiet - don’t log to stdout. Note this does not affect logging
verbosity, only that stdout is not to be used. For use in init.d
Show short help.
Console is available by connecting into standard
listen_addr/listen_port and specifying string pgbouncer as database.
$ psql -h 127.0.0.1 -p 6543 pgbouncer
Only users listed in configuration parameters admin_users or
stats_users are allowed to login to the console.
Additionally, username pgbouncer is allowed to log in without password,
if the login comes via UNIX socket and the client has same UNIX user
uid as the running process.
The SHOW commands output some rows, the columns contained are described
Statistics are presented per database.
Total number of SQL requests pooled by pgbouncer.
Total volume in bytes of network traffic received by pgbouncer.
Total volume in bytes of network traffic sent by pgbouncer.
Total number of milliseconds spent by pgbouncer when actively
connected to PostgreSQL.
Average requests per second in last stat period.
Average received (from clients) bytes per second.
Average sent (to clients) bytes per second.
Average query duration in milliseconds.
S, for server.
Username pgbouncer uses to connect to server.
database name on server.
State of the pgbouncer server connection, one of active, used
IP address of PostgreSQL server.
Port of PostgreSQL server.
Connection start address on local machine.
Connection start port on local machine.
When the connection was made.
When last request was issued.
Address of internal object for this connection. Used as unique
Address of client connection the server is paired with.
C, for client.
Client connected user.
State of the client connection, one of active, used, waiting or
IP address of client.
port client is connected to.
Connection end address on local machine.
Connection end port on local machine.
Timestamp of later client connection.
Timestamp of later client request.
Address of internal object for this connection. Used as unique
Address of server connection the client is paired with.
A new pool entry is made for each couple of (database, user).
Count of currently active client connections.
Count of currently waiting client connections.
Count of currently active server connections.
Count of currently idle server connections.
Count of currently used server connections.
Count of currently tested server connections.
Count of server connections currently login to PostgreSQL.
How long has first (oldest) client in queue waited, in second.
If this start increasing, then current pool of servers does not
handle requests quick enough. Reason may be either overloaded
server or just too small pool_size.
Show following internal information, in columns (not rows):
Count of databases.
Count of users.
Count of pools.
Count of free clients.
Count of used clients.
Count of clients in login state.
Count of free servers.
Count of used servers.
Show one line per user, under the name column name.
name of configured database entry.
Host pgbouncer connects to.
Port pgbouncer connects to.
Actual database name pgbouncer connects to.
When user is part of the connection string, the connection
between pgbouncer and PostgreSQL is forced to the given user,
whatever the client user.
Maximum number of server connections.
Shows list of fds in use. When the connected user has username
"pgbouncer", connects thru unix socket and has same UID as running
process, the actual fds are passed over connection. This mechanism
is used to do online restart. Note: The windows environment is not
File descriptor numeric value.
One of pooler, client or server.
User of the connection using the FD.
database of the connection using the FD.
IP address of the connection using the FD, unix if a unix
socket is used.
port used by the connection using the FD.
cancel key for this connection.
fd for corresponding server/client. NULL if idle.
Show the current configuration settings, one per row, with
configuration variable name
Either yes or no, shows if the variable is changeable when
running. If no, the variable can be changed only boot-time.
PROCESS CONTROLLING COMMANDS
PgBouncer tries to disconnect from all servers, first waiting for
all queries to complete. The command will not return before all is
done. To be used at the time of database restart.
All socket buffers are flushed and PgBouncer stops listening data
on them. The command will not return before all is done. To be used
at the time of PgBouncer restart.
Resume work from previous PAUSE or SUSPEND command.
The PgBouncer process will exit.
The PgBouncer process will reload its configuration file and update
Reload config. Same as issuing command RELOAD; on console.
Safe shutdown. Same as issuing PAUSE; and SHUTDOWN; on console.
Immediate shutdown. Same as issuing SHUTDOWN; on console.
From libevent docs:
It is possible to disable support for epoll, kqueue, devpoll, poll
or select by setting the environment variable EVENT_NOEPOLL,
EVENT_NOKQUEUE, EVENT_NODEVPOLL, EVENT_NOPOLL or EVENT_NOSELECT,
By setting the environment variable EVENT_SHOW_METHOD, libevent
displays the kernel notification method that it uses.
pgbouncer(5) - manpage of configuration settings descriptions.
[FIXME: source] 05/05/2009 PGBOUNCER(1)