# Maximum Limit of Realms

**URL:** <https://forum.keycloak.org/t/maximum-limit-of-realms/8189>\
**Category:** Getting advice\
**Tags:** admin-console\
**Created:** [March 29, 2021, 10:00am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189 "2021-03-29T10:00:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![athiranibu](https://avatars.discourse-cdn.com/v4/letter/a/edb3f5/32.png) [@athiranibu](https://forum.keycloak.org/u/athiranibu)\
**Post date:** [March 29, 2021, 10:00am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/1 "2021-03-29T10:00:53Z")

</div>

What can be the maximum number of Realms that can be created for a single Keycloak Instance? Also, will there be any performance issues if the realm count rises above 1000+. If so suggest any alternate solutions. I am using Keycloak Version : 11

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [April 1, 2021, 6:15pm UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/2 "2021-04-01T18:15:35Z")

</div>

It depends on your setup, but people here have reported serious problems when using more than ~400 realms in one Keycloak instance.

---

<div class="post-metadata">

**Author:** ![baensaf](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/baensaf/32/4168_2.png) [@baensaf](https://forum.keycloak.org/u/baensaf)\
**Post date:** [October 17, 2021, 10:57am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/4 "2021-10-17T10:57:40Z")

</div>

we want to service a million users from thousands of companies  
should we use realm for each company or we should isolate them in another way?

---

<div class="post-metadata">

**Author:** ![xgp](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/xgp/32/2589_2.png) [@xgp](https://forum.keycloak.org/u/xgp)\
**Post date:** [October 18, 2021, 6:57am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/5 "2021-10-18T06:57:03Z")

</div>

It depends. Do you need to connect an external identity broker or user federation source for each of those companies?

If so, my approach in the past has been realm per company, that then broker to a single realm that you use for authentication for your app. That gives you the flexibility to add new tenant/company clusters if you run up against scaling problems with a single Keycloak instance. The downside is that you need to build your own approach to get users to the right realm (I use a custom Authenticator for this).

If not, there may be a simpler way to architect it with a single realm, like using groups to identify company membership.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [October 18, 2021, 3:25pm UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/6 "2021-10-18T15:25:35Z")

</div>

Brokering various realm to a single one also duplicates total session count and thus needs more resources.

Another thing is: Do you really want to put all your customers/tenants/etc. into one single Keycloak system (no matter if clustered or not) and thus have one giant single point of failure? If this one and only Keycloak isn’t working any more, no one of your customers is able to auth and work with your applications.  
Clustering just mitigates the risk, but it doesn’t eliminate it. Be aware of this!

---

<div class="post-metadata">

**Author:** ![stumkar](https://avatars.discourse-cdn.com/v4/letter/s/ac91a4/32.png) [@stumkar](https://forum.keycloak.org/u/stumkar)\
**Post date:** [June 3, 2022, 1:17am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/7 "2022-06-03T01:17:10Z")

</div>

@baensaf did you get any resolution for your usecase? We have similar usecase where we need to create millions of realms. To performance test, I am trying to create this using keycloak benchmark tool but its breaking after 1250 realms and not allowing me to create any. I dont want keycloak to cache anything as I am not loading admin UI (just want to setup data) but still keycloak fails from 1250 realms which is very minimal number. I tried commenting the realm caching code in benchmark tool but it didnt help. Any suggestions?

---

<div class="post-metadata">

**Author:** ![dwadie](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dwadie/32/4775_2.png) [@dwadie](https://forum.keycloak.org/u/dwadie)\
**Post date:** [December 9, 2022, 10:13am UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/8 "2022-12-09T10:13:07Z")

</div>

@stumkar, we have seen keycloak ui errors after 240 realms some of the UI will not load. Did you try to load any UI when you reach 1000 and over realms? or even keycloak operate. Not sure if anyone else have any success reaching high number of realms

---

<div class="post-metadata">

**Author:** ![vikkes](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/vikkes/32/7490_2.png) [@vikkes](https://forum.keycloak.org/u/vikkes)\
**Post date:** [January 18, 2023, 6:55pm UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/9 "2023-01-18T18:55:14Z")

</div>

So is keycloak not a good choice for millions of realm? Any suggestion how to do it.

---

<div class="post-metadata">

**Author:** ![mfechtner](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/mfechtner/32/9297_2.png) [@mfechtner](https://forum.keycloak.org/u/mfechtner)\
**Post date:** [November 17, 2023, 3:23pm UTC](https://forum.keycloak.org/t/maximum-limit-of-realms/8189/11 "2023-11-17T15:23:37Z")

</div>

I would like to invest in your business 🙂  
Most business have a couple of hundred clients, which can be handled with one realm or a couple of realms.  
A use case we faced is where we want to offer our clients their own identity provider/s.

The standard clients go into the same realm and for the professional client get their dedicated realm.  
You just need to get the automation right and it works very well.
