-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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 load #896
Comments
Anyone is more than welcome to investigate this issue. Best regards, |
Thank for answer. I understand. Issue is hard to reproduce and even can be kind of bug of selector. Unless i founded minor fix: i put Thread.sleep(1) before selector.select() to prevent millions cycles per second. And i want to say that load goes even less than usual and latency for few additional milliseconds does not matter for me. |
I would just like to say that I have run into a completely similar problem. I cannot tell what is causing it in my case at all. I also get 100% on the WebSocketServer. |
So we too are seeing a rare but extended 100% cpu load. I have not used NIO selectors but all of the examples I see remove the key from the selected keys set after iterating over each of them. Example: http://tutorials.jenkov.com/java-nio/selectors.html Perhaps this is the root of the problem? |
So trying to investigate this area more and in the WebSocketServer why not just always remove the key after calling i.next()? while ( i.hasNext() ) { Eliminate passing the iterator into doAccept() and doRead() which are calling "i.remove()" and notice the there is no "i.remove()" in the key.isWritable() case. Might that be the problem that is is stuck isWritable()? If we learn more, I will add info here. |
This error happens every night. While researching, I saw that it is from websocket. When I stop the websocket, the cpu returns to normal. i found the problem today i will download the source code and examine it |
The problem is gone for me on java 16. |
my problem started with ssl. If no data is received without establishing a connection at the SSL destination |
Dear Marcel I'm facing same cpu overload on Selector.select in WebSocketServer class run. Maybe it happens after network failure. Can you check this blog? Best regards, JungGi |
@sahnjeok feel free to open a PR |
What do you mean 'PR' ? ^^;; |
Pull request |
Dear Marcel I found that sometimes selected keys iterator does not remove key. I think it should always be removed after .next() function. Best regards, JungGi |
'handshakeStartTime' long variable is added and isHandShakeComplete() function is updated for TooTallNate#896. If wss handshake is not completed in 10s, close this channel to prevent cpu overload or unexpected channel error. See TooTallNate#896.
'handshakeStartTime' long variable is added and isHandShakeComplete() function is updated for TooTallNate#896. If wss handshake is not completed in 10s, close this channel to prevent cpu overload or unexpected channel error. See TooTallNate#896.
This issue made SSL unusuable in production due to freezing the server randomly multiple times per day and not being able to recover by itself. I tried a bunch of the fixes suggested, but in the end, the solution that worked was just to use Stunnel. |
From time to time the load on cpu sharply rises to 100% core and sometimes it going to 3% without the reason. Jprofiler shows load on selector.select
If i stop in debud on the line (thread stop) in screenshot - load goes to 3%.
To Reproduce
Steps to reproduce the behavior:
Really i dont know how to reproduse. Sometime it raise to 100% at 50 connections but another time it idle on 300.
Even not redusing on close all connections in debug... (last screenshot)
Example application to reproduce the issue
I cant to share my project :(
Debug log
Does it really needed? There is so many logs)
Environment(please complete the following information):
openjdk version "1.8.0_151"
OpenJDK Runtime Environment (build 1.8.0_151-b12)
OpenJDK 64-Bit Server VM (build 25.151-b12, mixed mode)
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: