[RFE] Add support to multithread

Bug #1944066 reported by Pedro Guimarães
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
pgbouncer charm
New
Undecided
Unassigned

Bug Description

As per pgbouncer documentation: "PgBouncer is single-threaded and uses one CPU core per instance." [0]

This feature has been added to pgbouncer 1.12, so we should limit it to Focal+.

The solution to set multithreaded pgbouncer is to deploy several processes of it, with slightly different configuration files.

In this, case, set them all with:

so_reuseport = 1 [0]

So these processes will share the same listener port and watch for requests there.

Each pgbouncer should get its own service file (in this case, pgbouncer@<NUM>.service) with a configuration file (/etc/pgbouncer/pgbouncer<NUM>.ini) pointing to a different [0]:

1) PID file: pidfile = /var/run/pgbouncer<NUM>.pid
2) log file: logfile = /var/log/postgresql/bouncer<NUM>.log
3) socket: unix_socket_dir = /var/run/postgresql/bouncer<NUM>_sock

We should also add a config option to define the number of worker processes:

config:
  worker_processes:
    type: int
    default: 0
    description: |
      Set the number of concurrent pgbouncer processes running in the host.
      If set to 0, pgbouncer count == # of cores.
      If set to 1, one single pgbouncer will be set with "so_reuseport=0" option
      If set to N>1, then N pgbouncers will be deployed

[0] https://www.pgbouncer.org/config.html

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.