Re: Migration from nginx

2015-09-09 Thread Thierry FOURNIER
On Tue, 8 Sep 2015 11:35:48 +0300
Vladimir Mihailenco  wrote:

> That is very unlikely since haproxy and Go app run on same machine. But
> probably Go expects more data than haproxy buffers - I don't know how to
> check this assumption... The appropriate Go code is
> https://github.com/golang/go/blob/master/src/net/http/server.go#L1348


Hi, you can run a tcpdump network capture between your two processes
(even if the processes are on the same machine), and you will see which
one introduce a delay.

Thierry

 
> On Sun, Sep 6, 2015 at 1:17 PM,  wrote:
> 
> > On Sat, 5 Sep 2015 18:13:57 +0300
> > Vladimir Mihailenco  wrote:
> >
> > > Thanks for advice. It turns out that Go silently (without any reply and
> > log
> > > message) closes the connection when it can't fully read request headers.
> > > Which is kinda strange, because I thought that haproxy fully reads
> > request
> > > headers to route it to proper backend...
> >
> > Its sure: HAProxy read entirely the headers (if it os configured with
> > the mode http). Maybe your problem is between HAProy and your Go
> > server ?
> >



Re: Migration from nginx

2015-09-08 Thread Vladimir Mihailenco
That is very unlikely since haproxy and Go app run on same machine. But
probably Go expects more data than haproxy buffers - I don't know how to
check this assumption... The appropriate Go code is
https://github.com/golang/go/blob/master/src/net/http/server.go#L1348

On Sun, Sep 6, 2015 at 1:17 PM,  wrote:

> On Sat, 5 Sep 2015 18:13:57 +0300
> Vladimir Mihailenco  wrote:
>
> > Thanks for advice. It turns out that Go silently (without any reply and
> log
> > message) closes the connection when it can't fully read request headers.
> > Which is kinda strange, because I thought that haproxy fully reads
> request
> > headers to route it to proper backend...
>
> Its sure: HAProxy read entirely the headers (if it os configured with
> the mode http). Maybe your problem is between HAProy and your Go
> server ?
>


Re: Migration from nginx

2015-09-06 Thread thierry . fournier
On Sat, 5 Sep 2015 18:13:57 +0300
Vladimir Mihailenco  wrote:

> Thanks for advice. It turns out that Go silently (without any reply and log
> message) closes the connection when it can't fully read request headers.
> Which is kinda strange, because I thought that haproxy fully reads request
> headers to route it to proper backend...

Its sure: HAProxy read entirely the headers (if it os configured with
the mode http). Maybe your problem is between HAProy and your Go
server ?



Re: Migration from nginx

2015-09-05 Thread Vladimir Mihailenco
Thanks for advice. It turns out that Go silently (without any reply and log
message) closes the connection when it can't fully read request headers.
Which is kinda strange, because I thought that haproxy fully reads request
headers to route it to proper backend...


On Sat, Sep 5, 2015 at 4:11 AM,  wrote:

> On Wed, 2 Sep 2015 09:26:25 +0300
> Vladimir Mihailenco  wrote:
>
> > Hi,
> >
> > I am trying to migrate existing app written in Go from nginx to HA-Proxy
> > version 1.5.14 2015/07/02 on Ubuntu 12.04. nginx/haproxy runs behind F5
> > load balancer. My config:
> > https://gist.github.com/vmihailenco/9b41016b05cdea821687 . App mainly
> > serves POST requests with body size 10-64kb.
> >
> > First thing that I noticed after stopping nginx and starting haproxy is
> > that app spends more time processing requests (same server, same amount
> of
> > requests). E.g. with nginx Go responds within 1-2ms, but with haproxy
> > response time is in range of 100-400ms. I guess the reason is that nginx
> > buffers incoming request until it is fully read, but haproxy does not.
> What
> > can I do to enable request buffering in haproxy?
> >
> > From the logs I also see that sometimes Go does not send response
> headers,
> > e.g.
> >
> > haproxy[6607]: 149.210.205.54:54598 [01/Sep/2015:17:15:01.931] http-in
> > goab/s1 0/0/0/-1/1 -1 381 - - SD-- 128/128/6/6/0 0/0 {myhost} "POST /url
> > HTTP/1.1"
> > haproxy[6607]: 192.243.237.46:34628 [01/Sep/2015:17:15:12.851] http-in~
> > goab/s1 224/0/0/1/674 413 381 - - SD-- 128/128/15/15/0 0/0 {myhost} "POST
> > /url HTTP/1.1"
>
> Hi,
>
> You can look the documentation about log here:
>
>https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#8.2.3
>
> The termination flags are SD--, so the documentation says:
>
>S : the TCP session was unexpectedly aborted by the server, or
>the server explicitly refused it.
>
>D : the session was in the DATA phase.
>
> I suppose that you have some keepalive errors. Try to activate
> keepalive between the browser and haproxy, and deactivate between
> haproxy and your go server.
>
> Look for the directive "option httpclose".
>
>
> > So these are 2 identical requests with same response body, but 2nd
> request
> > has status code = -1. I don't understand how that is possible, because if
> > app does not set status code Go uses 200 OK status code. And app does not
> > crash.
> >
> > Thanks in advance for any help/advices.
>


