# Infinispan Cache Config Recommendation

**URL:** <https://forum.keycloak.org/t/infinispan-cache-config-recommendation/20118>\
**Category:** Getting advice\
**Created:** [February 8, 2023, 11:59am UTC](https://forum.keycloak.org/t/infinispan-cache-config-recommendation/20118 "2023-02-08T11:59:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Plamka](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Plamka](https://forum.keycloak.org/u/Plamka)\
**Post date:** [February 8, 2023, 11:59am UTC](https://forum.keycloak.org/t/infinispan-cache-config-recommendation/20118/1 "2023-02-08T11:59:29Z")

</div>

Hi,

we have found that our keycloak in cluster mode runs on errors at some point.

```auto
ISPN000136: Error executing command PutKeyValueCommand on Cache 'offlineSessions', writing keys [5bd3a9cd-8993-427e-bdf3-dcdf6ed8c27e]: org.infinispan.util.concurrent.TimeoutException: ISPN000427: Timeout after 15 seconds waiting for acks. Id=850319

```

```auto
Uncaught server error: org.infinispan.util.concurrent.TimeoutException: ISPN000476: Timed out waiting for responses for request 944963

```

… CODE\_TOT\_TOKEN\_ERROR  
and so go on.

We suspect that the configuration is maybe not optimal for the amount of users.  
Is there any advice how the cache-container should be configured?

We modified `<expiration lifespan="-1"/> to <expiration lifespan="3600000"/>`

We suspect that the memory will continue to grow exponential with the lifespan = “-1” configuration.  
Does it make sense to set the livespan to a fixed value like 1h?

What are your experiences?

Our new configuration looks like this.

```auto

 <cache-container name="keycloak">
    <!-- custom stack must be referenced by name in the stack attribute of the transport element -->
    <transport lock-timeout="60000" stack="jdbc-ping-tcp"/>
    <local-cache name="realms">
      <encoding>
        <key media-type="application/x-java-object"/>
        <value media-type="application/x-java-object"/>
      </encoding>
      <memory max-count="10000"/>
    </local-cache>
    <local-cache name="users">
      <encoding>
        <key media-type="application/x-java-object"/>
        <value media-type="application/x-java-object"/>
      </encoding>
      <memory max-count="0"/>
      <expiration lifespan="3600000"/>
    </local-cache>
    <distributed-cache name="sessions" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <distributed-cache name="authenticationSessions" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <distributed-cache name="offlineSessions" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <distributed-cache name="clientSessions" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <distributed-cache name="offlineClientSessions" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <distributed-cache name="loginFailures" owners="2">
      <expiration lifespan="3600000"/>
    </distributed-cache>
    <local-cache name="authorization">
      <encoding>
        <key media-type="application/x-java-object"/>
        <value media-type="application/x-java-object"/>
      </encoding>
      <memory max-count="0"/>
      <expiration lifespan="3600000"/>
    </local-cache>
    <replicated-cache name="work">
      <expiration lifespan="3600000"/>
    </replicated-cache>
    <local-cache name="keys">
      <encoding>
        <key media-type="application/x-java-object"/>
        <value media-type="application/x-java-object"/>
      </encoding>
      <expiration max-idle="3600000"/>
      <memory max-count="1000"/>
    </local-cache>
    <distributed-cache name="actionTokens" owners="2">
      <encoding>
        <key media-type="application/x-java-object"/>
        <value media-type="application/x-java-object"/>
      </encoding>
      <expiration max-idle="3600000" lifespan="3600000" interval="300000"/>
      <memory max-count="-1"/>
    </distributed-cache>
  </cache-container>

```

Thx and best regards  
David

---

<div class="post-metadata">

**Author:** ![alath](https://avatars.discourse-cdn.com/v4/letter/a/b4bc9f/32.png) [@alath](https://forum.keycloak.org/u/alath)\
**Post date:** [August 29, 2024, 1:37pm UTC](https://forum.keycloak.org/t/infinispan-cache-config-recommendation/20118/2 "2024-08-29T13:37:56Z")

</div>

Dear David,

Is there any news on this issue?  
We are facing the same problem [https://forum.keycloak.org/t/infinispan-timeout/27651](https://forum.keycloak.org/t/infinispan-timeout/27651)

Thanks in advance,

Aris
