
:guide-id: concepts-database-connections
:guide-title: Concepts for database connection pools
:guide-summary: Understand concepts for avoiding resource exhaustion and congestion.
:guide-priority: 999
:guide-tile-visible: false
:version: 26.2.4

include::../attributes.adoc[]

[[concepts-database-connections]]
= Concepts for database connection pools

ifeval::["" == "true"]
WARNING: This {section} is describing a feature which is currently in preview.
ifeval::["" == ""]
Please provide your feedback while we’re continuing to work on this.
endif::[]
ifeval::["" != ""]
Please provide your feedback by link:[joining this discussion] while we’re continuing to work on this.
endif::[]
endif::[]


This section is intended when you want to understand considerations and best practices on how to configure database connection pools for {project_name}.
For a configuration where this is applied, visit link:{links_high-availability_deploy-keycloak-kubernetes_url}[{links_high-availability_deploy-keycloak-kubernetes_name}].

== Concepts

Creating new database connections is expensive as it takes time.
Creating them when a request arrives will delay the response, so it is good to have them created before the request arrives.
It can also contribute to a https://en.wikipedia.org/wiki/Cache_stampede[stampede effect] where creating a lot of connections in a short time makes things worse as it slows down the system and blocks threads.
Closing a connection also invalidates all server side statements caching for that connection.

include::partials/database-connections/configure-db-connection-pool-best-practices.adoc[]


