LVS
lvs-users
Google
 
Web LinuxVirtualServer.org

RE: apache + ldirector + heartbeat

To: "'LinuxVirtualServer.org users mailing list.'" <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
Subject: RE: apache + ldirector + heartbeat
From: "Mark" <msalists@xxxxxxx>
Date: Wed, 15 Feb 2006 10:03:23 -0800
I've done something similar. However, I use my own session handling, so I am 
not sure if this will work with the standard apache
session handling:

The original request comes in (e.g. mysite.com)
Ldirector forwards to one of the two real servers (round-robin, etc).

If a real server processes the request, all subsequent links that are generated 
in the response have a special URL that mark which
server generated it, for example:
Instead of "mysite.com/page2" I use "mysite.com/rs1/page2" if RealServer one 
processed the request and "mysite.com/rs2/page" if
RealServer2 processed the request.

When the next request comes back from a subsequent link "mysite.com/rs1/page2", 
ldirector forwards again to one of the two nodes. It
may not be the same node that your session was created on, so here is the main 
fix for this problem: I use mod_rewrite in order to
figure out which host is responsible and forward it as a proxy rewrite rule: 
        RewriteCond %{REQUEST_URI}   ^/rs1/
        RewriteRule ^/rs1/(.*)  http://vpn.ip.for.rs1/$1 
[P,L,E=ORIG_HTTP_HOST:%{HTTP_HOST}]

        RewriteCond %{REQUEST_URI}   ^/rs2/
        RewriteRule ^/rs2/(.*)  http://vpn.ip.for.rs2/$1 
[P,L,E=ORIG_HTTP_HOST:%{HTTP_HOST}]

        RequestHeader add ORIG_HTTP_HOST %{ORIG_HTTP_HOST}e

You can use the environment variables in order to pass on information from the 
original HTTP header that otherwise would get lost by
of the proxy (original hostname, client IP, etc etc) and retrieve it in your 
webapp by analyzing the HTTP header.

This requires that you modify your webapp a little bit in order to handle the 
special base URL and extracting information from
different fields of the header, but in my case I was lucky - the required 
modifications where quite limited and easy to do.

The disadvantage is that you bind a session to one particular node, so you lose 
the failover feature. If the node that handles the
session goes down, you can not failover to one of the others. But at least 
requests that come in as a new session will still be
directed to one of the currently active servers.

I've used this over a few months now and it works fine - no problems so far.

Has anybody else done something similar? Any commments on this approach?

Thanks,

MARK



> -----Original Message-----
> From: lvs-users-bounces@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:lvs-users-bounces@xxxxxxxxxxxxxxxxxxxxxx] On Behalf 
> Of Christophe Mailhebuau
> Sent: Wednesday, February 15, 2006 7:13 AM
> To: LVS
> Subject: apache + ldirector + heartbeat
> 
> 
> Hi,
> 
> I need to install ldirector + heartbeat for 2 servers
> 
>     ---       vip---
>     |        |
> [srv1]     [srv2]
> 
> Do you kown a howto to configure it with persistent connexion ?
> 
> -- 
> Cordialement,       
> Christophe Mailhebuau  - http://www.justlinux.org
> Administrateur systèmes et réseaux GNU/Linux
> GPG: 1024D/75B07F8D: BD18 2D01 D954 A339 E35B 9EA1 4240 0410 75B0 7F8D
> _______________________________________________
> LinuxVirtualServer.org mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
> Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
> or go to http://www.in-addr.de/mailman/listinfo/lvs-users
> 


<Prev in Thread] Current Thread [Next in Thread>