Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rule of thumb for Max Postgres connections to set?

Tags:

postgresql

As a rule of thumb, how many max connections should I set my Postgres server to have? For instance, if I have 8 GB of memory, and quad core 3.2 GHZ machine, and the server is dedicated to only Postgres, how many max connections would be safe?

like image 753
Henley Avatar asked Apr 15 '13 18:04

Henley


1 Answers

There is no real rule of thumb since it really depends on your load.

  • If you do lots of tiny queries than you can easily increase the amount of connections.
  • If you have a few heavy queries, than you will probably increase the work_mem so you'll run out of memory with a lot of connections.

The basic thing is:

  • don't have more connections than your memory allows.
  • don't kill and recreate connections if possible (pgbouncer springs to mind)
like image 115
Wolph Avatar answered Nov 06 '22 18:11

Wolph