From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: * X-Spam-ASN: AS33070 50.56.128.0/17 X-Spam-Status: No, score=1.3 required=3.0 tests=AWL,MSGID_FROM_MTA_HEADER, RDNS_NONE shortcircuit=no autolearn=no version=3.3.2 Path: news.gmane.org!not-for-mail From: Claudio Poli Newsgroups: gmane.comp.lang.ruby.rainbows.general Subject: Re: Transfer encoding chunked disables HAProxy gzip compression Date: Sat, 3 Aug 2013 00:34:17 +0200 Message-ID: References: <20130802205810.GA9486@dcvr.yhbt.net> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 (Mac OS X Mail 6.5 \(1508\)) Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1375484641 11083 80.91.229.3 (2 Aug 2013 23:04:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Aug 2013 23:04:01 +0000 (UTC) To: Rainbows! list Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Sat Aug 03 01:04:02 2013 Return-path: Envelope-to: gclrrg-rainbows-talk@m.gmane.org X-Original-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Delivered-To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:content-type:mime-version:subject:from:in-reply-to:date :content-transfer-encoding:message-id:references:to:x-mailer :x-gm-message-state; bh=BpmGCIulgWgradFCpE22aC0FV5fJNVYTuAotzsRkljc=; b=LKV7IPiuHTnNKknAIUcKeNgBw/SHzxGUDpjd8igQdTRJPsCNmsXkCQmdWeZ6BGL7ji KoOaJiH9bn19uf1DcP3xIQkx0oAU3T5Mh2mR2McRr4WpqP6/fQ4J5XMk/klFb3yTODBj gKKi9CI6avFU5GracZD0yOzJtRl8CGtEhFmIk5E7qf4nMsVxmR/bt6UtoYGkVAjJlDsD FcUiCbVB0ZPq1xY3jWGoE4I/DDHuD2wzozRJIVcwJp75bqTYGfTUFrmwTJLQklxYzWPt WgVhSyRpJFuqHqxOYozZmmO5VD/mU67aN+vsBhTSW7XBSe7WgbRmWs4Nvtp1THmCr0wA p5Hw== X-Received: by 10.15.42.72 with SMTP id t48mr7297063eev.105.1375482860900; Fri, 02 Aug 2013 15:34:20 -0700 (PDT) In-Reply-To: <20130802205810.GA9486-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org> X-Mailer: Apple Mail (2.1508) X-Gm-Message-State: ALoCoQkH8v8RXYX1mzw5QriJnN9HvMcQv7ybbZxqzW1iLOZB94+366Zyqv6QvxhT1kI14KUBtTcW X-BeenThere: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Errors-To: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org X-Broken-Reverse-DNS: no host name found for IP address 50.56.192.79 Xref: news.gmane.org gmane.comp.lang.ruby.rainbows.general:504 Archived-At: Received: from [50.56.192.79] (helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V5OO8-0002W9-W9 for gclrrg-rainbows-talk@m.gmane.org; Sat, 03 Aug 2013 01:04:01 +0200 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id EA15E2E25A; Fri, 2 Aug 2013 23:04:00 +0000 (UTC) Received: from mail-ea0-f177.google.com (mail-ea0-f177.google.com [209.85.215.177]) by rubyforge.org (Postfix) with ESMTP id 663DF2E198 for ; Fri, 2 Aug 2013 22:34:22 +0000 (UTC) Received: by mail-ea0-f177.google.com with SMTP id f15so563076eak.8 for ; Fri, 02 Aug 2013 15:34:21 -0700 (PDT) Received: from [172.20.10.3] (adsl-ull-66-200.46-151.net24.it. [151.46.200.66]) by mx.google.com with ESMTPSA id x3sm14791833eeu.1.2013.08.02.15.34.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 15:34:20 -0700 (PDT) Ok, in staging everything seems to work correctly, we had to handle a case where one of our internal services couldn't communicate through compressed responses. Willy told me the HAProxy compression issue for chunked request might be solved in Sept. Best, Claudio On 02/ago/2013, at 22:58, Eric Wong wrote: > Claudio Poli wrote: >> Hello, story time. >> >> I was investigating why suddenly our service become slow in response >> times, currenrly the app is served through Rainbows! behind HAProxy. >> >> It turns out that the problem is HAProxy, which we use as >> frontend/load balancer *and* for gzip compression of responses from >> backends. > > > OK, hopefully these problems get fixed in HAProxy soon > >> So, I tried to study rainbows and unicorn internals a bit (-N switch, >> -E 'development, deploy, none') to attempt and disable chunked >> middleware and replace with a Rack::ContentLength, so if and when the >> body can be enumerated my responses would have a fixed size length to >> feed the client. > >> It doesn't work: I tried to place them in config.ru, in rails' >> application.rb, tried the -N switch, messed with -E but in staging >> every response that comes out are of type http/1.1 chunked requests. > > This could be from Rails chunked responses, especially if you're using > -N already. You may have to dig into Rails internals a bit... > > When in doubt, try dropping Rails from the equation and using a bare > bones "hello world" type Rack app (e.g. Rack::Lobster) > > Rack::ContentLength won't add a Content-Length header if the response > was already chunked anywhere before. > >> So I went ahead and added Rack::Deflater to live with the chunked >> response types and enable gzip compression as well, even if the cpu >> spent time compressing moved from one load balancer to the app server. > > This is probably the better way to go anyways, especially if you add > more Rainbows! workers and maintain few HAproxy processes. > >> I would like to know more about this behavior and based on which >> factors Rainbows! or Unicorn set and pick the transfer-encoding or >> content-lenght to use. > > It's down to middleware/Rack stack ordering (LIFO), and reading code of > these middlewares. Since Rack::Chunked runs first in the default > Rack::Server configs, Chunked can insert its headers before > ContentLength for HTTP 1.1 requests. > > Rack::Chunked won't force an existing Content-Length response to > be chunked, it'll only make things chunked that don't have either > Content-Length/Transfer-Encoding set. > _______________________________________________ > Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org > http://rubyforge.org/mailman/listinfo/rainbows-talk > Do not quote signatures (like this one) or top post when replying _______________________________________________ Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org http://rubyforge.org/mailman/listinfo/rainbows-talk Do not quote signatures (like this one) or top post when replying