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

support reuse_port option when creating server #2679

Closed
hubo1016 opened this issue Jan 22, 2018 · 9 comments
Closed

support reuse_port option when creating server #2679

hubo1016 opened this issue Jan 22, 2018 · 9 comments

Comments

@hubo1016
Copy link
Contributor

Python supports reuse_port socket option when creating server

https://docs.python.org/3/library/asyncio-eventloop.html#asyncio.AbstractEventLoop.create_server

With reuse_port you can start multiple processes binding with the same port, easily creating a load-balanced server. While it is possible to start each process on different port, it can be done much easier with reuse_port option.

@asvetlov
Copy link
Member

Could be done by adding reuse_port parameter to TCPSite and family.
reuse_address should be supported as well.

@pfreixes
Copy link
Contributor

From my knowledge and tests reuse port is fundamentally broken for epoll

https://idea.popcount.org/2017-03-20-epoll-is-fundamentally-broken-22/

There is a flag that is available since kernel 4.5 that allows you to achieve the same behaviour. Also glibc has to be at least 2.24. Most of the distributions do not have it.

Also take into account that this is only appliable for new connections which have the worst code path in terms of performance. Most scenarios relay on long live conections to achieve maximum performance.

@hubo1016
Copy link
Contributor Author

@pfreixes Execuse me, I didn't find any relationship between reuse_port option to the link.
The underlying create_server() call in Python asyncio supports this option, it should not be any problem to allow user to set it...

@pfreixes
Copy link
Contributor

Because of that @hubo1016

With reuse_port you can start multiple processes binding with the same port, easily creating a load-balanced server. While it is possible to start each process on different port, it can be done much easier with reuse_port option.

@hubo1016
Copy link
Contributor Author

@pfreixes As far as I know, reuse_port does not create duplicated sockets, it creates independent sockets binding on the same port. dup() issues should not be related to this I think?
After all, if underlying Python implementation supports it, then we should support it and leave the choices to users.

@asvetlov
Copy link
Member

@hubo1016 please prepare a Pull Request

@hubo1016
Copy link
Contributor Author

@asvetlov
OK, I will try

@asvetlov
Copy link
Member

Fixed by #2693

@lock
Copy link

lock bot commented Oct 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a [new issue] for related bugs.
If you feel like there's important points made in this discussion, please include those exceprts into that [new issue].
[new issue]: https://github.com/aio-libs/aiohttp/issues/new

@lock lock bot added the outdated label Oct 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants