[keycloak-user] slow role search

Gideon Caranzo gideonray at gmail.com
Thu Sep 27 13:02:20 EDT 2018


Hi,

I'm running Keycloak with 1700 realms and API calls like getting a realm
now takes a lot of time. I profiled it and found that role checking is
causing the issue particularly *KeycloakModelUtils.searchFor(RoleModel
role, RoleModel composite, Set<String> visited)*.

I'm using a user with "admin" role to call get realm API. And since i have
1700 realms, "admin" role now have about 30K composite roles under it. The
line below from KeycloakModelUtils.searchFor() will load all 30K composite
roles causing the slow down.

        *Set<RoleModel> compositeRoles = composite.getComposites();*

Is there a way to avoid this issue? Or is it possible to fix the code such
that it will do a database query instead of searching in memory to check if
the role exist?

Thank you,
Gideon


More information about the keycloak-user mailing list