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

Slow web socket performance #135

Closed
mvollrath opened this issue Oct 19, 2014 · 4 comments · Fixed by #167
Closed

Slow web socket performance #135

mvollrath opened this issue Oct 19, 2014 · 4 comments · Fixed by #167

Comments

@mvollrath
Copy link
Contributor

The rosbridge web socket server is very CPU hungry when a lot of messages are being routed to browser clients.

Our use case is subscription to multiple sensors from multiple browser clients for distributed, interactive visuals. ROS is a great platform for this kind of thing, but when we ran rosbridge on a modest server (some kind of Atom processor with plenty of RAM), it couldn't keep up. The server would eat a lot of CPU as message traffic ramped up, and sometimes choked up resulting in apparent system breakdown. We ended up offloading the rosbridge server to a more powerful server, but we'd like for rosbridge to be efficient enough to handle hundreds of messages per second without burning up CPU cycles on a user-facing machine.

I looked around and found this discussion pointing at Tornado's web socket masking function as the culprit, with native speedups making an order of magnitude difference:

https://groups.google.com/forum/#!topic/python-tornado/n6VpUr8zk2c

Then this Tornado pull request to add native speedups:

tornadoweb/tornado#579

Looks like it was released in Tornado 3.2. Ubuntu's python-tornado package is still at 3.1.1 in trusty, but pip will install 4.0.2 as of today. Presently rosbridge includes Tornado 2.3.

This is related to #121 which should resolve this issue if Tornado comes from pip or is updated to 3.2+ in the rosbridge tree.

Thanks
mv

@megawac
Copy link

megawac commented Oct 19, 2014

Correct me if I'm wrong but this is fixed on master+develop as of #126 and has been published to the debs

@mvollrath
Copy link
Contributor Author

Thanks, #126 does resolve this.

@mvollrath
Copy link
Contributor Author

Using 4.0.2 Tornado sources doesn't resolve this. The tornado.speedups module has to be compiled native to get full speed websockets. See Tornado's setup.py:

https://github.com/tornadoweb/tornado/blob/v4.0.2/setup.py

We may be able to chain load Tornado's setup.py or just copy the custom_build_ext bits into rosbridge_server's setup.py.

Here is test code I've verified with pip-installed Tornado:

#!/usr/bin/env python
try:
    import tornado.speedups
except ImportError:
    print 'no speedups!'
else:
    print 'blazing fast websockets!'

@mvollrath mvollrath reopened this Nov 11, 2014
mvollrath added a commit to EndPointCorp/rosbridge_suite that referenced this issue Jan 10, 2015
mvollrath added a commit to EndPointCorp/rosbridge_suite that referenced this issue Jan 10, 2015
mvollrath added a commit to EndPointCorp/rosbridge_suite that referenced this issue Jan 10, 2015
@gladkikhartem
Copy link

  1. You'll need to build tornado speedups.
  2. If you'll send multiple small websocket messages - it will eat up your CPU!
    I've met this during data upload to tornado:

Uploading file by 1024 bytes chunks will eat your 100% CPU at 5-10 Mbit/s

Uploading file by 1024*20 bytes chunks will eat 10% CPU at 100Mbit/s

Magic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants