-
-
Notifications
You must be signed in to change notification settings - Fork 216
Improve websocket performance #690
Conversation
LaRiffle
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand all the details but it looks good!
What's the current bandwidth you achieve with this?
|
@LaRiffle Just giving a brief explanation. Masking/Unmasking is a process used to guarantee some level of security during the transportãtion of the messages across proxies (as described in WebSocket RFC). The problem: since the masking process needs to iterate over the message payload, the larger this message is, the longer it takes to process it. The library we use (gevent-websocket) developed this process in order to use only native language structures, as we can see here. Replacing these structures for NumPy structures should increase the performance. Test code used: Results: Testing the nodes using this node version (Before): Testing the nodes using this node version (After): Conclusion: The improvement in my tests almost reached 25x. (which is pretty impressive but also a bit weird). So I'd like you to do your own tests just to check if it matches in your dev environment as well. |
|
@IonesioJunior Noobie question here: I'm trying to run the |
|
@IonesioJunior it's working like a charm, i have now a way faster execution <3 |
Description
Flask-Sockets uses gevent-websockets as a socket interface. This library has some performance issues. One simple way to improve its performance it's just overwriting the WebSocket
mask_payload/unmask_payloadmethods by a new version usingNumPyinstead of standard python data-structures.Checklist