-
-
Notifications
You must be signed in to change notification settings - Fork 500
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
recv() is slow #1462
Comments
Your timing includes the json.loads() call so your latency measurements include the overhead of those calls. Are you sure you want to measure both or do you just want to measure the await websocket.recv()?
You can try switching to orjson instead of json if you need more speed. |
I have implemented what you have suggested and It's still pretty bad unfortunately.
Surprisingly these websockets receive latency stats are worse than Rest messages I send to the same destination geographically speaking, different server of course. |
What do you mean by receive latency? You have to make sure to measure the correct thing if you want your results to be helpful. Maybe look into timing asyncio operations. Without knowing anything else about your test it's hard to point to where the issue might be. For latency this got added and you can refer this: https://github.com/python-websockets/websockets/issues/1195. Also look at recv function https://github.com/python-websockets/websockets/blob/12.0/src/websockets/legacy/protocol.py#L502-L578 |
recv() latency. |
Yes. However, your stopwatch ( |
Awaiting
websocket.recv()
appears to be quite slow. I am scheduling the belowconsumer()
into a task group, nevertheless if we look at the latency statistics:we see a distribution of waiting times as follows:
What would account for the latency here? Presumably if there is no message to receive, control should be returned to the event loop. If there is a message to process, surely the message has been sent already from the websockets server to my client and the waiting times should be better?
The text was updated successfully, but these errors were encountered: