Hi,
Firstly, would like to thank everyone who has contributed to Keycloak. We are using it for all user management and authorization and are extremely happy with it.
As the number of protected resources in our deployment has grown over time I noticed that Keycloak’s CPU began to spike from time to time.
Our web application has quite a few pages that list protected resources which the user has permissions to see, and allow the user to page through them. A pattern I believe is very common to almost any application 🙂
To back those pages, our application asks Keycloak for an RPT in order to work out what resources the user has permissions to see. From what I understand based on a brief dive into Keycloak’s code, unless asked to evaluate specific resources, Keycloak selects all permissions from the database and loops over them, one-by-one for evaluation. It is possible to supply a max value for the number of positive evaluations, however, if the user has permissions only for a small subset of resources, and the total number of resources is quite large, it can still take some time (and CPU) to build this list.
While this approach of permission evaluation is extremely flexible (e.g. based on my understanding Keycloak allows to create custom permissions using e.g. JS), it limits scalability. We only use group and user based permissions, and I was hoping Keycloak would e.g. push the resolution of these permissions to the db, where db indexes could be used to speed up evaluation.
Is there any guidance around the recommended maximum number of resources that should be used with Keycloak's authorization?
I would love to hear what others have experienced using Keycloak’s authorization with hundred thousand (or more) resources? How long does it take to receive a response for RPT?
Are there any plans to improve the scalability of Keycloak’s authorization?
Again, thanks a lot for making Keycloak a reality!
Cheers,
Anton