Welcome! Log In Create A New Profile

Advanced

how to decide a http transaction is commpleted

Posted by mark green 
mark green
how to decide a http transaction is commpleted
August 01, 2012 01:20PM
Hi,

when haproxy forward a http request to server, and received response
from backend server,
forward it to client, will haproxy receive another request on the same
socket before this response is forwarded to client?
and, how to decide this response is completely forwarded to client?

Thanks
Baptiste
Re: how to decide a http transaction is commpleted
August 02, 2012 09:50AM
On Wed, Aug 1, 2012 at 1:13 PM, mark green <[email protected]> wrote:
> Hi,
>
> when haproxy forward a http request to server, and received response from
> backend server,
> forward it to client, will haproxy receive another request on the same
> socket before this response is forwarded to client?
> and, how to decide this response is completely forwarded to client?
>
> Thanks

Hi Mark,

It depends on the options you have enabled on HAProxy, and in some
cases, on the server itself.
The options I'll speak about are "http-server-close" and "httpclose".
If none of them are set in your configuration, then you're in the
tunnel mode, which means HAProxy will analyze the first request then
maintain opened a tunnel between the client and the server, where
every data being transferred won't be analyzed.
In this mode, this is up to the server to decide when to close the connection.

If you setup httpclose, then HAProxy will close the TCP connection
after each request for both client and server, announcing the HTTP
header "Connection: close".

If you setup http-server-close, then HAProxy will use HTTP keep alive
to maintain the TCP connection opened on the client side only. On the
server side, a new TCP connection will be opened per each HTTP
requests.

I don't understand your last question.
Could you be clearer?

Baptiste
mark green
Re: how to decide a http transaction is commpleted
August 02, 2012 10:40AM
Hi, Baptiste

Thanks for your explanation.

the second question is from this:
I want to change the current behavior of connection between haproxy and
backend servers as following:
pre-setup some persistent connections between haproxy and backend servers.
such as: connection1(haproxy---->server1), connection2(haproxy--->server2)
and,
1, when a client1's request incoming, dispatch it to connection1 , forward
the request to server1, and when server1's
response is totally forwarded to client1 by haproxy, connection1 is freed;
then if clientN's request incoming,
dispatch it to connection1. that is reusing the connection.

clinet1----------->[ ]------------------>server1
client2----------->| |
....... | haproxy|
clientn----------->[ ]------------------->server2

so, I should know when the response is totally forwarded so that I can free
the connection between haproxy and server


Mark

On Thu, Aug 2, 2012 at 3:46 PM, Baptiste <[email protected]> wrote:

> On Wed, Aug 1, 2012 at 1:13 PM, mark green <[email protected]>
> wrote:
> > Hi,
> >
> > when haproxy forward a http request to server, and received response
> from
> > backend server,
> > forward it to client, will haproxy receive another request on the same
> > socket before this response is forwarded to client?
> > and, how to decide this response is completely forwarded to client?
> >
> > Thanks
>
> Hi Mark,
>
> It depends on the options you have enabled on HAProxy, and in some
> cases, on the server itself.
> The options I'll speak about are "http-server-close" and "httpclose".
> If none of them are set in your configuration, then you're in the
> tunnel mode, which means HAProxy will analyze the first request then
> maintain opened a tunnel between the client and the server, where
> every data being transferred won't be analyzed.
> In this mode, this is up to the server to decide when to close the
> connection.
>
> If you setup httpclose, then HAProxy will close the TCP connection
> after each request for both client and server, announcing the HTTP
> header "Connection: close".
>
> If you setup http-server-close, then HAProxy will use HTTP keep alive
> to maintain the TCP connection opened on the client side only. On the
> server side, a new TCP connection will be opened per each HTTP
> requests.
>
> I don't understand your last question.
> Could you be clearer?
>
> Baptiste
>
Baptiste
Re: how to decide a http transaction is commpleted
August 02, 2012 02:10PM
On Thu, Aug 2, 2012 at 10:34 AM, mark green <[email protected]> wrote:
> Hi, Baptiste
>
> Thanks for your explanation.
>
> the second question is from this:
> I want to change the current behavior of connection between haproxy and
> backend servers as following:
> pre-setup some persistent connections between haproxy and backend servers.
> such as: connection1(haproxy---->server1), connection2(haproxy--->server2)
> and,
> 1, when a client1's request incoming, dispatch it to connection1 , forward
> the request to server1, and when server1's
> response is totally forwarded to client1 by haproxy, connection1 is freed;
> then if clientN's request incoming,
> dispatch it to connection1. that is reusing the connection.
>
> clinet1----------->[ ]------------------>server1
> client2----------->| |
> ...... | haproxy|
> clientn----------->[ ]------------------->server2
>
> so, I should know when the response is totally forwarded so that I can free
> the connection between haproxy and server
>
>
> Mark

Hi,

You can't pre-allocate connection with HAProxy.
and what you're describing is not doable.
Saying that, HAProxy does TCP buffering, it reads responses at server
speed and answers at client speed, releasing the server connection
once all the data have been received (oof course, only if the server
sends data faster than the client can read it).
You hide client side latency on your server. That's why you'll see you
have 300 connections on the frontend and only 10 on the backend (for
exemple), it would mean that your sever latency is in average 10 time
lower than the client one.

If you want to use server 1 only untill it is saturated, there is a
new LB algorithm available: "balance first".

cheers
Sorry, only registered users may post in this forum.

Click here to login