RE: HAProxy1.7.9-http-reuse

2017-10-29 Thread Karthikeyan.Rajamani
Thank you Willy. 

I also tested it with http alone(no ssl). The time went down from 411ms to 
238ms with -k in ab. 

Good to know that it is in the feature list.

Thanks again.

Best Regards
Karthik

-Original Message-
From: Willy Tarreau [mailto:w...@1wt.eu] 
Sent: Sunday, October 29, 2017 10:12 AM
To: Rajamani, Karthikeyan (TR Technology & Ops)
Cc: bryan.tal...@playnext.com; haproxy@formilux.org
Subject: Re: HAProxy1.7.9-http-reuse

On Sun, Oct 29, 2017 at 02:37:25PM +, 
karthikeyan.rajam...@thomsonreuters.com wrote:
> Hello,
> 
> Thank you. Option http-pretend-keepalive did not reduce the time.
> 
> The latency is 210ms only if we inject -k in ab when tested with ssl. 

OK so it makes sense now.

> We need a feature in haproxy that can keep alive as ab when used with ssl.
> Can you please add it to your feature list.

It's already in the todo list. It was even in the todo for 1.7 but with stuff 
getting merged late it was postponed. It'll be for 1.9 now as we'll need it to 
improve HTTP/2 support.

Willy



Re: HAProxy1.7.9-http-reuse

2017-10-29 Thread Willy Tarreau
On Sun, Oct 29, 2017 at 02:37:25PM +, 
karthikeyan.rajam...@thomsonreuters.com wrote:
> Hello,
> 
> Thank you. Option http-pretend-keepalive did not reduce the time.
> 
> The latency is 210ms only if we inject -k in ab when tested with ssl. 

OK so it makes sense now.

> We need a feature in haproxy that can keep alive as ab when used with ssl.
> Can you please add it to your feature list.

It's already in the todo list. It was even in the todo for 1.7 but with
stuff getting merged late it was postponed. It'll be for 1.9 now as we'll
need it to improve HTTP/2 support.

Willy



RE: HAProxy1.7.9-http-reuse

2017-10-29 Thread Karthikeyan.Rajamani
Hello,

Thank you. Option http-pretend-keepalive did not reduce the time.

The latency is 210ms only if we inject -k in ab when tested with ssl. 

We need a feature in haproxy that can keep alive as ab when used with ssl. Can 
you please add it to your feature list.

Thanks & Regards
Karthik

-Original Message-
From: Willy Tarreau [mailto:w...@1wt.eu] 
Sent: Thursday, October 26, 2017 11:32 PM
To: Bryan Talbot
Cc: Rajamani, Karthikeyan (TR Technology & Ops); HAproxy Mailing Lists
Subject: Re: HAProxy1.7.9-http-reuse

Hi Bryan,

On Thu, Oct 26, 2017 at 03:51:33PM -0700, Bryan Talbot wrote:
> > 4. Local haproxy log
> > 172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1 
> > 0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"
> 
> 
> This log line says that it took your local proxy 204 ms to connect to 
> the remote proxy and that the first response bytes from the remote 
> proxy were received by the local proxy 205 ms later for a total round 
> trip time of 410 ms (after rounding).
> 
> The only way to get the total time to be equal to the network latency 
> times would be to make the remote respond in 0 ms (or less!). If the 
> two proxies are actually 200 ms apart, I don't see how you could do much 
> better.

Not exactly in fact, what Karthikeyan is observing totally makes sense.
The first round trip is used for the SYN->SYN/ACK, the second one for
request->response. The server roughly takes 2 ms to respond if the ping
is 204ms and the total time is 410ms (410-2*204).

Regarding http-reuse, it indeed only reuses idle connections, and there are 
certain conditions for this. The first one obviously is that the response must 
be made in keep-alive so that the connection is kept open.
If "ab" is used to inject, it needs "-k" to enable keep-alive otherwise by 
default a close is requested and the connections are closed. I'm suddenly 
wondering if using "option http-pretend-keepalive" could help cheating here, I 
honnestly don't know.

