Redisson tomcat session manager performance advice/questions/issues #6054
Replies: 3 comments 8 replies
-
Thanks for you feedback.
Don't forget that the internal state of Tomcat session also should be in correct state not only state stored in Redis. This is why these methods should be called in such way.
What do you suggest? response has boolean type and it's synchronous.
There is always room for improvement. |
Beta Was this translation helpful? Give feedback.
-
Totally agree, but I think they're called too many times. Here's a sample of a page load; there are two calls for
What's intriguing is that there is a call to This kind of makes the previous explicit calls to |
Beta Was this translation helpful? Give feedback.
-
Just trying to see what happens, I tried something myself. Tried two things :
For the sake of keeping this comment short, I'll post only one of the methods, since they all follow the same pattern :
Obviously, the default implementation will call the original method to avoid making too many changes; for these new methods the return type is always The implementation in the RedissonMap goes like this :
Basically, I created asynchronous versions without caring for the timing or the return value for two reasons : it's never used and it serializes the operations in time. Then, whenever the original method was used :
In addition to that, I wrapped the
Simply put, if I set The result : every call to But it created a problem : being asynchronous, when the session changes id following a login request, there is a session object left in redis with no expiration set; tricky to understand why, but I won't go in such detail here. Which was solved by triggering a delayed expiration on the previous session id after a session id change. Currently I plan to test this against an azure configuration to see if I can get rid of the sticky sessions I have previously used. |
Beta Was this translation helpful? Give feedback.
-
TL;DR: SessionManager is very slow. What am I doing wrong?
While implementing a multi instance webapp, we came across the redisson session manager and tried it out.
The webapp and redis cache are both hosted on azure, using (for development and testing purposes) the lowest plan possible (I think this will become important later, as the redis cache is marketed as 'low bandwidth')
The immediate and very noticeable issue was a serious performance drop in response time. Request times increased from milliseconds to couple seconds and maybe more.
So naturally, we thought there's a config problem. Could not find anything that improved the situation.
Next was to look at the redisson-tomcat code to try and figure out what we were doing wrong. And we came across some pieces of code that raised some questions. I'll just include a couple here so that the post gets not too long, but I'll be happy to discuss each one in detail if needed.
redisson-tomcat/redisson-tomcat-9/src/main/java/org/redisson/tomcat/RedissonSessionManager.java:173
Why call
access()
andendAccess()
in sequence ? According toRedissonSession.java:214
,access()
will setTHIS_ACCESSED_TIME_ATTR
then the expiration, andendAccess()
will do almost the same thing all over again then broadcast the update... Not to mention that astore()
is also called later which includes more or less the same updates.Not to mention that
access()
is also called internally by tomcat, so the call infindSession()
seems redundant.According to our profiling and our infrastructure, both take some 150 to 250ms to complete which amount to at least 350-500 ms for the
findSession()
call... for EVERY call. First page load (I'm saying 'first' because later on there may be some caching involved for some ressources) will call thefindSession()
several times which will add up to a hell of a response time.Which brings us to the next one ...
redisson/src/main/java/org/redisson/RedissonMap.java:1315
The call to
get()
will wait for the Future to finish and kind of serialize in time all calls. This begs the question : can this be done differently ? especially if the return value is not needed (like inRedissonSession.java:214
).We have timed a redis operation to about 50ms (this is where the azure low bandwidth plan comes into play), so the response time from calls from the previous
access()
andendAccess()
gets explained. Probably, with a faster redis response time these issues go unnoticed ...Overall, the impression is that there is a lot of overhead that is not necessary or could be improved. It seems that there is a lot of network traffic between tomcat and the redis cache that can be avoided.
Or maybe we are trying to use the session manager the wrong way or with the wrong configuration.
Any advice/comment/criticism/help/solution is welcome. Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions