Slow startup with a million records of Offline_user_session

We have a million users in our app and we use offline tokens. So our offline_user_session table has a million records

It takes Keycloak more than 30 minutes to start.
If I delete everything from offline_user_session, everything starts in 30 second.

Is there any configuration or maybe I’m doing something wrong

I use docker image from here:

I change no configurations.


Any updates, please? I am facing the same issue with Keycloak 9.0.2 and PostgreSQL 9.6.6.

This issue should be fixed in 14.0.0 ([KEYCLOAK-11019] Offline sessions preloading still slow in some cases - Red Hat Issue Tracker). There is also workaround mentioned for previous versions.

1 Like