PgBouncer
In PostgreSQL, a separate process is created to handle each client connection. The larger the number of connections, the more processes that use RAM. The maximum number of connections to a PostgreSQL process is defined by the max_connections
parameter.
To optimize resource consumption, you can use a connection pooler. Clients do not connect directly to PostgreSQL, but to the connection pooler. A small number of connections between the pooler and the PostgreSQL server are supported — the pooler creates a new connection or reuses one of the existing ones. The number of connections between the pooler and the database on each cluster node is determined by the pool size ( pool_size
parameter ).
PostgreSQL cloud database clusters use the PgBouncer connection pooler. Three PgBouncer pooling modes are available. Read more about connection pooler in the PgBouncer documentation.
Maximum number of connections to PostgreSQL process (max_connections)
The PostgreSQL DBMS max_connections
parameter defines the maximum number of simultaneous connections to the PostgreSQL process. The default value is 100 connections.
You can change the value of the parameter in the DBMS settings in the control panel to the value of the maximum number of connections under load. Note that each connection consumes RAM resources.
Changing the max_connections
value causes the PostgreSQL cluster nodes to restart.
Pool size (pool_size)
The pool size ( pool_size
parameter) is the maximum number of connections between the connection pooler and each PostgreSQL database on each node in the cluster.
Pool size can be selected when creating a cluster and can be changed in the created cluster. The available values are from 1 to 500.
Pooling modes
Pooling mode is the client's connection strategy to PostgreSQL. PostgreSQL cloud database clusters use the PgBouncer connection pooler. Read more about the connection pooler in the PgBouncer documentation.
PgBouncer supports three modes:
By default, cloud databases use the transaction mode.
Pooling mode can be selected when creating a cluster and the mode can be changed in the created cluster.