Keycloak multi-cluster active-active deployment (v2)

Keycloak multi-cluster v2 runs active-active across clusters without external Infinispan, but only if the synchronously replicated database, latency budget, health probes and runbooks are designed first.

On this page

Keycloak multi-cluster active-active deployment: when teams need it

If your identity service must keep working when one site or cluster is lost, multi-cluster v2 is one of the high availability architectures Keycloak documents, and it requires a synchronously replicated database. The design runs two or more independent Keycloak clusters, each in its own location, against a shared database that is kept in sync across sites. Keycloak's high availability overview lists it alongside the single-cluster design, and the deprecated v1 design that needed a separate Infinispan cluster per site is not the path to choose for new work.

The v2 design is not automatic failover of sessions, and it is not a way to avoid planning for the database. Each cluster still runs its own Keycloak nodes, and the stateless feature is what lets nodes avoid depending on a session store that spans sites. Every login, token issuance and admin change waits for the database to confirm the write at both sites, so the round trip between sites sets the floor for response time. Ask your database vendor and your network team to measure that latency before you commit to the design, and confirm the Keycloak release notes for the exact multi-site behavior in your version.

If your sites are close enough that one cluster can span them, a single cluster across availability zones is usually the simpler fit. It has fewer moving parts, one set of nodes to operate and one upgrade path, and it fits a latency budget that the multi-zone design documents. Choose multi-cluster v2 when you need separate clusters that can each be upgraded, drained and recovered on their own, or when your sites are far enough apart that a single cluster cannot meet the latency requirement. Confirm with your architecture team which failure you must survive, a zone outage, a data center loss or a regional event, because that answer decides which design you build.

How the clusters, database and global load balancer fit together

The diagram starts with users reaching a global load balancer that runs health probes against each site and sends traffic only to healthy clusters. Each cluster has its own Keycloak nodes, and the nodes in every cluster write to one synchronously replicated database that spans the sites. The admin hostname sits in a separate trust boundary from the public frontend, so administrative traffic never shares a path with login traffic. Check that probes target the management endpoints, that every site reaches the same database, and that the admin boundary holds at the load balancer.

Two sites share one synchronously replicated database, with admin traffic kept on a separate hostname.

How the commit latency budget limits multi-cluster Keycloak

The commit latency budget is the most important constraint in a multi-cluster v2 design, because almost every login writes to the database. Sessions, login events, token-related state and user updates are persisted as the request completes, so each write waits for the database to acknowledge it. When the database is synchronously replicated across sites, that acknowledgment cannot return until the remote site has confirmed the write. Every inter-site round trip therefore adds directly to the time a user waits for sign-in, and it also holds a database connection and an HTTP worker thread for longer.

Set the budget before choosing a topology. Start from the login and token response times your applications can tolerate, subtract the time spent in the load balancer, Keycloak processing and the client, and treat what remains as the maximum commit time you can accept across the link between sites. Measure the real round-trip time between your sites under peak network load, not the figure in a provider's brochure, and measure commit latency on the database you plan to run. Then run a load test at expected peak to see how write latency behaves when connections queue. Confirm the maximum inter-site latency that Keycloak supports for the version you deploy in the Keycloak high availability overview and in the release notes for that version, and do not design against a figure taken from memory or from an older release.

If the measured round trip consumes most of the budget, the answer is a different design, not a larger timeout. Ask the database vendor how synchronous replication behaves during a site loss, because a failed link can block writes until the replica is reachable again or until an operator changes the replication mode. Record who makes that decision, how long it may take, and what users see while it is pending. These trade-offs belong in the runbook, and the team should rehearse them before go-live.

Which multi-cluster design fits which requirement

This table compares the three high availability architectures Keycloak documents: a single cluster spread across zones, multi-cluster v2 without external Infinispan, and the deprecated multi-cluster v1. Read each row as a question you must answer before choosing, and treat the deprecation status as a hard filter for new builds.

Decision factorSingle cluster across zonesMulti-cluster v2 (no external Infinispan)Multi-cluster v1 (deprecated)
Infrastructure dependencyOne Keycloak cluster with nodes in several availability zones or data centersTwo or more separate Keycloak clusters, each with its own nodes and databaseTwo or more Keycloak clusters, plus a separate Infinispan cluster per site
Database requirementSynchronously replicated database across zonesSynchronously replicated database across sitesSynchronously replicated database across sites
Operational burdenOne cluster to run, upgrade and monitor, with zone-aware pod placementSeveral clusters to run, with cross-site health probes and coordinated runbooksSeveral Keycloak clusters and several Infinispan clusters to run and upgrade
Deprecation statusSupported, documented as a standard high availability optionDocumented as a supported design in the high availability guideDeprecated; the upgrading guide recommends moving to the stateless feature
Latency constraintZone-to-zone latency must stay within the limit the project documents for this designSite-to-site latency must fit the commit latency budget of the synchronously replicated databaseSite-to-site latency affects both the database and Infinispan replication
When it fitsOne region or metro area where a single cluster and a shared database are acceptableSites that must keep serving logins when one site fails, and the team can run a synchronous database across themExisting v1 estates that need a migration plan, not a new build
When to avoidSites too far apart for the documented latency limitSites with no synchronous database option or no capacity to run cross-site runbooksAny new deployment; plan a move to v2 or the stateless feature

Setup sequence for a multi-cluster v2 deployment

This sequence takes a team from a confirmed database and latency budget to two Keycloak clusters that serve the same realms, route traffic through global health probes and fail over on a rehearsed runbook. Each phase closes with a check that can be repeated before go-live.

  1. Confirm a supported synchronously replicated database

    The platform team confirms that the chosen database appears on Keycloak's supported production list and that it can replicate synchronously between sites, because both supported high availability designs depend on this. Ask the database vendor to document the replication mode, the failover behavior and the commit acknowledgement rule in writing. Done means the architecture record names the exact database product and version, and the vendor's documentation confirms synchronous commit across both sites. Do not proceed with a database that only replicates asynchronously, since the v2 design cannot be supported on it.

  2. Measure inter-site latency against the commit budget

    The network team measures round-trip latency between the two sites over the same links the database will use, under peak traffic and not only in quiet periods. Compare the measured figure with the commit latency budget in the Keycloak high availability documentation and record how much headroom remains for each login transaction. Run a sustained test that covers both average and tail latency, and include packet loss and jitter in the results. Done means a signed-off latency report shows that the measured values fit the budget with margin. If the budget is exceeded, stop and revisit the site placement or the database topology.

  3. Deploy identical Keycloak releases to each cluster

    The Keycloak operator or deployment team installs the same Keycloak release, the same providers, themes and configuration files in each cluster, and uses the same database connection settings with the multi-cluster v2 options enabled. Pin the release version in the deployment manifests, set operator updates to manual approval, and store both configurations in version control so drift can be detected. Check the exact release number against the current release on keycloak.org before you pin it. Done means a diff of the rendered configuration for the two clusters shows no differences other than site-specific values such as hostnames and zone labels.

  4. Configure global load balancer probes on the management interface

    The network or platform team configures the global load balancer to check each cluster's health through the management interface, not the public application port, so that a node can be drained before users see errors. The probe should query the health endpoints that Keycloak exposes on the management port, and the team should set failure thresholds with the load balancer vendor's documentation in hand. Metrics on the same management interface should be enabled only where monitoring needs them, and the admin and management paths must stay off public hostnames. Done means a forced failure of one cluster's health endpoint removes that site from rotation within the probe window, and the site returns after the check passes again.

  5. Synchronize clocks across all nodes and the database

    The infrastructure team configures time synchronization on every Keycloak node, every database node and the load balancer, pointing each to the same trusted time sources at both sites. Token validity, session expiry and replication ordering all depend on consistent clocks, so skew can cause tokens to be rejected or sessions to expire early. Document the time source for each host and the monitoring alert for drift. Done means a time offset check across all hosts reports a difference within the tolerance the team has set in its runbook, and the alert fires in a test when drift is introduced on purpose.

  6. Rehearse failover and failback before go-live

    The operations team runs planned failover tests in a non-production copy of the design, then in production during a agreed window, stopping one site and confirming that logins, token refresh and admin access continue through the surviving site. Repeat the test with a database switchover and with failback to the original site, and record the observed errors and recovery time. Write the results into the operating runbook, including who makes the failover decision and how users are informed. Done means each scenario has a recorded result, the runbook has been updated from the findings, and the team has tested a restore from backup as part of the drill.

