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=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: Transfer encoding chunked disables HAProxy gzip compression Date: Fri, 2 Aug 2013 21:26:18 +0200 Message-ID: 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 1375473580 31954 80.91.229.3 (2 Aug 2013 19:59:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Aug 2013 19:59:40 +0000 (UTC) To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Original-X-From: rainbows-talk-bounces-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org Fri Aug 02 21:59:42 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-Greylist: delayed 380 seconds by postgrey-1.31 at rubyforge; Fri, 02 Aug 2013 19:32:46 UTC X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:from:content-type:content-transfer-encoding:subject :message-id:date:to:mime-version:x-mailer:x-gm-message-state; bh=x+n4AJ6LXJVIkB50QdHZrvJ0WvVmvQVDcnjqQ5UHJ38=; b=eb3A65K9HupBEDfBCCz0tIs4HDcB0YB6DMQRk+T01EPv7CNDOfYu0U6sQNJlVHZHCa LT2f4GwCM6z18tTmRe9cvIZh0VyekPYVO1/KO/CyVP3OVroPl5Q0sJ5P923MJv7ZG7Zr A9iqPRFkB2kAZZOMdgY5egmlqHMDqdxN0kh+zxvWEYPU966iEVxtzZ39dSM7SQEU3nau kCVe8J1Lmv0wHVKqoMSlZAYiHUg18Fn80mHajdK/GSIK+Ym9cHq2e/Y13qPrG6PQ4nfy Q2zHRz8CNgHTDV3GuabyYrZgrDssTWFQLT6pI5HuboycpnDRmxA8edfjVST4ph1nLHhZ 72ng== X-Received: by 10.14.108.7 with SMTP id p7mr6926745eeg.3.1375471581359; Fri, 02 Aug 2013 12:26:21 -0700 (PDT) X-Mailer: Apple Mail (2.1508) X-Gm-Message-State: ALoCoQnFJZf23ksZM7R3uuMYjxCE4ZhfCeSYjVMnRypu2MXh6kQ382hm1p0sYC0scyO5ylJzAZGn 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:497 Archived-At: Received: from [50.56.192.79] (helo=rubyforge.org) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1V5LVl-0007FB-Tv for gclrrg-rainbows-talk@m.gmane.org; Fri, 02 Aug 2013 21:59:42 +0200 Received: from localhost.localdomain (localhost [127.0.0.1]) by rubyforge.org (Postfix) with ESMTP id 793902E247; Fri, 2 Aug 2013 19:59:41 +0000 (UTC) Received: from mail-ee0-f46.google.com (mail-ee0-f46.google.com [74.125.83.46]) by rubyforge.org (Postfix) with ESMTP id DC3922E2B7 for ; Fri, 2 Aug 2013 19:32:46 +0000 (UTC) Received: by mail-ee0-f46.google.com with SMTP id c13so504276eek.19 for ; Fri, 02 Aug 2013 12:32:44 -0700 (PDT) Received: from [192.168.5.102] (host37-20-dynamic.252-95-r.retail.telecomitalia.it. [95.252.20.37]) by mx.google.com with ESMTPSA id bj46sm14316838eeb.13.2013.08.02.12.26.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 02 Aug 2013 12:26:20 -0700 (PDT) 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. HAProxy 1.5dev19 disabled automatic response compression for responses that have Transfer-Encoding: chunked from backends. I found out by downgrading haproxy as last resort and asking the developer what's up with compression being disabled from one release to another. We had some reports from our automated tools that something was wrong with gzip but it was so rare we didn't care that much, until today. There are certain rules in HAProxy to successfully enable automatic gzip compression in responses. The author told me that he had to disable compression for chunked responses in the latest version due to bad code in HAProxy, but it is still enabled for fixed content-length responses. 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. 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. 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. Thanks! _______________________________________________ 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