Base solution for your next web application
Open Closed

Switching tenant fails in mutiple docker container instances setup #9502


User avatar
0
shipserv created

Hi ASPNetZero support,

We are currently migrating Zero to a docker setup using Kubernetes so that we could be able to run multiple instances of the app. Single instance seems to be not good enough for the amount of load that we put in as it can't be horizontally scaled.

We tested most of the functionality and seems working fine on our DEV environment with this docker setup. But we encountered an issue with switching user to a different tenant. Zero is throwing an error "Impersonation token is invalid or expired!". We've investigated and assumed that the issue is caused by caching mechanism in Zero which is relative and contained within the app context instance. So, if we are running multiple instances in docker, each app instance will have their own unique cache (not shared) by default. So, the token might be available in one instance but not on the other instances.

The solution that we are planning to implement is to configure a single centralized caching system (e.g. Redis) so that all instances would be able to fetch the token whichever instance has stored it. But we would like to consult to you if this is correct and best way to go. Can you please guide us on this?

--The code snippet that is triggered to throw exception

Regards, Allan Backend Team Lead in ShipServ


2 Answer(s)