Welcome! Log In Create A New Profile

Advanced

Reuse backend connections

Posted by Leela Kalidindi (lkalidin) 
Leela Kalidindi (lkalidin)
Reuse backend connections
June 29, 2018 02:20PM
Hi,

How can I enforce haproxy to reuse limited backend connections regardless of number of client connections? Basically I do not want to recreate backend connection for every front end client.

"HAPROXY_0_BACKEND_HEAD": "\nbackend {backend}\n balance {balance}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n option persist\n http-reuse aggressive\n maxconn 16\n",
"HAPROXY_0_FRONTEND_HEAD": "\nfrontend {backend}\n bind {bindAddr}:{servicePort}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n maxconn 16\n"

I currently have the above configuration, but still backend connections are getting closed when the next client request comes in.

Could someone help me with the issue? Thanks in advance!


-Leela
Bryan Talbot
Re: Reuse backend connections
June 29, 2018 09:40PM
> On Jun 29, 2018, at Jun 29, 5:11 AM, Leela Kalidindi (lkalidin) <[email protected]> wrote:
>
> Hi,
>
> How can I enforce haproxy to reuse limited backend connections regardless of number of client connections? Basically I do not want to recreate backend connection for every front end client.
>
> "HAPROXY_0_BACKEND_HEAD": "\nbackend {backend}\n balance {balance}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n option persist\n http-reuse aggressive\n maxconn 16\n",
> "HAPROXY_0_FRONTEND_HEAD": "\nfrontend {backend}\n bind {bindAddr}:{servicePort}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n maxconn 16\n"
>
> I currently have the above configuration, but still backend connections are getting closed when the next client request comes in.
>
> Could someone help me with the issue? Thanks in advance!
>


I suspect that there is a misunderstanding of what backend connection re-use means. Specifically this portion from the documentation seems to trip people up:


https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#http-reuse <https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#http-reuse>;
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.

I suspect that in your testing, you send one request, observe TCP state, then send a second request and expect the second request to use the same TCP connection. This is not how the feature works. The feature is optimized to support busy / loaded servers where the TCP open rate should be minimized. This allows a server to avoid, say opening 2,000 new connections per second, and instead just keep re-using a handful. It’s not a connection pool that pre-opens 10 connections and keeps them around in case they might be needed.

-Bryan
Leela Kalidindi (lkalidin)
Re: Reuse backend connections
June 29, 2018 09:50PM
Hi Bryan,

Thanks a lot for the prompt response.

Is there a such kind of thing to leave the backend connections open forever that can serve any client request?

-Leela



From: Bryan Talbot <[email protected]>
Date: Friday, June 29, 2018 at 12:30 PM
To: "Leela Kalidindi (lkalidin)" <[email protected]>
Cc: HAproxy Mailing Lists <[email protected]>
Subject: Re: Reuse backend connections




On Jun 29, 2018, at Jun 29, 5:11 AM, Leela Kalidindi (lkalidin) <[email protected]<mailto:[email protected]>> wrote:

Hi,

How can I enforce haproxy to reuse limited backend connections regardless of number of client connections? Basically I do not want to recreate backend connection for every front end client.

"HAPROXY_0_BACKEND_HEAD": "\nbackend {backend}\n balance {balance}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n option persist\n http-reuse aggressive\n maxconn 16\n",
"HAPROXY_0_FRONTEND_HEAD": "\nfrontend {backend}\n bind {bindAddr}:{servicePort}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n maxconn 16\n"

I currently have the above configuration, but still backend connections are getting closed when the next client request comes in.

Could someone help me with the issue? Thanks in advance!



I suspect that there is a misunderstanding of what backend connection re-use means. Specifically this portion from the documentation seems to trip people up:




https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#http-reuse

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.

I suspect that in your testing, you send one request, observe TCP state, then send a second request and expect the second request to use the same TCP connection. This is not how the feature works. The feature is optimized to support busy / loaded servers where the TCP open rate should be minimized. This allows a server to avoid, say opening 2,000 new connections per second, and instead just keep re-using a handful. It’s not a connection pool that pre-opens 10 connections and keeps them around in case they might be needed.

-Bryan
Bryan Talbot
Re: Reuse backend connections
June 29, 2018 09:50PM
> On Jun 29, 2018, at Jun 29, 12:38 PM, Leela Kalidindi (lkalidin) <[email protected]> wrote:
>
> Hi Bryan,
>
> Thanks a lot for the prompt response.
>
> Is there a such kind of thing to leave the backend connections open forever that can serve any client request?
>


No, not to my knowledge.

-Bryan
Leela Kalidindi (lkalidin)
Re: Reuse backend connections
June 29, 2018 09:50PM
Bryan,

One another follow-up question - what does persist do? Thanks!

-Leela


From: Bryan Talbot <[email protected]>
Date: Friday, June 29, 2018 at 12:40 PM
To: "Leela Kalidindi (lkalidin)" <[email protected]>
Cc: HAproxy Mailing Lists <[email protected]>
Subject: Re: Reuse backend connections




On Jun 29, 2018, at Jun 29, 12:38 PM, Leela Kalidindi (lkalidin) <[email protected]<mailto:[email protected]>> wrote:

Hi Bryan,

Thanks a lot for the prompt response.

Is there a such kind of thing to leave the backend connections open forever that can serve any client request?



No, not to my knowledge.

-Bryan
Bryan Talbot
Re: Reuse backend connections
June 29, 2018 10:00PM
> On Jun 29, 2018, at Jun 29, 12:42 PM, Leela Kalidindi (lkalidin) <[email protected]> wrote:
>
> Bryan,
>
> One another follow-up question - what does persist do? Thanks!
>


https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#persist <https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#persist>;

is for

https://en.wikipedia.org/wiki/Remote_Desktop_Protocol https://en.wikipedia.org/wiki/Remote_Desktop_Protocol

Is that what you were asking?

-Bryan
Leela Kalidindi (lkalidin)
Re: Reuse backend connections
June 29, 2018 10:00PM
Not for Remote desktop protocol, it is for haproxy backend server with option persist as in
"HAPROXY_0_BACKEND_HEAD": "\nbackend {backend}\n balance {balance}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n option persist\n http-reuse aggressive\n maxconn 16\n",


Thanks!



From: Bryan Talbot <[email protected]>
Date: Friday, June 29, 2018 at 12:47 PM
To: "Leela Kalidindi (lkalidin)" <[email protected]>
Cc: HAproxy Mailing Lists <[email protected]>
Subject: Re: Reuse backend connections




On Jun 29, 2018, at Jun 29, 12:42 PM, Leela Kalidindi (lkalidin) <[email protected]<mailto:[email protected]>> wrote:

Bryan,

One another follow-up question - what does persist do? Thanks!



https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#persist

is for

https://en.wikipedia.org/wiki/Remote_Desktop_Protocol

Is that what you were asking?

-Bryan
Bryan Talbot
Re: Reuse backend connections
June 29, 2018 10:00PM
> On Jun 29, 2018, at Jun 29, 12:50 PM, Leela Kalidindi (lkalidin) <[email protected]> wrote:
>
> Not for Remote desktop protocol, it is for haproxy backend server with option persist as in
> "HAPROXY_0_BACKEND_HEAD": "\nbackend {backend}\n balance {balance}\n mode http\n option httplog\n option forwardfor\n option http-keep-alive\n option persist\n http-reuse aggressive\n maxconn 16\n",
>


You need to stop playing 20 questions on the mailing list and RTFM already.

https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#option%20persist <https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#option persist>

-Bryan
Sorry, only registered users may post in this forum.

Click here to login