From 4060b7742d047c0000fd1bf4ac2c3b9cae95585a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Jan 2011 16:19:17 -0800 Subject: disable Nagle's algorithm by default Nagle's algorithm is harmful with the write-write-read sequence during keepalive, so we disable it performance for users using keepalive. We always write headers with a separate write because Rack response bodies may not always be ready for writing when headers are. This requires Unicorn 3.3.0 --- lib/rainbows.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib/rainbows.rb') diff --git a/lib/rainbows.rb b/lib/rainbows.rb index 3f9058e..a8bfa78 100644 --- a/lib/rainbows.rb +++ b/lib/rainbows.rb @@ -1,8 +1,15 @@ # -*- encoding: binary -*- require 'kgio' require 'unicorn' -# the value passed to TCP_DEFER_ACCEPT actually matters in Linux 2.6.32+ -Unicorn::SocketHelper::DEFAULTS[:tcp_defer_accept] = 60 +Unicorn::SocketHelper::DEFAULTS.merge!({ + # the value passed to TCP_DEFER_ACCEPT actually matters in Linux 2.6.32+ + :tcp_defer_accept => 60, + + # keep-alive performance sucks without this due to + # write(headers)-write(body)-read + # because we always write headers and bodies with two calls + :tcp_nodelay => true, +}) module Rainbows -- cgit v1.2.3-24-ge0c7