0

Without diving so much into web applications or database performance tuning etc, I wish to consult on one thing. pgBouncer has the following settings:

;; Total number of clients that can connect
max_client_conn = 5000

;; Default pool size.  20 is good number when transaction pooling
;; is in use, in session pooling it needs to be the number of
;; max clients you want to handle at any moment
default_pool_size = 500

Given that the web application I am running can only operate in session mode, is the configuration above correct assuming:

  1. My web application does not go above the 5000 client connection mark
  2. My PostgreSQL Database has a max_connection setting of 500

Or am I missing something here. Thanks!!

1 Answer 1

1

You will probably get errors about too many open files long before you reach 5000 queued connections, and so need to change the limit using ulimit -n or by otherwise altering the kernel settings. (Note that if your application needs max_client_conn to be that high, your application is almost certainly profoundly broken. But that wasn't your question)

You don't want default_pool_size to be equal to max_connections. That would leave no connections left over for things like monitoring, reporting, or debugging, or anything else. So back off a few. If 495 isn't enough, 500 probably wouldn't be enough either.

Note that 500 is unlikely to be a good setting of max_connections in the first place. Do you have 500 CPUs, or a RAID with 500 spindles? But again, that wasn't your question.

1
  • thank you again. It makes sense to set the default_pool_size to something lower than max_connections to leave room for other "clients". These past 2 days have been a roller coaster and I've got to say, I don't envy database administrators. Thanks again. After more research, I found my application needs just 1000 max_client_conn and a default_pool_size of 50. Things seem to be running well and we just did a mock quiz with 250 students. Seems i'm doing something right. Thanks again.
    – realnsleo
    Oct 1, 2021 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.