Using the TLS protocol to connect to PostgreSQL
The TLS (Transport Layer Security) protocol is used to protect connections between the client and the PostgreSQL server. It encrypts the transmitted data, preventing interception and unauthorized access.
PgBouncer is used to optimize connections. It manages a connection pool, reusing connections and reducing the number of active connections to PostgreSQL. This reduces the load on the server, speeds up query execution, and prevents resource overload with a large number of clients.
This instruction will help you:
- configure a secure connection to connect to the PostgreSQL server;
- run the PgBouncer extension on the PostgreSQL server to optimize connections;
- adjust the query to the PostgreSQL DB on the client;
- connect the PgBouncer load balancer extension.
- Create a Postgresql DB instance, if this has not been done earlier.
- Make sure the database instance is running.
-
In the VK Cloud management console, go to the Databases → Database instances section.
-
Click the instance name.
-
Go to the Database parameters → Add parameter tab
-
Select the
sslparameter from the list and set the parameter value toon. -
Click Save and confirm the action.
After that, the database instance will restart.
-
Go to the Extensions → Add tab.
-
Select pooler from the drop-down list of extensions.
-
Set the main parameters of the extension.
- pool_mode: select a connection management mode or keep the default value.
- max_client_conn: set a limit on the number of client connections to prevent the load balancer from being overloaded, or keep the default value.
- listen_port: specify the port for incoming connections or keep the default value.
-
Click Save.
Wait for the extension parameter update process to complete.
Connect to the Postgresql DB, specifying the value require for the sslmode parameter in the query.
If you no longer need the database instance, delete it.