简体   繁体   中英

SpringBoot controler redirect across docker poods

We have a SpringBoot Web app docker container deployed in Kubernetes with 3 replicas. when the controller redirects to a different url within the same controller, we pass an object via the flashAttributes. When we run 1 pod, everything works. But when I scale to 3 pods, the object comes with all internal attributes set to Null. Has anyone come across the issue ? If so prescribe a solution ?

Thanks,

SR

Kubernetes can send multiple requests from a session to different pod within a deployment. That's why the data is lost because the data might in memory for one pod but another pod will not have that data at all.

To avoid this - you can either maintain the session cache in an external store like Redis or use sticky sessions so that for given session requests are sent to the same pod.

Some pointers to the solution

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM