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

High CPU usage - may be deadlock #225

Closed
flashmandv opened this issue Jan 5, 2014 · 6 comments
Closed

High CPU usage - may be deadlock #225

flashmandv opened this issue Jan 5, 2014 · 6 comments

Comments

@flashmandv
Copy link

When my server gets more clients and respectivelly more data transfer, the CPU is getting high. I made stack dump using "jstack" and here is the log for the problematic thread (I'm using the latest code):

"WebsocketSelector17" prio=10 tid=0x00007f532c0fa000 nid=0x523a runnable [0x00007f5322ad0000]
java.lang.Thread.State: RUNNABLE
at sun.nio.ch.EPollArrayWrapper.epollCtl(Native Method)
at sun.nio.ch.EPollArrayWrapper.updateRegistrations(EPollArrayWrapper.java:246)
- locked <0x000000078b5c06d8> (a java.util.LinkedList)
at sun.nio.ch.EPollArrayWrapper.poll(EPollArrayWrapper.java:209)
at sun.nio.ch.EPollSelectorImpl.doSelect(EPollSelectorImpl.java:65)
at sun.nio.ch.SelectorImpl.lockAndDoSelect(SelectorImpl.java:69)
- locked <0x000000078b5c0600> (a sun.nio.ch.Util$2)
- locked <0x000000078b5c05f0> (a java.util.Collections$UnmodifiableSet)
- locked <0x000000078b5bbea8> (a sun.nio.ch.EPollSelectorImpl)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:80)
at sun.nio.ch.SelectorImpl.select(SelectorImpl.java:84)
at org.java_websocket.server.WebSocketServer.run(WebSocketServer.java:298)
at java.lang.Thread.run(Thread.java:662)

@sklegg
Copy link

sklegg commented Jan 23, 2014

I am seeing a similar issue when many clients are connected. (WebSocketServer.java line 298 waiting for selector.select() to return.)

Doing some research, this method usually churns when multiple threads make register calls or register OP_WRITE when not necessary. I could not find any place in the code where this could be happening.

@Joris-van-der-Wel
Copy link

Is it really hanging on select()? (which is okay if there is nothing interesting happening)
Or is it going through the loop in WebSocketServer.java:302 very very often?

If the latter case is true, I am guessing this could be because i.remove() is not called often enough, and the same keys keep getting returned by selector.selectedKeys().

@becast
Copy link
Contributor

becast commented Apr 23, 2017

I just experienced the same problem but only while using SSL. It is an issue when an SSL session can not fully established or the negotiations break down. Which leaves the Channel in a constant read state. I created a PR.

@marci4
Copy link
Collaborator

marci4 commented Apr 26, 2017

Hello everyone,
is this still an issue?

Greetings
marci4

@marci4
Copy link
Collaborator

marci4 commented May 28, 2017

Could also be fixed by #488

@marci4
Copy link
Collaborator

marci4 commented Nov 5, 2017

No feedback for months!

If you still have an issue with that, please open a separate issue again!
Greetings
marci4

@marci4 marci4 closed this as completed Nov 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants