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

feat(Sockets.jl): accept as many connections as possible in one loop #1

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pankgeorg
Copy link
Owner

@pankgeorg pankgeorg commented Aug 23, 2023

This PR introduces (another) buffer, on top of LibUv's 511 connection limit. This buffer aggressively accepts new connections if they are there (with accept_nonblock) and even rejects some of them (this shouldn't exactly happen like that, as TCP doesn't mean HTTP, but this is a demo). The performance difference is negligible (I measure +1% for this PR with a yielding handler, but I expect this to be much more in computation intensive code, and, more importantly, I expect this to handle spikes of traffic better)

WARNING: NOT TESTED, NOT THREADSAFE (...insert any disclaimer here...)

Inspired by libuv/libuv#3071 where it says

since uv_accept doesn't actually accept anything, but merely moves the already accepted connection to a new handle. Perhaps both the silent acceptance of connections and the automatic disabling of listening should be mentioned in the uv_listen, uv_accept and uv_connection_cb documentation entries.

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