Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve SessionTracker scalability #5108

Closed
sbordet opened this issue Aug 2, 2020 · 4 comments · Fixed by #5109
Closed

Improve SessionTracker scalability #5108

sbordet opened this issue Aug 2, 2020 · 4 comments · Fixed by #5109
Assignees
Labels
Enhancement Sponsored This issue affects a user with a commercial support agreement

Comments

@sbordet
Copy link
Contributor

sbordet commented Aug 2, 2020

Jetty version
9.4.26 and later

Description
SessionTracker holds a list of session in a COWAList.

Unfortunately it's a singleton-like object, so if an application opens and closes WebSocket connections at a high rate, it becomes a bottleneck because of lock contention.

@sbordet sbordet added the Sponsored This issue affects a user with a commercial support agreement label Aug 2, 2020
@joakime
Copy link
Contributor

joakime commented Aug 2, 2020

IIRC, The SessionTracker has a few purposes.

  1. To avoid the addBean() removeBean() contention of the previous impl (and dump() issues)
  2. Holds the collection of open Sessions to allow for proper graceful shutdown.
  3. To satisfy the needs of javax.websocket.Session.getOpenSessions()

While 1 and 2 can be solved in ways that don't need to use the Collections objects, the need in point 3 means the the ability to at least return a Set<Session> when asked.

@sbordet
Copy link
Contributor Author

sbordet commented Aug 2, 2020

@joakime do we only need it for the JSR implementation, or also the Jetty APIs have a similar method?

We can use a more efficient data structure as getOpenSessions() is not called that often, so that we do not pay the price every time a connection is opened/closed.

@lachlan-roberts
Copy link
Contributor

@sbordet the Jetty WebSocket API does have similar methods as well.

lachlan-roberts added a commit that referenced this issue Aug 3, 2020
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Aug 3, 2020
…zed blocks

Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@joakime joakime added this to To do in Jetty 9.4.32 via automation Aug 3, 2020
@joakime joakime moved this from To do to In progress in Jetty 9.4.32 Aug 3, 2020
lachlan-roberts added a commit that referenced this issue Aug 4, 2020
…Scalability

Issue #5108 - improve scalability of WebSocket SessionTrackers
@lachlan-roberts
Copy link
Contributor

PR #5109 fixes the scalability issue by using a set derived from ConcurrentHashMap instead of the CopyOnWriteArraySet.
This has been merged into the 9.4.x branch and will be available in a 9.4.32 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Sponsored This issue affects a user with a commercial support agreement
Projects
No open projects
Jetty 9.4.32
  
Done
Development

Successfully merging a pull request may close this issue.

3 participants