|
| 1 | +--- |
| 2 | +id: high-performance-pooling |
| 3 | +title: High-performance database connection pooling |
| 4 | +sidebar_label: High-performance pooling |
| 5 | +--- |
| 6 | + |
| 7 | +High-performance pooling is available only in the Ory Enterprise License (OEL). It uses |
| 8 | +[pgxpool](https://pkg.go.dev/github.com/jackc/pgx/v5/pgxpool) and provides additional configuration options for managing database |
| 9 | +connections under variable load. |
| 10 | + |
| 11 | +To activate high-performance pooling, you must set the `pool_min_conns` parameter, otherwise high-performance pooling will not be |
| 12 | +enabled. |
| 13 | + |
| 14 | +- `pool_min_conns` (number): The minimum number of total (in-use and idle) database connections to keep open at all times. After a |
| 15 | + connection closes, the pool may dip below `pool_min_conns` momentarily. Defaults to 0. |
| 16 | +- `pool_max_conns` (number): Sets the maximum number of open connections to the database. Overrides `max_conns`. |
| 17 | +- `pool_max_conn_idle_time` (duration: for example "500ms", "5s", "30m", "1h"): Database connections will be closed after idling |
| 18 | + for this duration. Overrides `max_conn_idle_time`. |
| 19 | +- `pool_max_conn_lifetime` (duration: for example "500ms", "5s", "30m", "1h"): Sets the time after which a connection will be |
| 20 | + closed, irrespective of how long it has been idle. Overrides `max_conn_lifetime`. |
| 21 | +- `pool_max_conn_lifetime_jitter` (duration: for example "500ms", "5s", "30m", "1h"): Jitter to add to the |
| 22 | + `pool_max_conn_lifetime` value. This is useful to avoid thundering herd problems when many connections are closed and re-opened |
| 23 | + at the same time. |
| 24 | +- `pool_health_check_period` (duration: for example "500ms", "5s", "30m", "1h"): Sets the period for health checks to potentially |
| 25 | + kill stale connections. Defaults to "1m". |
| 26 | + |
| 27 | +## Key differences from standard pooling |
| 28 | + |
| 29 | +### Standard pooling behavior |
| 30 | + |
| 31 | +- Opens connections on demand |
| 32 | +- Closes idle connections after timeout |
| 33 | +- During traffic spikes, must initialize many new connections simultaneously |
| 34 | +- Can cause database overload, timeouts, or connection storms when traffic surges suddenly |
| 35 | + |
| 36 | +### High-performance pooling behavior |
| 37 | + |
| 38 | +- Maintains min_pool connections open at all times |
| 39 | +- Traffic spikes use pre-established connections |
| 40 | +- Avoids connection initialization overhead during demand peaks |
| 41 | +- Reduces risk of overwhelming the database during sudden load increases |
| 42 | + |
| 43 | +### Connection refresh jitter |
| 44 | + |
| 45 | +High-performance pooling includes randomized jitter when refreshing connections. This prevents synchronized connection resets that |
| 46 | +could cause momentary overload when all connections attempt to restart simultaneously. |
| 47 | + |
| 48 | +## When to use high-performance pooling |
| 49 | + |
| 50 | +Consider high-performance pooling when your workload exhibits: |
| 51 | + |
| 52 | +- Large, unpredictable traffic spikes |
| 53 | +- Sudden transitions from low to high request volume |
| 54 | +- Time-sensitive operations where connection initialization latency is problematic |
| 55 | + |
| 56 | +For steady-state traffic or gradual load changes, standard pooling may be enough. |
| 57 | + |
| 58 | +High-performance pooling does not reload TLS certificates while the process is running. If database TLS certificates change, you |
| 59 | +must restart the Ory service to establish connections using the new certificates. Standard pooling supports hot reloading of TLS |
| 60 | +certificates because connections close after idle timeout and reconnect with refreshed credentials. |
0 commit comments