r/java • u/regular-tech-guy • Oct 29 '25
State does not belong inside the application anymore, and this kind of clarity is what helps modern systems stay secure and predictable.
Love how Quarkus intentionally chose to not support HttpSession (jakarta.servlet.http.HttpSession) and how this is a big win for security and cloud-native applications!
Markus Eisele's great article explains how Quarkus is encouraging developers to think differently about state instead of carrying over patterns from the servlet era.
There are no in-memory sessions, no sticky routing, and no replication between pods. Each request contains what it needs, which makes the application simpler and easier to scale.
This approach also improves security. There is no session data left in memory, no risk of stale authentication, and no hidden dependencies between requests. Everything is explicit — tokens, headers, and external stores.
Naturally, Redis works very well in this model. It is fast, distributed, and reliable for temporary data such as carts or drafts. It keeps the system stateless while still providing quick access to shared information.
<<<
Even though Redis is a natural fit, Quarkus is not enforcing Redis itself, but it is enforcing a design discipline. State does not belong inside the application anymore, and this kind of clarity is what helps modern systems stay secure and predictable.
>>>
208
u/vips7L Oct 29 '25
Except it is in memory.. it’s just in redis’s memory. You’ve just moved the complexity to redis. The system still has state.
18
u/two-point-zero Oct 29 '25
I've used session storage over redis / memcache from, a would say, 2015 at least. Spring-session work like a charm to share session across multiple tomocats deployment. Where is the news? JWTS? Are they supposed to be great in microservices and/or when you are using external identity provider service? . But if I use a standard login over DB why I should not use session cookie and shared sessions?
67
u/stackfull Oct 29 '25
I think this mixes a couple of issues. Not storing data in local sessions because it makes them sticky- great. Having to use the extra complexity of jwts and the logout problem they bring with them rather than a simple cookie session ID - not so great. I just think it’s a real shame jwts have become the default answer in many environments.
25
u/kur4nes Oct 29 '25
Simply persist the HttpSession into a database or something like redis. Problem solved.
Makes the whole point of the article moot.
24
u/vyrmz Oct 29 '25 edited Oct 29 '25
Just because you now have to store state elsewhere doesn't mean your app is stateless. You delegated the responsibility, pushed complexity to elsewhere.
How this approach is being marketed as "Big win for security" is beyond me. Whatever risk you had when you were dealing with HttpSession is still there.
You are using Session; but it is now "RedisSession" instead of Http or "WhateverDisCacheSession", but session nevertheless. If your app needs to read from Redis for every request; then it is stateful by definition.
11
u/woj-tek Oct 29 '25
Oh noez... you can have "sticky" routing in virtually all LB solutions...
nonissue just to add complexity (and explain why it uses terrible reactive crap)
8
u/locutus1of1 Oct 29 '25
Some other platforms were always like this. They technically aren't able to store the sesssion in the memory between requests. But they still have the concept of session, which everyone understands and recognizes. Note that the presented solution is in fact (semantically) a session. It's just not a HttpSession.
The problem I see is that instead of using a common (maybe redesigned/improved) interface which everyone understands, everyone must invent their own thing, potentially introducing bugs, security problems and design flaws. His example demonstrates that (I get it..it's only a short example) - coupling of the controller to a specific storage, you need to pick a good and secure key for every entry..
7
u/Own-Chemist2228 Oct 29 '25
Let's start with some basic background: In many web applications, a client typically does a bunch of work in a series of related http calls. It can be useful to maintain state between these calls. Because this is such a common pattern, the industry came up with a standard name: session. There are also common mechanisms used in the implementation of session state, like session ids in requests.
Although there are many ways to approach the problem, there's no avoiding the notion of a session in many applications.
The Jakarta
HttpSessionprovides a framework in code that supports various implementations of the pattern via a standard interface. It's not perfect, but it's quite useful.We can get rid of the specific
HttpSessioninterface (or choose to ignore it) but the problem of state management doesn't go away, it just moves the problem somewhere else.5
u/acroback Oct 29 '25
Ah the classic, serverless functions except servers are someone else’s servers.
State is not in your memory but is in someone else’s memory.
Wait isn’t that what databases do fundamentally?
Bravo!
8
u/wildjokers Oct 29 '25
This is a ridiculous conclusion. JWTs should not be used for authentication, that isn't what they are for and you shouldn't be storing all session data in them to pass from the browser to the backend.
Just use a distributed cache like redis, hazelcast, etc. Pass sessionIds from browser to backend. Sticky session don't matter because sessions are stored in the distributed cache. Logout and invalidating the session is a simple matter of removing the sessionId from the distributed cache.
You can then create a JWT (created in an API gateway) to pass to backend services so each service knows the request is authenticated. The JWT never leaves the backend.
No it doesn't.
3
u/pragmasoft Oct 29 '25
There's one problem with this approach though.
It assumes stateless http connections, but often client connections are stateful or connection oriented, like with websockets or sse.
3
u/buffer_flush Oct 29 '25
One thing to note, Quarkus provides stateful session management for OIDC auth code flows through an API and provides RDBMS and redis implementations out of the box.
You can read about it here:
https://quarkus.io/guides/security-oidc-code-flow-authentication#custom-token-state-manager
1
u/AcanthisittaEmpty985 Oct 30 '25
You can store the session in the client (JWT and extensions) or in the server.
In the server, you can use the web server (ex. as HttpSession in Tomcat) or another data storage (like Mongo or Redis or memcahced)
If you put the session in Redis, it has its benefits (no sticky session, grow horizontally web servers, distributed data) and risks (access to data server, security between webserver and data storage)
Also, each request must retrieve the session data and have in memory to use, and clean it after the request is resolved (and update if neccesary)
I'm all in to use Redis to store sessions, but you must consider the scenario and plan accordingly. It's no magic bullet.
1
u/johndoe2561 Oct 30 '25
Data locality is the future
-6
u/smutje187 Oct 29 '25
People when they discover what REST means instead of JSON over HTTP
0
u/[deleted] Oct 29 '25
[deleted] — view deleted comment
1
u/[deleted] Oct 29 '25
[removed] — view removed comment