Skip to content

Session cache affinity #42776

@pruivo

Description

@pruivo

Description

Related to keycloak/keycloak-benchmark#598

The goal is to collocate the authentication, session, and all client sessions in the same Keycloak instance.

This enhancement assumes a well-behaved load balancer that always forwards requests from a user to the same Keycloak instances.
If the assumption above does not hold, these changes are no better (or worse, for that matter) than randomly deciding where the sessions are located.

Special attention to volatile sessions, and this may generate an uneven distribution of data. For example, running the Keycloak Benchmark only against a single Keycloak instance in the cluster leads to all sessions living in that instance, as shown below:

$ curl -s -k https://keycloak:9000/metrics | grep vendor_statistics_approximate_entries_in_memory | grep ession
vendor_statistics_approximate_entries_in_memory{cache="sessions",cache_manager="keycloak",node="pedro-desktop-29691"} 1000.0
vendor_statistics_approximate_entries_in_memory{cache="clientSessions",cache_manager="keycloak",node="pedro-desktop-29691"} 1000.0
$ curl -s -k https://keycloak:9001/metrics | grep vendor_statistics_approximate_entries_in_memory | grep ession
vendor_statistics_approximate_entries_in_memory{cache="clientSessions",cache_manager="keycloak",node="pedro-desktop-58822"} 0.0
vendor_statistics_approximate_entries_in_memory{cache="sessions",cache_manager="keycloak",node="pedro-desktop-58822"} 0.0

Discussion

No response

Motivation

No response

Details

No response

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions