Increase number of files open for Pgbouncer

Pgbouncer is a lightweight connection pooler for Postgresql. It reduces the overhead of creating a new connection every time, instead it keeps a pool of connections open at all times which greatly reduces overhead. If you are doing a lot of connections per second, then Pgbouncer may complain that the open file limit has reached. You can increase this limit by editing the init.d startup script for Pgbouncer.

we need to add the following line to our init.d pgbouncer

ulimit -n 32768

our start up script will look something like this

case "$1" in
    # Check if we are still disabled in /etc/default/pgbouncer
    [ "${START:-}" = "0" ] && exit 0
    log_daemon_msg "Starting PgBouncer" $NAME
    test -d $PIDDIR || install -d -o postgres -g postgres -m 2775 $PIDDIR

    ### set whatever limits you want ###
    ulimit -n 32768

    $SSD --start --chuid $RUNASUSER --oknodo -- $OPTS 2> /dev/null
    log_end_msg $?

Comments 1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.