eager-petabyte-5975
04/13/2025, 2:20 PMbrief-egg-61061
04/13/2025, 2:20 PMbrief-egg-61061
04/13/2025, 2:21 PMeager-petabyte-5975
04/13/2025, 2:27 PMbrief-egg-61061
04/13/2025, 2:28 PMbrief-egg-61061
04/13/2025, 2:28 PMmax_conns
(number): Sets the maximum number of open connections to the database. Defaults to the number of CPU cores times 2. > - max_idle_conns
(number): Sets the maximum number of connections in the idle. Defaults to the number of CPU cores. [Database setup and configuration](https://www.ory.sh/docs/self-hosted/deployment) These parameters control how many connections the Ory application will establish to the database. The default values are calculated based on the CPU cores of the machine running the Ory service, as this is a common practice for determining optimal connection pool sizes. The application needs to manage these connections based on its own processing capacity, which is why it uses its own CPU count as a reference point. When you configure these parameters in your DSN string, you're telling the Ory application how to manage its connection pool to the PostgreSQL database.eager-petabyte-5975
04/13/2025, 4:09 PMbrief-egg-61061
04/13/2025, 4:09 PMbrief-egg-61061
04/13/2025, 4:09 PMmax_conns
(number): Sets the maximum number of open connections to the database. Defaults to the number of CPU cores times 2. > - max_idle_conns
(number): Sets the maximum number of connections in the idle. Defaults to the number of CPU cores. [Database setup and configuration](https://www.ory.sh/docs/self-hosted/deployment) For MySQL, similar defaults apply: > - max_conns
(number): Sets the maximum number of open connections to the database. Defaults to the number of CPU cores times 2. > - max_idle_conns
(number): Sets the maximum number of connections in the idle. Defaults to the number of CPU cores. [MySQL](https://www.ory.sh/docs/self-hosted/deployment#mysql) These defaults are based on the CPU cores of the machine running the Ory service, not the database server. The system will automatically calculate these values based on the available CPU cores on your application server if you don't explicitly set them in your DSN string.freezing-mechanic-10866
04/17/2025, 2:41 AMbrief-egg-61061
04/17/2025, 2:41 AMbrief-egg-61061
04/17/2025, 2:42 AMmax_conns
higher than the default (CPU cores × 2) to handle your high load - Adjusting max_idle_conns
to maintain enough warm connections - Setting appropriate max_conn_lifetime
and max_conn_idle_time
values to ensure connection recycling Example DSN with these parameters: <postgres://user:password@host:port/database?max_conns=300&max_idle_conns=100&max_conn_lifetime=5m&max_conn_idle_time=1m>
2. For high-load environments, there are known issues that might affect performance: - The GetOrGenerateKeys
function can cause performance degradation under high load due to its locking mechanism [GetOrGenerateKeys locking issue](https://github.com/ory/hydra/issues/3863) - Competing refresh token requests can cause concurrent update issues on PostgreSQL [Competing refresh token requests issue](https://github.com/ory/hydra/issues/3604) 3. For production deployments, Ory recommends using managed database solutions: > By the way, we do not recommend deploying databases using Docker in production. Use a managed solution like Amazon RDS or Google Cloud SQL. [Run your own OAuth2 Server](https://www.ory.sh/blog/run-oauth2-server-open-source-api-security) 4. For client credentials validation, be aware that Hydra uses BCrypt which is CPU-intensive by design: > Ory Hydra uses BCrypt to obfuscate secrets of OAuth 2.0 Clients. When using flows such as the OAuth 2.0 Client Credentials Grant, Ory Hydra validates the client credentials using BCrypt which causes (by design) CPU load. [Performance and benchmarks](https://www.ory.sh/docs/ecosystem/benchmark) For your specific requirements around LWLock:BufferContent and IO:XactSync, the knowledge sources don't provide specific PostgreSQL tuning parameters. Given the scale you're targeting, you might want to: 1. Consider horizontal scaling of Hydra instances 2. Reach out to Ory directly for enterprise-level support 3. Consult with a PostgreSQL performance expert for database-specific optimizations The knowledge sources don't contain enough specific information to provide a complete PostgreSQL configuration for your high-load use case.freezing-mechanic-10866
04/17/2025, 4:22 AMbrief-egg-61061
04/17/2025, 4:22 AMbrief-egg-61061
04/17/2025, 4:22 AM