How to Manage Connection Pools for Vultr Managed Databases for PostgreSQL

Updated on November 27, 2024

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.

  • Vultr Customer Portal
  • Vultr API
  1. Navigate to Products and select Databases.

  2. Click the target managed database instance.

    Select Managed Database

  3. Navigate to Connection Pools and click Add New Connection Pool.

    Edit Connection Pools

  4. Enter the details and click Create Pool.

    Add Connection Pool

  5. Click Edit to change the connection pool details or Delete Pool to remove the pool from the database.

    New Connection Pools

  1. 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.

    console
    $ curl "https://api.vultr.com/v2/databases" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  2. Send a POST request to the Create Connection Pool endpoint to create a connection pool and specify the database ID.

    console
    $ 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
        }'
    
  3. Send a GET request to the List Connection Pools endpoint to list all the connection pools.

    console
    $ curl "https://api.vultr.com/v2/databases/database_id/connection-pools" \
        -X GET \
        -H "Authorization: Bearer ${VULTR_API_KEY}"
    
  4. Send a PUT request to the Update Connection Pool endpoint and specify the database ID and the pool name to update.

    console
    $ 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"
        }'
    
  5. 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.

    console
    $ curl "https://api.vultr.com/v2/databases/database_id/connection-pools/pool_name" \
        -X DELETE \
        -H "Authorization: Bearer ${VULTR_API_KEY}"