Tune connection pooling
Hyperdrive maintains a pool of connections to your database that are shared across Worker invocations. You can configure the maximum number of these connections based on your database capacity and application requirements.
You can configure the connection pool size using the Cloudflare dashboard, the Wrangler CLI, or the Cloudflare API.
To configure connection pool size via the dashboard:
-
Log in to the Cloudflare dashboard ↗ and select your account.
-
Go to Storage & databases > Hyperdrive.
Go to Hyperdrive -
Select your Hyperdrive configuration.
-
Select Settings.
-
In the Origin connection limit section, adjust the Maximum connections value.
-
Select Save.
Use the wrangler hyperdrive update command with the --origin-connection-limit flag:
npx wrangler hyperdrive update <HYPERDRIVE_ID> --origin-connection-limit=<MAX_CONNECTIONS>Use the Hyperdrive REST API to update your configuration:
curl --request PATCH \ --url https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/hyperdrive/configs/<HYPERDRIVE_ID> \ --header 'Content-Type: application/json' \ --header 'Authorization: Bearer <API_TOKEN>' \ --data '{ "origin_connection_limit": <MAX_CONNECTIONS> }'All Hyperdrive configurations have a minimum of 5 connections. The maximum connection count depends on your Workers plan.
- Start conservatively: Begin with a lower connection count and gradually increase it based on your application's performance.
- Monitor database metrics: Watch your database's connection usage and performance metrics to optimize the connection count.
- Consider database limits: Ensure your configured connection count does not exceed your database's maximum connection limit.
- Account for multiple configurations: If you have multiple Hyperdrive configurations connecting to the same database, consider the total connection count across all configurations.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Directory
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- © 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark