Repository navigation
|
Upon introduction of Keycloak 23, a new documentation has been introduced to discuss multi-site deployments: https://www.keycloak.org/high-availability/introduction The page says "Keycloak supports deployments that consist of multiple Keycloak instances that connect to each other using its embedded Infinispan; load balancers can distribute the load evenly across those instances. Those setups are intended for a transparent network on a single site." but discusses mainly about active-passive deployment model. Does Keycloak support active-active deployments (ie. multiple nodes that serve requests simultaneously)? |
Replies: 3 comments 5 replies
|
I can confirm that active-active deployments can indeed be achieved... as long as the Infinispan instances do not desynchronize. Basically, for a cross-datacentre configuration you need to configure Keycloak to use external Infinispan servers, and the external Infinispan servers must back up cache data to the other site. Cross-datacentre configurations are not entirely new to Keycloak. They have been around since before Keycloak 15 (in an experimental state), when it was still using the old WildFly framework, but after moving to Quarkus the documentation for it was not added back, likely because it was still not fully supported. To make it work, you must make sure to forward all requests for a client (during the authentication flow) to the same backend. This can be done by either using sticky sessions through the Infinispan route cookies, or other means like IP hashing. Sticky session are used to make sure that the intermediate caches used during the authentication flow are always visible to the Keycloak server that receives the request. In theory at least, any server should still be able to fetch the cookies even if a request is not received by the same backend, since Infinispan can fetch the data from any owner in the network. Since an active-active deployment may send requests to either datacentre for a single client, to make sure that caches for all backends are the same, synchronous backups are recommended. The issue with this is that Infinispan does not support automatic recovery from failed backups for synchronous backups (auto recovery for asynchronous backups was recently added, but they may be less reliable in some cases), so from time to time you may find that the sites are considered offline if the network connection encounters errors for whatever reason. To make matters worse, this can happen for a subset of the caches (e.g., the |
|
Hi @Arnaud-FELTZ, @darius-m, @Laurenzi , if I configure my caches to only be local caches, I guess I get rid of the infinispan requirement to be replicated in a multi-site setup, isn't it? Also do you know if there will be any id conflicts in the active- active setup? Is it needed to change the sequences in the database for that to work well? Thank you. Cheers! |
|
The docs at https://www.keycloak.org/high-availability/introduction have been updated with two scenarios:
Both setups support active-active. With that, I'm calling this one resolved. |
The docs at https://www.keycloak.org/high-availability/introduction have been updated with two scenarios:
Both setups support active-active. With that, I'm calling this one resolved.