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

Websocket performance optimization #1140

Closed
lassepe opened this issue Jan 17, 2024 · 2 comments · Fixed by #1177
Closed

Websocket performance optimization #1140

lassepe opened this issue Jan 17, 2024 · 2 comments · Fixed by #1177

Comments

@lassepe
Copy link
Contributor

lassepe commented Jan 17, 2024

By default, HTTP.WebSockets uses a TCP socket configuration that is rather slow:

  • In the default setting, HTTP.WebSockets takes about 0.04s to respond to a request from a python websockets client.
  • An equivalent python server takes only 0.0002s to respond.

However, if one disables Nagel's algorithm on the tcp socket, the Julia implementation is on par.
In fact, with the tuned socket below I get Julia to 1e-5s response time.

function server()
    server = WebSockets.listen!("127.0.0.1", 8081) do ws
       # without these options below, the socket is way too slow.
        Sockets.nagle(ws.io.io, false)
        Sockets.quickack(ws.io.io, true)

        for msg in ws
            WebSockets.send(ws, msg)
        end
    end
end

Proposal: It would be nice to make this tuning the default and expose some relevent settings via the keywords of HTTP.WebSockets.listen! and HTTP.WebSockets.open.

@lassepe
Copy link
Contributor Author

lassepe commented May 10, 2024

@quinnj
Copy link
Member

quinnj commented May 10, 2024

SGTM! Mind making a PR?

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.

2 participants