---
title: "Discussion on \"Sticky Sessions on Kubernetes with WildFly and NGINX\" | Hashnode"
description: "Discussion on \"Sticky Sessions on Kubernetes with WildFly and NGINX\". Sticky Sessions on Kubernetes with WildFly and NGINX"
url: "https://hashnode.com/posts/sticky-sessions-on-kubernetes-with-wildfly-and-nginx/650804afcf05a2a5f0e4d83b"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Sticky Sessions on Kubernetes with WildFly and NGINX](https://tommasoborgato.hashnode.dev/sticky-sessions-on-kubernetes-with-wildfly-and-nginx?utm_source=hashnode&utm_medium=feed)

Sticky Sessions on Kubernetes with WildFly and NGINX

Sep 18, 2023 · 1 min read · tommasoborgato.hashnode.dev  
Read the article

-   [#kubernetes](https://hashnode.com/tag/kubernetes)
-   [#wildfly](https://hashnode.com/tag/wildfly)
-   [#nginx-ingress](https://hashnode.com/tag/nginx-ingress)
-   [#nginx](https://hashnode.com/tag/nginx)

## Written by

[tommaso borgato](https://hashnode.com/@tommasoborgato)

@tommasoborgato · italy

  
[View profile](https://hashnode.com/@tommasoborgato)

JBoss EAP QE at Red Hat

## Responses 1

Markdown supported · ⌘↵ to post

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Oct 31](https://hashnode.com/posts/sticky-sessions-on-kubernetes-with-wildfly-and-nginx/650804afcf05a2a5f0e4d83b/comment/6ae571184d27f3109d8de86c)

Sticky affinity on the ingress is fine for session-in-memory apps, but the failure mode that bites us is pod churn: a rolling update or node drain invalidates the affinity cookie and dumps users onto cold JVMs. With nginx ingress I keep affinity cookie-based (not pure ip\_hash) so NAT fleets do not pin an entire office to one replica, set a short cookie max-age aligned with the WildFly session timeout, and make sure the upstream still accepts a new session without a hard error when the sticky target disappears.

For safer ops I treat stickiness as a temporary bridge, not architecture: enable session replication or an external store for anything that cannot rebuild state, and watch 502/504 spikes plus upstream response time during deploys — those usually mean affinity pointed at a terminating pod. Also verify that health checks remove the pod from the endpoints list before SIGTERM finishes; otherwise sticky clients keep hammering a half-dead WildFly until the cookie expires. If you can move auth tokens or carts out of heap, drop affinity later and go back to plain round-robin.