Clock synchronization and health probes that keep sites consistent

In a two-site active-active design, clocks and health signals decide what each site believes and where users land. Clock drift can break token validation and replication ordering, while stale health probes can keep sending users to a site that is already degraded. The cards below cover the checks that keep both sites agreeing on time and on their own state.

Time sync across nodes and sites

Every Keycloak node, database host and load balancer should take time from a source that all sites share, configured with the same time service on each host. Tokens carry issued-at and expiry claims, so a node running fast or slow can issue tokens that other sites reject or accept too long. Ask your platform team which time source each site uses and whether the two sources are independent of each other.

Health endpoints for global probes

Keycloak exposes health endpoints on its management interface, which a global load balancer can probe without touching public login traffic. Probe the management port, not the public frontend, so that a site can be marked unhealthy even when user-facing paths still respond. Confirm the exact health paths and the management port for your Keycloak version in the docs before you write probe rules.

Keycloak production guide

Drift detection and alerting

Clock drift is silent until a token check or a replication conflict fails, so measure it directly on every host and alert before it reaches the application. Watch the offset reported by the time daemon, not just whether the daemon is running. Set the alert threshold with your security team and document who responds when it fires.

Probe thresholds and failover timing

The number of failed probes before a site is removed, and the interval between probes, set how quickly traffic moves after a failure. Short intervals with few required failures move traffic fast but can flap during brief database stalls, while long intervals keep users on a failing site longer. Choose these values by testing a planned site outage in your environment, and record the agreed values in the runbook.

Stale probes and degraded routing

A probe that caches its last answer, or that checks only a load balancer rather than Keycloak itself, can keep sending logins to a site whose database is failing. Users then see slow sign-ins, failed token refreshes or errors that look like random outages. Verify that each probe reflects a real login-path check and that the global load balancer drops a site once its probe fails.

Failback after a site recovers

When a failed site returns, its clock, database replica and probe state must be correct before it takes traffic again. Routing users back too early can expose the site to drift or an unfinished database catch-up. Put the failback conditions, such as a clean drift check and a passing login test, in the runbook and rehearse them during planned tests.

Questions teams ask before building multi-cluster Keycloak

What drives the cost of a multi-cluster Keycloak build?

The cost follows the number of sites, the database design and the amount of testing and runbook work your team needs. Keycloak's multi-cluster v2 design without external Infinispan still requires a synchronously replicated database, so the database platform, its licensing or managed service fees, and the network between sites are often the largest recurring items. One-time costs include discovery, environment setup, load and failover testing, and documentation of the operating runbooks. Ongoing costs include database capacity, the second and later cluster's infrastructure, monitoring, and patching across every site. Ask any partner for a written quote that separates one-time build work from recurring support, and ask which infrastructure lines you pay directly.

How long does a multi-cluster Keycloak build take?

Duration depends on how many clusters you run, how much of the surrounding platform already exists, and how much proof you need before go-live. The main drivers are the database replication design, the global load balancer and health probe setup, clock synchronization checks across sites, and the failover tests that show the design behaves as intended. Work goes faster when the database team already operates synchronous replication and when your identity integrations are already documented. Work slows when the commit latency budget is unclear or when security reviews, change windows and load tests need to be scheduled. Ask for a timeline tied to a written scope and named milestones rather than a single end date.

