Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Claudio Poli <claudio-3HQ/CcOImoi171pxa8y+qA@public.gmane.org>
To: Rainbows! list <rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org>
Subject: Re: Transfer encoding chunked disables HAProxy gzip compression
Date: Sat, 3 Aug 2013 02:20:59 +0200	[thread overview]
Message-ID: <E85CF5AB-7FF6-4BE8-BAAC-5416E14D4A14@gmail.com> (raw)
In-Reply-To: <20130802231115.GA24708-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>

On 03/ago/2013, at 01:11, Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org> wrote:

> Claudio Poli <claudio-3HQ/CcOImoi171pxa8y+qA@public.gmane.org> wrote:
>> 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.
> Good to know!

I'm still battling a little to find the perfect configuration, my deploy script (and rails) takes RACK_ENV seriously, but the -E switch for Rainbows! and Unicorn, as I understand, it's another thing that might or not might inject Rack::ContentLength and Rack::Chunked.
I admit that I was not able to see a Content-Length response when querying the app server with curl's --http1.0 . But at least we have compression back.

>> Willy told me the HAProxy compression issue for chunked request might
>> be solved in Sept.
> I will be curious to see performance numbers for your cluster with
> gzipping in HAProxy vs Rack::Deflater once this is fixed in HAProxy.

Yeah, there are definitely up and downsides in this approach to centralize gzip responses.
HAProxy has advanced parameters to fine tune the compression process,  you can set it to automatically skip gzipping when CPU reaches a user defined % threshold and the like.
To run a basic I'll probably just use the defaults.

Centralizing gzip was awesome for us because our applications servers are layered out in a distribute manner.
Now it has become pretty common to have multiple apps serving in the cloud sharing same-path HTTP endpoints through both simple and advanced routing logic at balancer level.

For example we delegate uploads and heavy streaming-related code to node.js, while our API and frontend are Rails. There are also a number of small services written in javascript, ruby and occasionally java.
It's also common that those apps communicate internally each other, via http or other message queues.

So, Rainbows! is configured to accept connections  through both tcp (only from the load balancers) and unix socket; the rest of the local stack will call Rainbows! directly on the unix socket, while serving http requests coming in from HAProxy destined the public.
Enabling gzip on the internal main rails app wreak havoc because libraries might not be ready to handle gzip responses, it's the case of the Request library for node.js. It does not ask for gzipped responses per-se, but since it is acting as a transparent proxy, the original request is taken from the client and forwarded as-is to Rails, like it was done to it directly.
In Node.js this was the point where I had to remove manually gzip headers to communicate internally with Rails (with Rack::Deflater) and without issues.

A central point where to produce gzipped responses for the public is pretty spot on for our architecture, since other apps (node.js, etc.) requires it in some cases.

I know that it might be confusing, perhaps it's time for a blog post.


> _______________________________________________
> 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
Do not quote signatures (like this one) or top post when replying

  parent reply	other threads:[~2013-08-03  0:49 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-02 19:26 Transfer encoding chunked disables HAProxy gzip compression Claudio Poli
     [not found] ` <CD8781D3-288B-4B61-85ED-16B8B15A90E9-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-02 20:03   ` Claudio Poli
     [not found]     ` <9C3CB455-F4F3-4DF4-BF67-1801547FE1B7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-02 20:46       ` Eric Wong
     [not found]         ` <20130802204647.GA7479-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-08-02 21:00           ` Eric Wong
     [not found]             ` <20130802210004.GB9486-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-08-02 21:35               ` Claudio Poli
2013-08-02 21:49               ` Claudio Poli
2013-08-02 20:58   ` Eric Wong
     [not found]     ` <20130802205810.GA9486-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-08-02 22:34       ` Claudio Poli
     [not found]         ` <FE4BFDCF-538B-4D2D-8991-FE0047DF52AA-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-02 23:11           ` Eric Wong
     [not found]             ` <20130802231115.GA24708-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-08-03  0:20               ` Claudio Poli [this message]
     [not found]                 ` <E85CF5AB-7FF6-4BE8-BAAC-5416E14D4A14-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-03  1:06                   ` Eric Wong
     [not found]                     ` <20130803010627.GA4521-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2013-08-03  1:53                       ` Claudio Poli
     [not found]                         ` <9580D763-16FA-4DB5-8CA7-0648DD6788CD-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-08-03  2:30                           ` Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E85CF5AB-7FF6-4BE8-BAAC-5416E14D4A14@gmail.com \
    --to=claudio-3hq/ccoimoi171pxa8y+qa@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).