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, <[email protected]> wrote: > On Wed, 2 Sep 2015 09:26:25 +0300 > Vladimir Mihailenco <[email protected]> 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. >