What does the client team need to provide for the engagement?

Your team provides the knowledge and access that the design depends on. Expect to supply the target infrastructure accounts or data centers, network paths between sites, the database platform decision and an owner for it, DNS and certificate management for the global hostnames, and the identity sources and applications that will sign in through Keycloak. You also need a named person who can approve changes, accept test results and own the runbooks after handover. Early in the engagement, confirm which site-to-site latency your network can guarantee, because the commit latency budget depends on it. A partner can prepare the design, but your operations staff must be able to run it.

Can our own team build a multi-cluster Keycloak deployment?

Yes, if your team has experience with Keycloak clustering, synchronously replicated databases, global load balancing and multi-site failover testing. The Keycloak documentation describes the supported high availability architectures and the requirement for a synchronously replicated database, so the reference material is public. The harder parts are usually the failure drills, clock synchronization monitoring and writing runbooks that operators trust during an incident. Check whether your team has run database failover tests and whether it can reproduce a site loss in a non-production environment. If one of these gaps exists, a fixed-scope engagement can cover that part while your staff take over the operation.

Which operating tasks recur after a multi-cluster Keycloak goes live?

The recurring work is the operations that keep every site consistent. Plan for Keycloak release upgrades, which the project ships as four minor releases a year, with major releases every two to three years, so every site must follow the same tested sequence. Plan for database maintenance across the synchronous replica set, regular failover drills, monitoring of commit latency and clock drift, and certificate and secret rotation. Keycloak exposes Prometheus-format metrics at /metrics when metrics are enabled, which helps your monitoring confirm each site's health. Confirm with your team who performs each task and how often the drills run.

How do Keycloak upgrades change a multi-cluster design?

Upgrades affect every site at once, so the design must make a rolling sequence possible. The Keycloak project says breaking changes in minor releases are opt-in, and the 26.8 upgrade notes include stricter defaults such as enforced SMTP StartTLS and mandatory signature validation of backchannel logout tokens from external providers. The database schema migrates automatically at startup by default, but the upgrading guide suggests manual migration for large deployments, which changes the runbook. The 26.8 notes also recommend moving from the deprecated multi-site feature to the stateless feature, so a design planned now should match the current architecture. Ask for an upgrade test plan that covers two adjacent releases and a rollback decision point.

Should we choose the Operator or a manual installation for multi-cluster?

The Keycloak Operator is the path the project documents for Kubernetes, installed through Operator Lifecycle Manager as the recommended method. It manages Keycloak custom resources, which helps keep the configuration of each cluster consistent. The Operator documentation strongly recommends manual approval mode for operator updates, which avoids unplanned upgrades across sites. If your platform does not run Kubernetes, the same architectural rules still apply, but the automation and runbooks will be different. Confirm which platform your organization standardizes on before the design starts, because it determines how upgrades, configuration and rollbacks are handled.

Security and operational considerations across sites

A multi-cluster Keycloak stretches identity across sites, so every exposure, secret and upgrade step multiplies. The cards below cover the checks that apply to each site and to the shared database that connects them. Review them before the first site goes live, then again at each upgrade.

TLS on all communication

Keycloak's production guide calls for TLS on all communication, so the path from clients to the load balancer, from the load balancer to each node, and from each node to the database needs encryption. Across sites, traffic between clusters and the synchronously replicated database often crosses networks you do not fully control. Confirm certificate issuance and rotation for every site, and test that each hop rejects plaintext connections.

Production guide

Separate admin and public hostnames

Expose the admin console and Administration REST API on a different hostname or context path from public frontend URLs. Each site's reverse proxy should restrict paths so that administrative endpoints are reachable only from management networks. Check that every site uses the same split, because a site that exposes admin paths publicly weakens the whole deployment.

Production guide

Metrics on the management interface

Keycloak exposes Prometheus-format metrics at /metrics on its management interface when started with --metrics-enabled=true. Keep that endpoint off public routes and scrape it from each site's monitoring network. Watch database connection and cache metrics on every site, since a problem in one site can appear first as a latency rise in another.

