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

100% cpu usage #323

Closed
groupboard opened this issue Jan 27, 2018 · 4 comments
Closed

100% cpu usage #323

groupboard opened this issue Jan 27, 2018 · 4 comments
Labels
bug Something isn't working fixed

Comments

@groupboard
Copy link

There seems to be an issue in the python 0.8.0 version which occasionally causes websockify to get stuck at 100% cpu usage. The problem disappears when reverting to 0.7.0. This has happened on both a Centos 6 server, and a Ubuntu server. Normally cpu usage is < 2% per websockify process.

Here is the stack trace (probably not useful):

#0 0x0000712e54be059d in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#1 0x0000712e54be5647 in PyEval_EvalCodeEx ()
from /usr/lib64/libpython2.6.so.1.0
#2 0x0000712e54be3a94 in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#3 0x0000712e54be5647 in PyEval_EvalCodeEx ()
from /usr/lib64/libpython2.6.so.1.0
#4 0x0000712e54be3a94 in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#5 0x0000712e54be4b7f in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#6 0x0000712e54be4b7f in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#7 0x0000712e54be4b7f in PyEval_EvalFrameEx ()
from /usr/lib64/libpython2.6.so.1.0
#8 0x0000712e54be5647 in PyEval_EvalCodeEx ()
from /usr/lib64/libpython2.6.so.1.0
#9 0x0000712e54b78ca0 in ?? () from /usr/lib64/libpython2.6.so.1.0
#10 0x0000712e54b51c63 in PyObject_Call () from /usr/lib64/libpython2.6.so.1.0
#11 0x0000712e54b646af in ?? () from /usr/lib64/libpython2.6.so.1.0
#12 0x0000712e54b51c63 in PyObject_Call () from /usr/lib64/libpython2.6.so.1.0

The process doesn't seem to be stuck...it exits normally when the user disconnects.

Here is the process listing for a few websockify processes:

root 29597 24.0 0.0 196368 9216 ? R 09:07 38:01 python /home/packages/websockify-master/websockify.py
root 29599 0.3 0.0 196500 9404 ? S 09:07 0:35 python /home/packages/websockify-master/websockify.py

Both processes here have been running 2.5hrs. One has used 38 minutes of cpu time during that interval, and the other just 35 seconds. This is not to do with usage...even with our highest packet throughput these processes typically only use 2% of cpu, even with 0.8.0. I think there is some factor that is occasionally causing 0.8.0 to sometimes use all the cpu time.

@groupboard
Copy link
Author

This was with latest master branch downloaded on Jan 22, 2018. Note that the problem only happens occasionally (perhaps once every 100 connections).

@groupboard
Copy link
Author

I think this might be fixed by the change CendioOssman made 3 days to fix handling of closed sockets. Will test it and report back.

@CendioOssman
Copy link
Member

Yeah, this was fixed in 3d20cab. It occurred whenever the server closes the socket and would continue until the client tried to send some data.

@CendioOssman CendioOssman added bug Something isn't working python labels Jan 29, 2018
@groupboard
Copy link
Author

Yes, confirmed...after applying this change the problem is now fixed. It wasn't detecting the closed socket, so select() was always returning immediately.

@samhed samhed added the fixed label Jan 30, 2018
@samhed samhed modified the milestone: 0.8.0 Jan 30, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed
Projects
None yet
Development

No branches or pull requests

3 participants