Keycloak Ha
You set up a keycloak ha cluster by running multiple nodes over one shared database. These nodes also share an in-memory cache to sync active login states. Most teams put a load balancer in front to split user traffic across servers. This design keeps your login portal online when one server goes down. Yet high uptime does not fix the danger of broad user roles. When an admin role has too much power, every node honours that risky permission. How a keycloak ha architecture works A single ident
Keycloak: the complete guide
Architecture patterns, implementation strategies, and security best practices. Delivered to your inbox.
You set up a keycloak ha cluster by running multiple nodes over one shared database. These nodes also share an in-memory cache to sync active login states. Most teams put a load balancer in front to split user traffic across servers. This design keeps your login portal online when one server goes down. Yet high uptime does not fix the danger of broad user roles. When an admin role has too much power, every node honours that risky permission.
How a keycloak ha architecture works
A single identity server creates a single point of failure for your whole team. If that machine crashes, nobody can log in to your apps or databases. High availability solves this by running two or more active nodes at once. Each node runs the exact same software and reads from one central database. The database holds realms, users, groups, and role mappings in persistent tables.
Database reads alone are too slow for live login checks and token refreshes. To stay fast, the cluster uses a distributed cache across all running nodes. When a user logs in on node one, that node writes session data. The cache copies that session state to node two right away. If node one stops working, the load balancer sends traffic to node two. The user stays logged in and does not see an error screen.
Nodes find each other on the network to form this shared cache ring. In cloud setups, nodes can look up peer addresses through DNS or cluster APIs. You also need a database that supports failover so storage never blocks logins. Health check endpoints on each node tell the load balancer which servers are ready. When a node fails its check, the balancer stops sending new requests there.
Managing permissions and roles across clustered nodes
Once your cluster runs well, your team will map groups to target roles. Identity admins create realms and define which users belong to which groups. Each group links to roles that grant entry to internal servers or data stores. Because every node shares one database, role changes spread across the cluster fast. When you add an engineer to a group, every node issues updated tokens.
To save time, teams often create broad roles for whole engineering groups. A single role might give full write rights to every production database. This makes setup easy, because admins manage just a few group rules. Still, every token from the cluster now carries those wide rights by default. The cluster makes sure those broad permissions are always available, day and night.
Keycloak: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
What high availability solves and what it leaves open
A clustered identity setup solves uptime and login scale for your company. It makes sure engineers and apps can always get tokens when they need them. It also gives you one place to turn off a user account fast. If someone leaves the team, disabling their profile blocks new logins right away.
Still, an identity cluster only decides who can log in at the start. It does not watch or control what happens after a session begins. Once a user gets a valid token or database role, the identity server steps back. It cannot see the actual SQL queries or shell commands the user runs next. It cannot stop an engineer from dropping a table or reading raw customer rows. It also cannot rewrite sensitive fields like emails, phone numbers, or card numbers in results. High uptime keeps the front door working, but you still need query-level controls inside.
Check database and API queries on the wire
Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.
Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.
Frequently asked questions
How many nodes do you need for a keycloak ha setup?
You need at least two active nodes behind a load balancer for basic redundancy. Many teams run three nodes across separate zones to survive a full zone outage.
Does a keycloak ha cluster require sticky sessions on the load balancer?
No, the shared cache lets any node handle any request from a user. Sticky sessions can still cut down cross-node network chatter during multi-step login flows.
Does clustering your identity server audit database queries?
No, the identity cluster only logs login events, token grants, and admin changes. It never sees the SQL statements or commands a user runs inside a target system.
Related guides
In this post