Metrics guide

Database credentials and backups per site

The shared database holds realms, users, sessions and credentials, so its credentials must be stored in each site's secrets system and rotated on a schedule that every site follows. Backups must cover the database and the Keycloak configuration, providers and themes, since realm exports alone are not a complete recovery. Ask who restores the database, where backup copies live, and whether a restore has been tested from a second site.

Database guide

Upgrade notes that affect multi-site operations

The Keycloak 26.8 upgrade notes add enforced SMTP StartTLS without plaintext fallback, mandatory signature validation of backchannel logout tokens from external providers, and login failures persisted to the database by default. They also recommend moving from the deprecated multi-site feature to the stateless feature. Review each note against your mail relay, external identity providers and database growth before rolling the new version across sites.

Upgrading guide

The operating runbooks multi-cluster Keycloak requires

A multi-cluster Keycloak design is only as good as the runbooks that operate it, and the design fails most often at the moments nobody rehearsed. Five runbooks cover the events that matter: a site failure, a database failover, a probe misrouting, clock drift between clusters and a planned upgrade. Each needs a named owner, a written trigger, a decision point for who may fail traffic over, and a check that confirms recovery. Identity usually belongs to the platform or security team, but the database runbook sits with whoever runs the synchronously replicated database, and the global load balancer runbook sits with the network team. Agree those boundaries before the first incident, not during one.

Failover must be tested, not assumed. Run the site failure and database failover runbooks in a non-production copy of the topology, measure how long sign-in takes to recover from the client side, and record which steps needed a person. Probe misrouting deserves its own test: confirm that the global load balancer health checks mark a site unhealthy when its Keycloak nodes or database connection fail, and that traffic does not return to a site that is still degraded. Clock drift is easy to overlook because it does not fail loudly. Confirm that every node in both clusters synchronizes time from the same trusted source and alert on drift, since token validation depends on it.

Planned upgrades need their own runbook because the two sites must move through a version change without serving mismatched Keycloak builds for longer than the design allows. Read the upgrade notes for each release in the Keycloak upgrading guide before scheduling, and keep Operator updates in manual approval mode so that no site upgrades on its own. DR drills and load tests are separate topics with their own plans. Schedule them alongside these runbooks, not inside them, and ask your partner or internal team to state in writing which runbooks are covered by each.

How DeployOpen scopes and delivers multi-cluster Keycloak

DeployOpen plans, implements, hardens, documents and supports self-hosted Keycloak inside your own infrastructure, including multi-cluster active-active designs without external Infinispan. Engagements start with a written scope that fixes the clusters, the database, the health probes and the runbooks before any build begins.

How we scope

  • Confirm the number of clusters, their locations and the latency between them before choosing a commit latency budget.
  • Agree in writing which synchronously replicated database product and topology the design will use, and who operates it.
  • Define the global load balancer health probes, clock synchronization checks and the failure scenarios the design must survive.

How we build

  • Deploy Keycloak nodes in each cluster with the multi-cluster v2 settings, following the Keycloak high availability documentation for the chosen version.
  • Configure the database connection, schema migration method and TLS on all links, and expose admin and management endpoints on separate hostnames or paths.
  • Test write latency, session behavior and failover between sites with your own traffic patterns before any cutover decision.

How we hand over

  • Deliver runbooks for site failover, failback, database switchover, operator update approval and clock drift response.
  • Document the configuration, monitoring at the metrics endpoint and the alert thresholds your operators will use day to day.
  • Run a joint failover drill with your team and record the results, the open findings and the owner of each fix.

How we support

  • Engagements are fixed-scope, and any follow-up work is agreed in a separate written scope.
  • Ongoing support, upgrades and continuous testing for multi-cluster Keycloak are available as a retainer.
  • Confirm with DeployOpen which upgrade and retest responsibilities sit in the retainer and which remain with your team.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.