Title: connection limit on listening socket in asyncio
Type: enhancement Stage:
Components: asyncio Versions: Python 3.8
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: asvetlov, lguo, yselivanov
Priority: normal Keywords:

Created on 2018-06-11 21:10 by lguo, last changed 2018-06-13 04:53 by lguo.

Messages (3)
msg319347 - (view) Author: Lisa Guo (lguo) Date: 2018-06-11 21:10
I'd like to re-open the discussion on pause_server/resume_server that's been discussed here:!topic/python-tulip/btGHbh5kUUM

with PR:

We would like to set a max_connection parameters to a listening socket. Whenever it reaches this number with open accepted sockets, it stops accepting new connections until a user request is served, response sent back, and the connection closed. This is useful for a web application where the more user requests accepted and processed in-flight isn't necessarily better for performance. It would be great if we could dynamically change this value as well.

Some more detailed behavior:

- it can be either a per loop parameter, or per server parameter
- the number of currently open accepted connections is counted against this limit
- if max connection is reached, remove the listening socket from the loop so it back pressures new connections to kernel and other processes can take them
- when total number of accepted connections drops below max connection, put the listening socket back in the loop
- it can be dynamically configured but has no effect on currently already accepted connections (useful for graceful shutdown)

msg319349 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-06-11 22:56
Do other frameworks (Tornado, Twisted, libuv/nodejs) have this functionality?
msg319425 - (view) Author: Lisa Guo (lguo) Date: 2018-06-13 04:53
Hi Yury, no, I'm not familiar with the other frameworks (libuv doesn't have this). I'll need to look into it. If anybody else knows, please comment as well.
Date User Action Args
2018-06-13 04:53:20lguosetmessages: + msg319425
2018-06-11 22:56:53yselivanovsetmessages: + msg319349
2018-06-11 21:10:29lguocreate