diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-01-31 15:51:30 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-01-31 15:52:36 -0800 |
commit | c28e2610cfc70e89a0ffabe18356d148afe98bfc (patch) | |
tree | f48226cbfdf9c4be1c519865130bdf72358c37e8 | |
parent | e3420e0ae1f3c38f125010134d2cdeb22c6fa64e (diff) | |
download | unicorn-c28e2610cfc70e89a0ffabe18356d148afe98bfc.tar.gz |
It's actually harmless since Unicorn only supports "fast" applications that do not trickle, and we don't do keepalive so we'll always flush-on-close. This should reduce wakeups on the nginx proxy server if nginx is over TCP. Mongrel 1.x had TCP_CORK enabled by default, too.
-rw-r--r-- | lib/unicorn/configurator.rb | 12 | ||||
-rw-r--r-- | lib/unicorn/socket_helper.rb | 4 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/unicorn/configurator.rb b/lib/unicorn/configurator.rb index 1aea3cd..9aa84f1 100644 --- a/lib/unicorn/configurator.rb +++ b/lib/unicorn/configurator.rb @@ -247,13 +247,13 @@ class Unicorn::Configurator # # Default: operating system defaults (usually Nagle's algorithm enabled) # - # +:tcp_nopush+: enables TCP_CORK in Linux or TCP_NOPUSH in FreeBSD + # +:tcp_nopush+: enables/disables TCP_CORK in Linux or TCP_NOPUSH in FreeBSD # - # This will prevent partial TCP frames from being sent out. - # Enabling +tcp_nopush+ is generally not needed or recommended as - # controlling +tcp_nodelay+ already provides sufficient latency - # reduction whereas Unicorn does not know when the best times are - # for flushing corked sockets. + # This is enabled by default as of Unicorn 3.4. This prevents partial + # TCP frames from being sent out and reduces wakeups in nginx if it is + # on a different machine. Since Unicorn is only designed for applications + # that send the response body quickly without keepalive, sockets will + # always be flushed on close to prevent delays. # # This has no effect on UNIX sockets. # diff --git a/lib/unicorn/socket_helper.rb b/lib/unicorn/socket_helper.rb index d07684a..9600b34 100644 --- a/lib/unicorn/socket_helper.rb +++ b/lib/unicorn/socket_helper.rb @@ -23,6 +23,10 @@ module Unicorn # same default value as Mongrel :backlog => 1024, + + # since we don't do keepalive, we'll always flush-on-close and + # this saves packets for everyone. + :tcp_nopush => true, } #:startdoc: |