Connection Pooling
Sombra uses connection pooling to efficiently manage database connections and prevent unbounded connections to upstream databases. This approach maintains a pool of connections for each database endpoint and stores these pools in an LRU (Least Recently Used) cache.
To enable connection pooling, you must set the environment variable ODBC_POOL_CACHE_SIZE
based on the number of upstream database servers being scanned, plus some buffer to prevent cache misses.
The following environment variables allow you to configure the connection pooling behavior:
Environment Variable | Description | Default | Required |
---|---|---|---|
ODBC_POOL_CACHE_SIZE | Maximum size of LRU cache to store the connection pool per database | None | Yes |
ODBC_QUERY_TIMEOUT_IN_SECONDS | Maximum time to wait for each ODBC query to execute before returning to the application | 60 seconds | No |
ODBC_CONNECTION_TIMEOUT_IN_SECONDS | Number of seconds to wait for a request on the connection to complete before returning to the application | 0 | No |
ODBC_LOGIN_TIMEOUT_IN_SECONDS | Number of seconds to wait for a login request to complete before returning to the application | 10 | No |
ODBC_CONNECTION_MAX_POOL_SIZE | Maximum number of open connections the pool will create | 100 | No |
ODBC_CONNECTION_INITIAL_POOL_SIZE | Initial number of connections created in the pool | 10 | No |
ODBC_CONNECTION_POOL_SIZE_INCREMENT | Number of additional connections to create when all of the pool's connections are in use | 10 | No |
REUSE_ODBC_CONNECTIONS | Whether or not to reuse an existing connection instead of creating a new one | true | No |
ODBC_CONNECTION_POOL_SIZE_SHRINK | Whether or not the number of connections should shrink to initialSize as they free up | true | No |