-
I have realtime application and there is occasionally huge slowdowns. I catched a CPU profile while it was lagging couple of times. It looked like the ws.send function is taking around 50%. At first I thought it was something up with my application logic but after switching to cWS library for some days the problem disappeared. Any idea what could be causing this or is possible that the new versions of uws has this fixed? I am using Uws 17.0.0 on Debian 9. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments
-
"cWS" is a dead-end copy of uWS 0.14, so the question is rather what differs in sending between older uWS 0.14 and newer uWS 0.17. How are you managing backpressure? |
Beta Was this translation helpful? Give feedback.
-
I use SSLApp without passing much options except the SSL certs. |
Beta Was this translation helpful? Give feedback.
-
0.14 holds backpressure in a linked list, 0.17 holds backpressure in a vector. If you just blindly shove data down the socket without taking backpressure into account 0.17 will have more severe issues but that doesn't mean 0.14 is better. 0.17 is a lot more efficient if you follow the docs and manage backpressure properly. |
Beta Was this translation helpful? Give feedback.
-
It would be nice to have an example for that, there is no "tutorial" or real explanation in the docs |
Beta Was this translation helpful? Give feedback.
-
The docs are pretty clear on this https://unetworking.github.io/uWebSockets.js/generated/interfaces/websocket.html#send |
Beta Was this translation helpful? Give feedback.
-
I could call ws.getBufferedAmount and if it returns that there is bytes in backpressure, then I wont call ws.send but is that the only way to handle it? Is that backpressure related to specific ws connection or all connections? Also I am curious, what happens in the older version or why the issues are more severe in new one? Any idea how other libraries like websockets/ws handles backpressure? |
Beta Was this translation helpful? Give feedback.
-
You have the same exact thing client side: https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/bufferedAmount |
Beta Was this translation helpful? Give feedback.
-
Does the cWS or older Uws skip sending some packets if there is backpressure by default? I am mostly interested because I am currently still using the cWS but if I knew that it drops the traffic then I could do that manually in new Uws by checking that buffered amount and not sending anything if there is some to fix the problem I had. |
Beta Was this translation helpful? Give feedback.
-
You have severe bugs in your application logic no matter if you use "cWS", ws or uWS. It's just a matter of different manifestation. Fix your mistakes and stop writing here. This is not related in any way to uWS. |
Beta Was this translation helpful? Give feedback.
You have severe bugs in your application logic no matter if you use "cWS", ws or uWS. It's just a matter of different manifestation. Fix your mistakes and stop writing here. This is not related in any way to uWS.