> For the complete documentation index, see [llms.txt](https://docs.openiam.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.openiam.com/troubleshooting/performance/jdbc-connection-pool.md).

# Increasing the JDBC connection pool size

Raising the JDBC connection pool size when load testing exhausts it, and where to set it on each deployment type.

| Symptom                                                               | Likely cause                                                             | Resolution                                                                       |
| --------------------------------------------------------------------- | ------------------------------------------------------------------------ | -------------------------------------------------------------------------------- |
| `Unable to acquire JDBC Connection` under load, with requests failing | The pool is exhausted — more concurrent work than it has connections for | [Size the pool](#size-the-pool) and set it on the services that use the database |

## Symptom

Under sustained load — a stress test against `/idp/rest/api/auth/public/login`, for example — requests begin failing with a JPA transaction error whose root cause is the pool:

{% code overflow="wrap" expandable="true" %}

```
javax.xml.ws.soap.SOAPFaultException: Could not open JPA EntityManager for transaction; nested exception is org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection
 at org.apache.cxf.jaxws.JaxWsClientProxy.mapException(JaxWsClientProxy.java:195) ~[cxf-rt-frontend-jaxws-3.3.6.jar:3.3.6]
 at com.sun.proxy.$Proxy244.getLoginByManagedSys(Unknown Source) ~[?:?]
 at org.openiam.ui.rest.api.mvc.AuthenticationRestController.loginPost(AuthenticationRestController.java:332) ~[classes/:?]
```

{% endcode %}

The deployment it was first seen on had four reverse proxies balancing their own `openiam-ui` instances across three backends, driven at roughly 5,000 requests a second.

## Size the pool

The shipped default is **20**, from `application.common.properties`. A starting point for a load test:

```
Concurrent users: X
TPS per user: 1.5
Avg query time: 0.5 seconds
Pool Size = (X * 1.5 * 0.5) * 1.2
```

{% hint style="info" %}
**Set it on the services that talk to the database** — `openiam-esb`, `openiam-auth` and `workflow`. Two services ship a lower value of their own: `risk-manager` and `privacy-manager` set `5` in their own `application.properties`, and raising the common default does not change them.
{% endhint %}

## Apply it

{% tabs %}
{% tab title="RPM" %}
{% stepper %}
{% step %}
**Point the service at a properties file.** Add this `-D` argument to `services/start_esb.sh`, alongside the ones already there:

{% code overflow="wrap" %}

```bash
-Dspring.config.location=$HOME_DIR/conf/application.esb.properties
```

{% endcode %}
{% endstep %}

{% step %}
**Create that file** with the value you calculated:

{% code title="conf/application.esb.properties" %}

```properties
org.openiam.jdbc.connection.pool.size.max=25
```

{% endcode %}

To watch the pool while testing, add this line as well:

```properties
logging.level.com.zaxxer.hikari=DEBUG
```

{% endstep %}

{% step %}
**Restart the service**, and confirm the old process is gone — a surviving process still holds the old pool.
{% endstep %}

{% step %}
**Check the value took.** With Hikari at `DEBUG`, the configuration is printed at startup. These are the lines that matter:

{% code overflow="wrap" %}

```
com.zaxxer.hikari.HikariConfig  : maximumPoolSize.................25
com.zaxxer.hikari.HikariConfig  : minimumIdle.....................25
com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Pool stats (total=1, active=0, idle=1, waiting=0)
```

{% endcode %}

`waiting` climbing above zero during a test means the pool is still too small.
{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Kubernetes" %}
Java options are held per service in `terraform.tfvars`, under a `javaOpts` block with an entry for each service and a `global` entry:

{% code title="terraform.tfvars" %}

```hcl
javaOpts = {
  global      = "..."
  esb         = "-Dorg.openiam.jdbc.connection.pool.size.max=25"
  authmanager = "..."
}
```

{% endcode %}

Then apply:

```bash
terraform apply
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.openiam.com/troubleshooting/performance/jdbc-connection-pool.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
