Custom pgbouncer connection limit for Sidekiq
Sidekiq sometimes goes a bit too crazy and can consume all available connections, blocking Unicorns from doing anything. To remedy this we should configure pgbouncer to use a custom limit of connections for both Unicorn and Sidekiq.
From what I can tell we can do this as following:
- We lower the default pool size to 100
- We configure Sidekiq to use database
gitlabhq_production_sidekiq
- In Pgbouncer we map this database to
gitlabhq_production
Because the pool size is per user + database this should lead to both Unicorn and Sidekiq being able to use up to 100 connections. If we want to give Sidekiq more connections we can configure this in the database mapping entry.
This however depends on Sidekiq applying the limits to the "source" database, and not the target database.