Skip to content
Multi-tenant SaaS

Keycloak multi-tenancy: a realm per tenant or one for all

Every multi-tenant product has to decide where one tenant’s users end and the next one’s begin. Keycloak gives you two clean answers. Here is what each costs, and how to choose.

Point here to play
A simplified drawing. Both models run on the same kind of cluster.
The short answer

Both models work. A realm per tenant gives each tenant its own users, login settings, signing keys and admin boundary, but your app must trust one issuer per tenant and every realm is configured on its own. One realm with Organizations keeps a single set of clients and flows and names the tenant in each token, but every tenant shares the realm’s login settings. Most products start with Organizations and give a tenant its own realm only when it needs settings the others cannot share.

How it works

Built from Keycloak’s own parts

Realms, clients, authentication flows and mappers, as the standard admin console has them. Nothing here needs a custom extension.

Model A: a realm per tenant

A realm is Keycloak’s hardest boundary. Each one has its own users, groups, roles, clients, identity providers, authentication flows, password policy, session lengths and signing keys. A user in one realm does not exist in another, even with the same email address.

That isolation has a price your app pays:

  • Each tenant has its own issuer, such as https://auth.yourcompany.com/realms/tenant-a. Your app has to pick the realm before sign-in, usually from a subdomain or a tenant picker, and accept tokens from many issuers.
  • Clients, scopes, mappers and flows exist once per realm. A change you want everywhere is made in every realm, by hand or through the admin REST API.
  • Each realm counts against the plan: up to 2 on Starter, 20 on Premium and 100 on Enterprise.

In return, a tenant admin can be given rights over one realm only, and one tenant’s settings can never leak into another’s.

Model B: one realm with Organizations

Organizations, fully supported since Keycloak 26.0, divide one realm by tenant. Each organization has its members, its email domains, its own groups and, when it wants one, its own identity provider. Your app has one client and one issuer; the tenant arrives in the organization claim when the client asks for the organization scope.

What stays shared is everything that belongs to the realm: the password policy, brute-force settings, session and token lifetimes, the login theme and the default flows. A client can override the browser flow for itself, but not per organization. And because users are unique in a realm, one email address is one account, which can be a member of several tenants.

Delegation has improved in recent releases: Keycloak 26.7 added manage-organizations, view-organizations and query-organizations roles, and fine-grained admin permissions can limit an administrator to specific organizations.

Side by side

A realm per tenantOne realm, Organizations
UsersSeparate per tenantOne account per person, member of one or more tenants
Login settingsPer tenantShared by all tenants
Signing keysPer tenantOne set
Your app trustsOne issuer per tenantOne issuer
Adding a tenantA realm, its clients and settingsAn organization
Tenant-only adminsRealm admin rolesOrganization roles and fine-grained permissions
Limit on our plans2, 20 or 100 realmsOne realm for all tenants

Mixing the two, and moving later

A common shape is Organizations for most tenants and a dedicated realm for the few that need their own policy or keys. Your app then handles two kinds of issuer, which is worth designing for from the start: resolve the tenant first, then the issuer.

A tenant that needs more than a realm, such as its own uptime or another region, can have a cluster of its own: each RealmDeploy order is a separate cluster in the region you pick.

Moving tenants between models is a realm export and import, planned and tested on a copy first. On Premium and Enterprise, the 10 service hours a month can go to that work. The realm export analyzer shows what a realm holds before you move it.

Who does what

We run the server. You shape the realm.

RealmDeploy runs
  • One Keycloak cluster for every realm you have, up to the plan’s limit
  • Upgrades that move every realm and organization together, after a backup
  • Point-in-time restore of the whole database, all realms included
  • A separate cluster per order, when a tenant needs one
  • Monitoring with per-realm error alerts, and our on-call
You configure, in the admin console
  • The choice of model, and how your app finds the tenant
  • Realms or organizations, with their domains and identity providers
  • Clients, scopes and mappers, kept in step across realms
  • Admin roles for tenant administrators
  • Login settings per realm
Which plan

Usually Premium

The plans are sized by realms and by active users a month: people who sign in at least once in the month. These are sizing guides, not hard caps.

Starter$199 a month
  • Dedicated Keycloak, 1 replica
  • Up to 2 realms
  • Sized for about 5,000 active users a month
  • Best effort, no uptime SLA
Fits this jobPremium$999 a month
  • High-availability cluster, 2+ replicas
  • Up to 20 realms
  • Sized for about 100,000 active users a month
  • 99.9% monthly uptime SLA
Enterprise$2,499 a month
  • Larger high-availability cluster
  • Up to 100 realms
  • Sized for about 500,000 active users a month
  • 99.95% monthly uptime SLA

With Organizations, size by users: Premium takes about 100,000 active users a month in one realm, with two or more replicas and a 99.9% SLA. With a realm per tenant, count tenants as well: Premium holds up to 20 realms and Enterprise up to 100, for about 500,000 active users and a 99.95% SLA. Starter’s 2 realms suit a trial of either model, not production. Past 100 realms, a Custom plan is sized with you.

Every plan, feature by feature

Questions

Frequently asked questions

How many realms can one cluster hold?

Up to 2 on Starter, 20 on Premium and 100 on Enterprise. With Organizations you need only one realm for all tenants. For more realms, a Custom plan is sized to what you need.

Can two tenants have different password policies?

Only with a realm each. The password policy, brute-force detection and session lengths belong to the realm, so organizations in one realm share them.

Can the same email address sign up in two tenants?

With a realm per tenant, yes: they are two separate accounts. With Organizations, one email is one account, which can be a member of both tenants.

Can a tenant admin manage only their own tenant?

Yes in both models. With a realm per tenant, give them admin roles in that realm only. With Organizations, use the organization admin roles and fine-grained admin permissions to limit them to their organization.

Can one tenant have a cluster of its own?

Yes. Each RealmDeploy order is a separate cluster with its own Keycloak and PostgreSQL, in the region you choose, so a tenant with stricter needs can be moved to one.

Which model makes upgrades easier?

We upgrade the whole cluster at once in both. The difference is your own configuration: with many realms, the clients and flows you keep in step multiply with each tenant.

Can we switch models later?

Yes, with planning. Moving a tenant means exporting and importing its users and settings, which we test on a staging copy first. Your app must also handle the change of issuer or claim.

Run it on a cluster of your own

Order a realm in the dashboard, or write to us first about what you are building.