[keycloak-user] Externalising session storage in keycloak

Stian Thorgersen stian at redhat.com
Tue Apr 7 02:20:57 EDT 2015


We have support for using either Infinispan or a database (relational or Mongo) to store the user sessions when load balanced.

If performance is not a problem you can just go with storing sessions in the database. Otherwise go with Infinispan, see http://docs.jboss.org/keycloak/docs/1.2.0.Beta1/userguide/html/clustering.html for the details on how to configure that. To use a replicated cache instead of a distributed cache use the following config for Infinspan:

<subsystem xmlns="urn:jboss:domain:infinispan:2.0">
    <cache-container name="keycloak" jndi-name="infinispan/Keycloak" start="EAGER">
        <transport lock-timeout="60000"/>
        <invalidation-cache name="realms" mode="SYNC"/>
        <invalidation-cache name="users" mode="SYNC"/>
        <replicated-cachename="sessions" mode="SYNC"/>
        <replicated-cache name="loginFailures" mode="SYNC"/>
    </cache-container>
    ...
</subsystem>

You can also just use the configuration from the docs above but set 'owners="2"'.

----- Original Message -----
> From: "Kalinga Dissanayake" <kalinga at leapset.com>
> To: keycloak-user at lists.jboss.org
> Cc: "Stian Thorgersen" <stian at redhat.com>
> Sent: Monday, 6 April, 2015 2:13:42 PM
> Subject: Externalising session storage in keycloak
> 
> 
> Guys i know this has been discussed before, but im trying to find a simple
> number of steps for me to externalize the session storage in keycloak.
> I just need to do the following;
> 1. Two servers running keycloak (wildfly)
> 2. A load balancer in front of these two servers. Preferably an AWS
> loadbalancer
> 3. I need to store the session details on an external store so that the
> sessions work accurately.
>  
> There is so much documentation for this but I am actually confused as to what
> i should do and the bare minimum i should do to achieve this. I dont need a
> distributed cache or anything just need one cache store (may be infinispan
> or memcached) and the two keycloak servers running storing the sessions on
> that. Is there one key place i should look into which contains the bare
> minimum i should do.
>  
> Kalinga.
> 


More information about the keycloak-user mailing list