12

We are having a Keycloak 4.8.1.Final deployed on a k8 cluster with two nodes with default settings. Backend database is PostgreSQL.

We are increasing the number of realms in Keycloak to figure out if Keycloak can support a larger number of realms; these creations are done sequentially.

However, when the quantity of realms reach around 470, it makes keycloak basically unusable with admin GUI not loading at all and requests taking too long to execute.

Below is a summary of the time taken. We have not added any users into the realms.

+--------------+----------+------------+------------+------------+
|  Operation   | 0 realms | 100 realms | 250 realms | 350 realms |
+--------------+----------+------------+------------+------------+
| Create realm |     1104 |       3739 |       8659 |      11535 |
| Get realm    |      128 |        961 |       3067 |       3853 |
| Get token    |      636 |       1159 |       2714 |       3197 |
| Get roles    |      127 |       1037 |       3034 |       3649 |
+--------------+----------+------------+------------+------------+

Are there any known limitations or an optimal number of realms for a Keycloak deployment?

Already raised in user group as well.

7
  • 1
    The reason for this is Keycloak load all the realm in the cache at once
    – Arun Killu
    Commented Nov 3, 2020 at 11:01
  • Is there any news about this limitation ? Commented Dec 30, 2020 at 13:17
  • @lkamal could you try enabling the pg_stat_statements extension for your Postgres instance, and sharing info on the performance of DB queries, e.g. using SELECT * FROM pg_stat_statements ORDER BY max_exec_time DESC.
    – runeks
    Commented Feb 8, 2021 at 10:52
  • 1
    if my memory serves me there was a corresponding issue in Keycloak Jira and in recent or near future releases was/should be some improvements concerning multiple realms performance
    – solveMe
    Commented Feb 8, 2021 at 23:57
  • @lkamal it would also be helpful to know: a) what's the CPU usage of the keycloak process while waiting for requests to finish? b) what's the CPU usage of the postgres process? c) what machine type (CPU, RAM, disk type) is the keycloak and postgres processes running on? Which of these are the bottleneck?
    – runeks
    Commented Feb 9, 2021 at 7:53

1 Answer 1

3

There has been some opened issues on this for quite a while:

From what I recall, several sources point out that decrease of performance at about 400 realms. However, none of the issues above seem to have already been effectively tackled.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.