On Sun, Sep 30, 2018 at 12:01:54PM +0300, Ciprian Dorin Craciun wrote:
> On Sun, Sep 30, 2018 at 11:41 AM Ciprian Dorin Craciun
> <[email protected]> wrote:
> > > - tune.sndbuf.client 16384 allows you to have 16384 bytes "on-the-fly", 
> > > meaning unacknowlegded. 16384 / 0.16 sec = roughly 128 KB/s....
> > > - do the math with your value of 131072 and you will have get your ~800 
> > > KB/s.
> 
> 
> However, something bothers me...  Setting `tune.sndbuf.client`, is
> used only to call `setsockopt (SO_SNDBUF)`, right?  It is not used by
> HAProxy for any internal buffer size?

No it's totally independent. haproxy uses tune.bufsize for its own
buffers. You are configuring the recv and send buffers of the sockets
(in the system) and as such acting on the window sizes.

> If so then by not setting it the kernel should choose the default
> value, which according to:
> ~~~~
> > sysctl net.ipv4.tcp_wmem
> net.ipv4.tcp_wmem = 4096        16384   4194304
> ~~~~
> , should be 16384.

No, it *starts* at 16384 then grows up to the configured limit depending
on the ability to do so without losses and the available memory.

> Looking with `netstat` at the `Recv-Q` column, it seems that with no
> `tune` setting the value even goes up to 5 MB.

Recv-Q is based on tcp_rmem, not tcp_wmem.

> However setting the `tune` parameter it always goes up to around 20 KB.
> 
> 
> Anyway, why am I trying to configure the sending buffer size:  if I
> have large downloads and I have (some) slow clients, and as a
> consequence HAProxy times out waiting for the kernel buffer to clear.

Thus you might have very short timeouts! Usually it's not supposed to
be an issue.

> However if I configure the buffer size small enough it seems HAProxy
> is "kept bussy" and nothing breaks.

I see but then maybe you should simply lower the tcp_wmem max value a
little bit, or increase your timeout ?

> Thus, is there a way to have both OK bandwidth for normal clients, and
> not timeout for slow clients?

That's exactly the role of the TCP stack. It measures RTT and losses and
adjusts the send window accordingly. You must definitely let the TCP
stack play its role there, you'll have much less problems. Even if you
keep 4 MB as the max send window, for a 1 Mbps client that's rougly 40
seconds of transfer. You can deal with this using much larger timeouts
(1 or 2 minutes), and configure the tcp-ut value on the bind line to
get rid of clients which do not ACK the data they're being sent at the
TCP level.

Willy

Reply via email to