Willy



RE: HAProxy1.7.9-http-reuse

2017-10-29 Thread Karthikeyan.Rajamani
Hello Bryan,

You are right, there is not a connection pool.

We tested it, in tcp dump we see the same port being reused with http-reuse 
aggressive/always as long as the connection is alive & not being reused if 
http-resuse is removed .

Thank you very much.

Thanks & Regards
Karthik



From: Bryan Talbot [mailto:bryan.tal...@playnext.com]
Sent: Thursday, October 26, 2017 8:47 PM
To: Rajamani, Karthikeyan (TR Technology & Ops)
Cc: HAproxy Mailing Lists
Subject: Re: HAProxy1.7.9-http-reuse




On Oct 26, 2017, at Oct 26, 6:13 PM, 
karthikeyan.rajam...@thomsonreuters.com<mailto:karthikeyan.rajam...@thomsonreuters.com>
 wrote:


Yes the log indicates that. But the RTT via ping is 204 ms, with http-reuse 
always/aggressive option the connection is reused & we expect a time close to 
ping+ a small overhead time, the http-resuse always seem to have no impact on 
the  total time taken.
We are looking to get the option working.


I’d bet that it’s working but that it doesn’t do what you're assuming it does.

It’s not a connection pool that keeps connections open to a backend when there 
are no current requests. As the last paragraph and note of 
https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#http-reuse<https://urldefense.proofpoint.com/v2/url?u=https-3A__cbonte.github.io_haproxy-2Ddconv_1.7_configuration.html-23http-2Dreuse&d=DwMFaQ&c=4ZIZThykDLcoWk-GVjSLmy8-1Cr1I4FWIvbLFebwKgY&r=tPN4RNM1omOmcOWQYx92QHZErVx8Tp4m6aVAvjVu3uI9lxs1R3lVPGVai2o59274&m=OskODexIm6flCarX-uWjjqQzHVENwS_GnrKm-9vZRtw&s=doiTfuOjJz8g-3PYIRpqt9swiOjmslCBXV15XZNd8tI&e=>
 says



No connection pool is involved, once a session dies, the last idle connection

it was attached to is deleted at the same time. This ensures that connections

may not last after all sessions are closed.



Note: connection reuse improves the accuracy of the "server maxconn" setting,

because almost no new connection will be established while idle connections

remain available. This is particularly true with the "always" strategy.

So, testing one connection at a time one would not expect to see any 
difference. The benefit comes when there are many concurrent requests.

One way to check if the feature is working would be to run your ‘ab’ test with 
some concurrency N and inspect the active TCP connections from local proxy to 
remote proxy. If the feature is working, I would expect to see about N 
(something less) TCP connections that are reused for multiple requests. If 
there are 1000 requests sent with concurrency 10 and 1000 different TCP 
connections used the feature isn’t working (or the connections are private).

-Bryan



Re: HAProxy1.7.9-http-reuse

2017-10-26 Thread Willy Tarreau
Hi Bryan,

On Thu, Oct 26, 2017 at 03:51:33PM -0700, Bryan Talbot wrote:
> > 4. Local haproxy log
> > 172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1 
> > 0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"
> 
> 
> This log line says that it took your local proxy 204 ms to connect to the
> remote proxy and that the first response bytes from the remote proxy were
> received by the local proxy 205 ms later for a total round trip time of 410
> ms (after rounding).
> 
> The only way to get the total time to be equal to the network latency times
> would be to make the remote respond in 0 ms (or less!). If the two proxies
> are actually 200 ms apart, I don't see how you could do much better.

Not exactly in fact, what Karthikeyan is observing totally makes sense.
The first round trip is used for the SYN->SYN/ACK, the second one for
request->response. The server roughly takes 2 ms to respond if the ping
is 204ms and the total time is 410ms (410-2*204).

Regarding http-reuse, it indeed only reuses idle connections, and there
are certain conditions for this. The first one obviously is that the
response must be made in keep-alive so that the connection is kept open.
If "ab" is used to inject, it needs "-k" to enable keep-alive otherwise
by default a close is requested and the connections are closed. I'm
suddenly wondering if using "option http-pretend-keepalive" could help
cheating here, I honnestly don't know.

Willy



Re: HAProxy1.7.9-http-reuse

2017-10-26 Thread Bryan Talbot


> On Oct 26, 2017, at Oct 26, 6:13 PM, karthikeyan.rajam...@thomsonreuters.com 
> wrote:
> 
>  
> Yes the log indicates that. But the RTT via ping is 204 ms, with http-reuse 
> always/aggressive option the connection is reused & we expect a time close to 
> ping+ a small overhead time, the http-resuse always seem to have no impact on 
> the  total time taken.
> We are looking to get the option working.


I’d bet that it’s working but that it doesn’t do what you're assuming it does.

It’s not a connection pool that keeps connections open to a backend when there 
are no current requests. As the last paragraph and note of 
https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#http-reuse 
 says


No connection pool is involved, once a session dies, the last idle connection
it was attached to is deleted at the same time. This ensures that connections
may not last after all sessions are closed.

Note: connection reuse improves the accuracy of the "server maxconn" setting,
because almost no new connection will be established while idle connections
remain available. This is particularly true with the "always" strategy.

So, testing one connection at a time one would not expect to see any 
difference. The benefit comes when there are many concurrent requests.

One way to check if the feature is working would be to run your ‘ab’ test with 
some concurrency N and inspect the active TCP connections from local proxy to 
remote proxy. If the feature is working, I would expect to see about N 
(something less) TCP connections that are reused for multiple requests. If 
there are 1000 requests sent with concurrency 10 and 1000 different TCP 
connections used the feature isn’t working (or the connections are private).

-Bryan



RE: HAProxy1.7.9-http-reuse

2017-10-26 Thread Karthikeyan.Rajamani
Hi Aleks,

Thanks for the reply, I have replied inline.

Thanks
Karthik

-Original Message-
From: Aleksandar Lazic [mailto:al-hapr...@none.at] 
Sent: Thursday, October 26, 2017 5:54 PM
To: Rajamani, Karthikeyan (TR Technology & Ops); haproxy@formilux.org
Subject: Re: HAProxy1.7.9-http-reuse

Hi

-- Originalnachricht --
Von: karthikeyan.rajam...@thomsonreuters.com
An: haproxy@formilux.org
Gesendet: 27.10.2017 00:13:50
Betreff: HAProxy1.7.9-http-reuse

>Hi,
>
>We are testing a setup which has a local haproxy which connects to a 
>remote haproxy which in turn calls an apache server which returns a 
>html page.
>
>Haproxy(local)->Haproxy(remote)->Apache.
>
>We have  the set up working, the ping time from local to remote haproxy 
>is 204 ms.
>
>The time taken for the web page when accessed by the browser is 410 ms.
>
>We want the latency to be 204 ms when accessed by the browser. We 
>configured to reuse http & with http-reuse aggresive|always|safe 
>options
>
>but could not reduce the 410 ms to 204 ms. It is always 410 ms. Please 
>let us know how we can reuse http & reduce out latency.
ping is normally icmp and will be answered by the kernel.
http is normally tcp and will be answered by the apache httpd.
How do you measure the latency on the browser site?

We use chrome's tools->nw & also apache bench
--
Why do you expect that a complete other work flow have the same amount of time?

You can try to use mod_cache or some other cache concepts to reduce the disc 
I/O, in case you deliver a file and it fits into os cache.

The RTT via ping is 204 ms, with the use of http-resue always/aggressive the 
time via the apache bench/ browser should be close to the RTT + a small time 
overhead for headers/io. But the http-reuse has no effect on the request to 
response time. As per the documentation the http connection should be reused & 
the total time should be close to the ping time

Ab -n 1000 -c 40 ip. The I/O time is very minimal 

Regards
Aleks

