This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients giampaolo.rodola, vstinner
Date 2019-11-05.14:45:46
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1572965147.18.0.658730209941.issue38699@roundup.psfhosted.org>
In-reply-to
Content
Currently, socket.socket.listen() called with no argument limits the default backlog to 128:

    /* We try to choose a default backlog high enough to avoid connection drops
     * for common workloads, yet not too high to limit resource usage. */
    int backlog = Py_MIN(SOMAXCONN, 128);

I just saw an article suggesting to use 4096 instead:
https://blog.cloudflare.com/syn-packet-handling-in-the-wild/

On my Fedora 30, listen() manual page says:

       The  behavior of the backlog argument on TCP sockets changed with Linux
       2.2.  Now it specifies the  queue  length  for  completely  established
       sockets  waiting  to  be  accepted, instead of the number of incomplete
       connection requests.  The maximum length of the  queue  for  incomplete
       sockets  can be set using /proc/sys/net/ipv4/tcp_max_syn_backlog.  When
       syncookies are enabled there is no logical maximum length and this set‐
       ting is ignored.  See tcp(7) for more information.

       If    the   backlog   argument   is   greater   than   the   value   in
       /proc/sys/net/core/somaxconn, then it is  silently  truncated  to  that
       value;  the  default  value  in  this  file  is 128.  In kernels before
       2.4.25, this limit was a hard coded value, SOMAXCONN,  with  the  value
       128.

Python 3.8 new socket.create_server() calls sock.listen() by default: so use Py_MIN(SOMAXCONN, 128) by default.
History
Date User Action Args
2019-11-05 14:45:47vstinnersetrecipients: + vstinner, giampaolo.rodola
2019-11-05 14:45:47vstinnersetmessageid: <1572965147.18.0.658730209941.issue38699@roundup.psfhosted.org>
2019-11-05 14:45:47vstinnerlinkissue38699 messages
2019-11-05 14:45:46vstinnercreate