Connection pools provide a cache of reusable database connections to improve database response time. The cache allows your PostgreSQL server to serve many HTTP requests with fewer database connections. Connection pools reduce latency by reducing the number of times the PostgreSQL server creates new connections leading to better end-user experience.
Follow this guide to manage connection pools for Vultr Managed Databases for PostgreSQL using the Vultr Customer Portal, API, and CLI.
Navigate to Products and select Databases.
Click the target managed database instance.
Navigate to Connection Pools and click Add New Connection Pool.
Enter the details and click Create Pool.
Click Edit to change the connection pool details or Delete Pool to remove the pool from the database.
List all the database instances by sending a GET
request to the List Managed Databases endpoint and note the database ID. For example, 43b4c774-5dff-4ac0-a01f-78a23c2205b5
.
$ curl "https://api.vultr.com/v2/databases" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Send a POST
request to the Create Connection Pool endpoint to create a connection pool and specify the database ID.
$ curl "https://api.vultr.com/v2/databases/database-id/connection-pools" \
-X POST \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"name" : "sample-pool",
"database" : "defaultdb",
"username" : "vultradmin",
"mode" : "transaction",
"size" : 10
}'
Send a GET
request to the List Connection Pools endpoint to list all the connection pools.
$ curl "https://api.vultr.com/v2/databases/database_id/connection-pools" \
-X GET \
-H "Authorization: Bearer ${VULTR_API_KEY}"
Send a PUT
request to the Update Connection Pool endpoint and specify the database ID and the pool name
to update.
$ curl "https://api.vultr.com/v2/databases/database-id/connection-pools/pool-name" \
-X PUT \
-H "Authorization: Bearer ${VULTR_API_KEY}" \
-H "Content-Type: application/json" \
--data '{
"mode" : "session"
}'
Send a DELETE
request to the Delete Connection Pool endpoint and specify a database ID and a pool name
to remove the pool from the database.
$ curl "https://api.vultr.com/v2/databases/database_id/connection-pools/pool_name" \
-X DELETE \
-H "Authorization: Bearer ${VULTR_API_KEY}"