>Thanks
>
>Karthik
>
>
>
>Please find the version, local config, remote config & local haproxy 
>log
>
>
>
>1.haproxy -vv
>
>HA-Proxy version 1.7.9 2017/08/18
>
>-
>
>2.Local config
>
>-
>
>global
>
>log 127.0.0.1 local0
>
>chroot /var/lib/haproxy
>
>stats socket /run/haproxy/admin.sock mode 660 level admin
>
>stats timeout 30s
>
>user haproxy
>
>group haproxy
>
>daemon
>
>
>
>defaults
>
>log global
>
>mode http
>
>option httplog
>
>timeout http-keep-alive 5
>
>timeout connect 5000
>
>timeout client 5
>
>timeout server 5
>
>maxconn 500
>
>
>
>frontend http_front
>
>bind *:80
>
>stats uri /haproxy?stats
>
>capture response header Connection len 32
>
>default_backend http_back
>
>
>
>
>
>backend http_back
>
>option http-keep-alive
>
>http-reuse always
>
>server remote remote.haproxy.internal:80 check inter 6 maxconn
>500
>
>-
>
>3. Remote config
>
>-
>
>global
>
>log 127.0.0.1 local0
>
>chroot /var/lib/haproxy
>
>stats socket /run/haproxy/admin.sock mode 660 level admin
>
>stats timeout 30s
>
>user haproxy
>
>group haproxy
>
>daemon
>
>
>
>defaults
>
>log global
>
>mode http
>
>option httplog
>
>option http-keep-alive
>
>timeout http-keep-alive 5
>
>timeout connect 5000
>
>timeout client 5
>
>timeout server 5
>
>
>
>frontend http_front
>
>bind *:80
>
>stats uri /haproxy?stats
>
>default_backend http_back
>
>
>
>backend http_back
>
>option http-keep-alive
>
>http-reuse always
>
>server web2 52.91.x.x:80 check inter 6 maxconn 500
>
>-
>
>4. Local haproxy log
>
>172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1
>0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"
>
>
>
>
>
>
>
>
>
Thanks again!

Best Regards
Karthik


RE: HAProxy1.7.9-http-reuse

2017-10-26 Thread Karthikeyan.Rajamani
Hell Bryan,

Thank you for the response. I have replied inline.

From: Bryan Talbot [mailto:bryan.tal...@playnext.com]
Sent: Thursday, October 26, 2017 5:52 PM
To: Rajamani, Karthikeyan (TR Technology & Ops)
Cc: HAproxy Mailing Lists
Subject: Re: HAProxy1.7.9-http-reuse

Hello



On Oct 26, 2017, at Oct 26, 3:13 PM, 
karthikeyan.rajam...@thomsonreuters.com<mailto:karthikeyan.rajam...@thomsonreuters.com>
 wrote:

Hi,
We have  the set up working, the ping time from local to remote haproxy is 204 
ms.
The time taken for the web page when accessed by the browser is 410 ms.
We want the latency to be 204 ms when accessed by the browser. We configured to 
reuse http & with http-reuse aggresive|always|safe options
but could not reduce the 410 ms to 204 ms. It is always 410 ms. Please let us 
know how we can reuse http & reduce out latency.



4. Local haproxy log
172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1 
0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"


This log line says that it took your local proxy 204 ms to connect to the 
remote proxy and that the first response bytes from the remote proxy were 
received by the local proxy 205 ms later for a total round trip time of 410 ms 
(after rounding).

The only way to get the total time to be equal to the network latency times 
would be to make the remote respond in 0 ms (or less!). If the two proxies are 
actually 200 ms apart, I don’t see how you could do much better.

-Bryan

Yes the log indicates that. But the RTT via ping is 204 ms, with http-reuse 
always/aggressive option the connection is reused & we expect a time close to 
ping+ a small overhead time, the http-resuse always seem to have no impact on 
the  total time taken.
We are looking to get the option working.

Thanks again!

Best Regards
Karthik


Re: HAProxy1.7.9-http-reuse

2017-10-26 Thread Aleksandar Lazic

Hi

-- Originalnachricht --
Von: karthikeyan.rajam...@thomsonreuters.com
An: haproxy@formilux.org
Gesendet: 27.10.2017 00:13:50
Betreff: HAProxy1.7.9-http-reuse


Hi,

We are testing a setup which has a local haproxy which connects to a 
remote haproxy which in turn calls an apache server which returns a 
html page.


Haproxy(local)->Haproxy(remote)->Apache.

We have  the set up working, the ping time from local to remote haproxy 
is 204 ms.


The time taken for the web page when accessed by the browser is 410 ms.

We want the latency to be 204 ms when accessed by the browser. We 
configured to reuse http & with http-reuse aggresive|always|safe 
options


but could not reduce the 410 ms to 204 ms. It is always 410 ms. Please 
let us know how we can reuse http & reduce out latency.

ping is normally icmp and will be answered by the kernel.
http is normally tcp and will be answered by the apache httpd.
How do you measure the latency on the browser site?

Why do you expect that a complete other work flow have the same amount 
of time?


You can try to use mod_cache or some other cache concepts to reduce the 
disc I/O, in case you deliver a file and it fits into os cache.


Regards
Aleks


Thanks

Karthik



Please find the version, local config, remote config & local haproxy 
log




1.haproxy -vv

HA-Proxy version 1.7.9 2017/08/18

-

2.Local config

-

global

   log 127.0.0.1 local0

   chroot /var/lib/haproxy

   stats socket /run/haproxy/admin.sock mode 660 level admin

   stats timeout 30s

   user haproxy

   group haproxy

   daemon



defaults

   log global

   mode http

   option httplog

   timeout http-keep-alive 5

   timeout connect 5000

   timeout client 5

   timeout server 5

   maxconn 500



frontend http_front

   bind *:80

   stats uri /haproxy?stats

   capture response header Connection len 32

   default_backend http_back





backend http_back

   option http-keep-alive

   http-reuse always

   server remote remote.haproxy.internal:80 check inter 6 maxconn 
500


-

3. Remote config

-

global

   log 127.0.0.1 local0

   chroot /var/lib/haproxy

   stats socket /run/haproxy/admin.sock mode 660 level admin

   stats timeout 30s

   user haproxy

   group haproxy

   daemon



defaults

   log global

   mode http

   option httplog

   option http-keep-alive

   timeout http-keep-alive 5

   timeout connect 5000

   timeout client 5

   timeout server 5



frontend http_front

bind *:80

stats uri /haproxy?stats

default_backend http_back



backend http_back

   option http-keep-alive

   http-reuse always

   server web2 52.91.x.x:80 check inter 6 maxconn 500

-

4. Local haproxy log

172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1 
0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"















Re: HAProxy1.7.9-http-reuse

2017-10-26 Thread Bryan Talbot
Hello


> On Oct 26, 2017, at Oct 26, 3:13 PM, karthikeyan.rajam...@thomsonreuters.com 
> wrote:
> 
> Hi,
> We have  the set up working, the ping time from local to remote haproxy is 
> 204 ms.
> The time taken for the web page when accessed by the browser is 410 ms.
> We want the latency to be 204 ms when accessed by the browser. We configured 
> to reuse http & with http-reuse aggresive|always|safe options
> but could not reduce the 410 ms to 204 ms. It is always 410 ms. Please let us 
> know how we can reuse http & reduce out latency.
>  

> 4. Local haproxy log
> 172.31.x.x:53202 [26/Oct/2017:21:02:36.368] http_front http_back/web1 
> 0/0/204/205/410 200 89 - -  0/0/0/0/0 0/0 {} "GET / HTTP/1.0"


This log line says that it took your local proxy 204 ms to connect to the 
remote proxy and that the first response bytes from the remote proxy were 
received by the local proxy 205 ms later for a total round trip time of 410 ms 
(after rounding).

The only way to get the total time to be equal to the network latency times 
would be to make the remote respond in 0 ms (or less!). If the two proxies are 
actually 200 ms apart, I don’t see how you could do much better.

-Bryan