Enable PgBouncer

Enable PgBouncer Connection Pooling

In this guide, you will:

PgBouncer is a lightweight connection-pooler that sits between Turbot Guardrails services and the Hive PostgreSQL database. By multiplexing thousands of client connections into a much smaller pool of backend connections, PgBouncer dramatically reduces the number of active sessions on Hive, lowering memory consumption and protecting the database from connection storms.

Prerequisites

Step 1: Update TEF

To begin the upgrade process, you will first need to locate and access the TEF provisioned product in AWS Service Catalog and initiate an update.

Follow the same initial steps outlined in the Updating TEF guide to:

Once you've reached the version selection step in Service Catalog, return here to continue with the pgbouncer update process.

Select Version

Select the desired TEF version under Product Versions.

Select TEF Version

Update PgBouncer Parameter

Set Enable PgBouncer to true in the Advanced – PgBouncer section to turn on connection pooling for your Collective.

Enable PG Bouncer

After verifying any changes to existing parameters, select Update at the bottom of the screen.

Update TEF

Step 2: Update TED

Similar to TEF, locate and access the TED provisioned product in AWS Service Catalog and initiate an update.

Follow the same initial steps outlined in the Updating TED guide to:

Once you've reached the version selection step in Service Catalog, continue with the pgbouncer update steps:

Select Version

Select the desired TED version under Product Versions.

Select TED Version

Update Parameters

TED provides a comprehensive set of settings, but when first enabling PgBouncer, you can safely leave all values at their defaults.

[!NOTE]

PgBouncer Parameters Update

[!NOTE] It is recommended to set the PgBouncer Log Statistics parameter to enabled in TED to verify and view PgBouncer activation logs.

PgBouncer Parameters Update

You may continue to have the rest of the parameters as default settings.

After verifying any changes to existing parameters, select Update at the bottom of the screen.

Update TED

Step 3: Install TE

PgBouncer support requires Turbot Guardrails Enterprise (TE) 5.52.0 or later. Use the existing Install TE guide to install a new TE product and upgrade the workspaces. PgBouncer will activate automatically if Enable PgBouncer was set to true during the TEF update in the above steps. No additional parameters need changing at the workspace level.

Step 4: Verify PgBouncer Activation

The most reliable way to verify that PgBouncer is active is by checking its statistics output from the ECS logs.

[!NOTE] To view PgBouncer logs, ensure the TED parameter PgBouncer Log Statistics is set to enabled.

Check ECS Service Task

Navigate to your ECS service <prefix>_<hive>_pgbouncer (for example: turbot_newton_pgbouncer if using default names) and Select the running task.

ECS Service Task

View ECS Logs

Select the Logs tab to view the stats displayed under Message. PgBouncer is confirmed to be running and actively processing database traffic based on the presence of these stats.

The STATS lines appear every 5 minutes with metrics like:

   stats: 9 xacts/s, 8 queries/s, 8 client parts/s, 8 server parts/s, 8 kB/s/s, in 277 B/s, out 1000 B/s, xact 54224 us, query 47520 us, wait 126 us

These stats show:

ECS Task Logs

Step 5: Configuration & Tuning (Optional)

Sizing Guidelines

  1. Database Connections – a good starting point is 2–3 connections per vCPU on the Hive instance.
  1. Client Connections – the default 2000 is sufficient for most Collectives. If you need more:
  1. High Availability – enable zone spreading and set at least 2 desired tasks so a single AZ outage doesn't break connectivity.

Connection Settings

Resource Settings

Monitoring Settings

Next Steps

Please see the following resources to learn more about Turbot Guardrails Enterprise:

Troubleshooting

Issue Description Guide
Permission Issues If the current logged-in user lacks permission to modify, update, or create resources in the stack, or if IAM roles or SCPs have changed, preventing built-in roles from accessing needed configuration settings. Troubleshoot Permission Issues
Stack Rollback Failure Due to Database State If the CloudFormation stack attempts to roll back but fails because the database is in a state (e.g., Upgrading, Backing Up) that prevents a successful rollback. Troubleshoot Rollback Failures
Service Catalog Sync Issue If the Service Catalog Provisioned product, CloudFormation Stack, or the physical RDS instance becomes out of sync, causing issues with updates or resource management. Troubleshoot Sync Issues
Further Assistance If you continue to encounter issues, please open a ticket with us and attach the relevant information to assist you more efficiently. Open Support Ticket