reactphp / socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP.
https://reactphp.org/socket/
MIT License
1.2k stars 156 forks source link

Change default socket backlog size to 511 #242

Closed clue closed 4 years ago

clue commented 4 years ago

The backlog parameter used to default to just 32 as of PHP 5.3.3 and used to be hard coded to 4 in earlier PHP versions.

The new default of 511 was evaluated to be a reasonable value for event-driven applications that can cope with many concurrent connections on a variety of platforms. In particular, this solves common ECONNRESET (connection reset by peer) errors when running benchmarks with higher concurrency. For more specific requirements, the backlog parameter can be given explicitly to override this default.

See https://github.com/php/php-src/commit/5b277c4da0d9fb8bfb59186b61a884aaafffb861 Refs https://github.com/reactphp/http/issues/354 and others

kelunik commented 4 years ago

@clue Care to shed some light why you chose 511 instead of 512?

clue commented 4 years ago

@acasademont 511 is not only used in Node.js and PHP-FPM, but also in Nginx, Apache, Redis, etc... I'd say 511 was determined to be a safe limit on most OSes (except FreeBSD where it's -1). The backlog limit default in PHP was committed 5 years ago by an user, I don't think there was much discussion about it (the limit default itself) before or after adding a backlog stream context option?

Originally posted by @CharlotteDunois in https://github.com/reactphp/http/issues/354#issuecomment-569425096

kelunik commented 4 years ago

Thanks!