Skip to content

Set up pgbouncer

Prior testing done here: https://gitlab.com/gitlab-com/infrastructure/issues/259#note_25131536

The plan for moving to pgbouncer is as follows:

  1. Install via apt-get on db3
  2. Configure 1000 frontend connections, 200 max_connections for PostgreSQL
  3. Set up authentication so it uses PostgreSQL's own credentials
  4. Swap the ports of PostgreSQL and pgbouncer
  5. Monitor

Once this works we can apply it to db4 as well. We will then monitor/use this for a day or so to see how it behaves when both secondaries use pgbouncer. Once this works we need to take the following steps:

  1. Move pgbouncer back to a separate port instead of using PostgreSQL's port
  2. Move the secondary ports back to the default
  3. Set up pgbouncer on the primary
  4. Configure GitLab to use the pgbouncer port instead of the PostgreSQL port
  5. Drop max_connections on the primary to 200 (to match the secondaries)
  6. Restart PostgreSQL

In theory the last step does not require downtime as IIRC pgbouncer can handle restarts, but since this is the first time we'll be doing this I suggest enabling the deploy page to be certain.

Once this is working we can move towards using pgbouncer as shipped with omnibus (gitlab-org/omnibus-gitlab!1345 (merged) still a WIP).