Re: Migration from nginx

2015-09-04 Thread thierry . fournier
On Wed, 2 Sep 2015 09:26:25 +0300
Vladimir Mihailenco  wrote:

> Hi,
> 
> I am trying to migrate existing app written in Go from nginx to HA-Proxy
> version 1.5.14 2015/07/02 on Ubuntu 12.04. nginx/haproxy runs behind F5
> load balancer. My config:
> https://gist.github.com/vmihailenco/9b41016b05cdea821687 . App mainly
> serves POST requests with body size 10-64kb.
> 
> First thing that I noticed after stopping nginx and starting haproxy is
> that app spends more time processing requests (same server, same amount of
> requests). E.g. with nginx Go responds within 1-2ms, but with haproxy
> response time is in range of 100-400ms. I guess the reason is that nginx
> buffers incoming request until it is fully read, but haproxy does not. What
> can I do to enable request buffering in haproxy?
> 
> From the logs I also see that sometimes Go does not send response headers,
> e.g.
> 
> haproxy[6607]: 149.210.205.54:54598 [01/Sep/2015:17:15:01.931] http-in
> goab/s1 0/0/0/-1/1 -1 381 - - SD-- 128/128/6/6/0 0/0 {myhost} "POST /url
> HTTP/1.1"
> haproxy[6607]: 192.243.237.46:34628 [01/Sep/2015:17:15:12.851] http-in~
> goab/s1 224/0/0/1/674 413 381 - - SD-- 128/128/15/15/0 0/0 {myhost} "POST
> /url HTTP/1.1"

Hi,

You can look the documentation about log here: 

   https://cbonte.github.io/haproxy-dconv/configuration-1.5.html#8.2.3

The termination flags are SD--, so the documentation says:

   S : the TCP session was unexpectedly aborted by the server, or
   the server explicitly refused it.

   D : the session was in the DATA phase.

I suppose that you have some keepalive errors. Try to activate
keepalive between the browser and haproxy, and deactivate between
haproxy and your go server.

Look for the directive "option httpclose".


> So these are 2 identical requests with same response body, but 2nd request
> has status code = -1. I don't understand how that is possible, because if
> app does not set status code Go uses 200 OK status code. And app does not
> crash.
> 
> Thanks in advance for any help/advices.



Migration from nginx

2015-09-01 Thread Vladimir Mihailenco
Hi,

I am trying to migrate existing app written in Go from nginx to HA-Proxy
version 1.5.14 2015/07/02 on Ubuntu 12.04. nginx/haproxy runs behind F5
load balancer. My config:
https://gist.github.com/vmihailenco/9b41016b05cdea821687 . App mainly
serves POST requests with body size 10-64kb.

First thing that I noticed after stopping nginx and starting haproxy is
that app spends more time processing requests (same server, same amount of
requests). E.g. with nginx Go responds within 1-2ms, but with haproxy
response time is in range of 100-400ms. I guess the reason is that nginx
buffers incoming request until it is fully read, but haproxy does not. What
can I do to enable request buffering in haproxy?

>From the logs I also see that sometimes Go does not send response headers,
e.g.

haproxy[6607]: 149.210.205.54:54598 [01/Sep/2015:17:15:01.931] http-in
goab/s1 0/0/0/-1/1 -1 381 - - SD-- 128/128/6/6/0 0/0 {myhost} "POST /url
HTTP/1.1"
haproxy[6607]: 192.243.237.46:34628 [01/Sep/2015:17:15:12.851] http-in~
goab/s1 224/0/0/1/674 413 381 - - SD-- 128/128/15/15/0 0/0 {myhost} "POST
/url HTTP/1.1"

So these are 2 identical requests with same response body, but 2nd request
has status code = -1. I don't understand how that is possible, because if
app does not set status code Go uses 200 OK status code. And app does not
crash.

Thanks in advance for any help/advices.