You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue was brought up by a user in one of our Discord channels. When many new sessions are created, the reaper algorithm in LocalSessionStore keeps iterating over the whole collection of sessions in order to find those who are expired.
In such a scenario, it takes the whole session lifetime (30 minutes by default) to clear up the situation. During that time, the CPU is kept busy by the reaper iterating over the list of sessions.
Steps to reproduce
Start a Vert.x instance with a Vert.x Web router and a LocalSessionStore
Send 200,000 requests
Observed behaviour: The CPU is 100% busy until the lifetime of the sessions expires
Desired behaviour: The CPU is not busy
Contribution
A simple solution could be to maintain an index of sessions, sorted by their lastAccessed time in ascending order. The reaper could then use something like a dropWhile algorithm and only drop the first n sessions which have a lastAccessed value that is older than timeout.
This can be achieved by maintaining a second collection, like in this gist.
My favorite approach would be to have the sessions in a sortedLocalMap. Unfortunately, there is no SortedLocalMap, yet.
Anyway, I can contribute the solution. But let's discuss this first.
The text was updated successfully, but these errors were encountered:
Version
Context
This issue was brought up by a user in one of our Discord channels. When many new sessions are created, the reaper algorithm in
LocalSessionStore
keeps iterating over the whole collection of sessions in order to find those who are expired.In such a scenario, it takes the whole session lifetime (30 minutes by default) to clear up the situation. During that time, the CPU is kept busy by the reaper iterating over the list of sessions.
Steps to reproduce
Observed behaviour: The CPU is 100% busy until the lifetime of the sessions expires
Desired behaviour: The CPU is not busy
Contribution
A simple solution could be to maintain an index of sessions, sorted by their
lastAccessed
time in ascending order. The reaper could then use something like adropWhile
algorithm and only drop the firstn
sessions which have alastAccessed
value that is older thantimeout
.This can be achieved by maintaining a second collection, like in this gist.
My favorite approach would be to have the sessions in a sorted
LocalMap
. Unfortunately, there is noSortedLocalMap
, yet.Anyway, I can contribute the solution. But let's discuss this first.
The text was updated successfully, but these errors were encountered: