Mailing List Archive

Re(2): [mod_backhand-users] mod_backhand and mod_perl
>Bob Foster wrote:
>> It's a application which has grown awkward
>> with age. The way the url is stored in the database and then handled by
>> our perl scripts doesn't like the url getting passed to port 8080.
>We're
>> in the process of figuring out what to do to make everything work with
>> mod_perl being the backend.
>
>theo@omniti.com wrote:
>BTW, I would wager money that backhand can make that problem disappear.
>It
>doesn't do any URL modification ala mod_proxy/mod_rewrite.
>
>Though mod_backhand doesn't amke it trivial to set it up as a proxy only
>(frontend->backend) on the same machine, it is _much_ more efficient than
>mod_proxy (due to the restrictions placed on you -- that frakly should
>inhibit
>you in any way).
>
>If you have only one machine, and you ran Apache/mod_backhand on the front
>interface and Apache/mod_perl on the 127.0.0.1 or backend interface, you
>can
>serve GIF's and static content of the mod_backhand and have it proxy
>mod_perl
>content to the backend instance transparently.

This is what I'd like to try first! However, after spending several hours
reading the FAQ and other documentation, and trying a bunch of things, I
realize that I'm going to need more help.

I established the mod_perl backend with the command:
Listen 127.0.0.1:8080 Is this the correct way to do that? I can
run perl-status from a browser on this same box and see it fine.

I added the following on the mod_backhand frontend:
<Directory /cgi-bin/>
Backhand HTTPRedirectToIP 127.0.0.1:8080
</Directory>
This MUST be wrong but it was my best guess. NOTHING ever gets redirected
to the backend.
>
>The advantage of this over mod_proxy is that even if you have Keep Alives
>disabled on the front end (as most high traffic Apache installations are
>forced to), mod_backhand will "upgrde" the HTTP session to use Keep
>Alives and
>keep a connection pool to the backend instances. Much.. much.. much..
>faster.
>
>Becuase mod_backhand does no URL rewriting (not even port info), the
>mod_perl
>instance can actually serve content as if it is listening on the external
>interface; the remote IP and URL will be preserved transparently :-)
>
This sounds great if I can get it to work. Your help is greatly
appreciated!

Bob Foster
System Administrator
Dissemination, Inc.
Hotresponse.com
(541) 617-5021
bob@hotresponse.com
Re(2): [mod_backhand-users] mod_backhand and mod_perl [ In reply to ]
Hi Theo,

Thanks for the information. I finally have it working as advertised and I
think that it will be extremely valuable for us. THANK YOU! THANK YOU!
THANK YOU!

Some comments follow.

theo@omniti.com writes:
>
> The Backhand HTTPRedirectToIP 127.0.0.1:8080 will not work. That
>actually
>sends a HTTP redirect! Also, it doesn't take an argument. So it will
>redirect the user (_not_ proxy them) to the host's IP address. This isn't
>what you want.
>
>Here is how the hack for single host accelerating works:
>
> (1) You ned to run a mod_perl instance without mod_backhand enabled on a
>private interface or the loopback interface (127.0.0.1 is fine). If you
>want
>to put it on port 8080, that is fine, but I prefer to put it on the same
>port
>as my externally accessible web server (80) it eliminates many
>complications.
>So a "Listen 127.0.0.1:80" in the mod_perl httpd.conf is what you want.

I tried this and it didn't work until after I did (2) since then I had 2
instances of Apache trying to listen (apparently exclusively) on the same
port.
________________________________________________
>
> (2) You want to run a lean and mean apache with only the modules you
>need
>(not mod_perl) on the front end listening to the external interface on
>port
>80. I put a entry on all of my /etc/hosts files (on all my machines) that
>aliases "myip" to the machines IP address. In your external apache
>httpd.conf, you can put Listen myip:80

This is nice!
_______________________________________________
>
> (3) Configure your frontend webserver to up the TCP buffers (to
>accelerate
>things a little). To do this add "SendBufferSize x" to your external
>Apache
>httpd.conf (x is usually 65536 or 131072).

Done.
>
_______________________________________________
>
> (4) Now for the hack. mod_backhand will only redirect to its peers (or
>to
>itself). So, you need to convince mod_backhand that _itself_ is
>127.0.0.1.
>So, in your external httpd.conf file, instead of the normal
>"MulticastStats
>225.220.221.20:4445,1", put "MulticastStats 127.0.0.1
>225.220.221.20:4445,1"
>This will tell the local mod_backhand instance to advertise itself as
>127.0.0.1. [.if you use a different multicast or broadcast address, that is
>fine] To verify that it is working, visit /backhand/ and verify that
>there is
>one machine and its IP is 127.0.0.1 and its port is 80.

Here's a bit of my httpd.conf:

<Directory "/cgi-bin">
AllowOverride None
Options ExecCGI
Order allow,deny
Allow from all
BackhandSelfRedirect On
Backhand byAge
#Backhand byRandom
# If I add the line above, when I first start apache some of my requests
are handled by
the frontend.
#Backhand byLogWindow
# If I add the line above, it stops sending anything to the backend.
#Backhand byCPU
# If I add the line above, the child process faults every time with this
message
# [notice] child pid 6354 exit signal Segmentation fault (11)
</Directory>

When I add additional mod_backhand computers to this setup, how should I
change this configuration?

<IfModule mod_backhand.c>
UnixSocketDir /usr/local/apache/backhand
MulticastStats 127.0.0.1 225.44.73.20:4445,1
AcceptStats 208.44.73.0/27 # This works. I hope it's right. We use
208.44.73.2 through 30

<Location "/backhand/">
SetHandler backhand-handler
</Location>

</IfModule>

My only comment for the broadcast/multicast section is that the
documentation needs some fleshing out for folks like me who don't
understand this aspect of networking well. I will try to write up my
assumptions on what should be said here and after you review/correct them,
you may want to include them in "Help: configuring mod_backhand."
_______________________________________________
>
> (5) Tell mod_backhand to proxy to the best server _even if it is the
>local
>machine_. To do this, add the line: "BackhandSelfRedirect On"
>
>Now, assuming you use the "Backhand" directives for only your mod_perl
>scripts, mod_backhand will not activate for all other content (letting the
>external apache answer) and proxy to itself (at 127.0.0.1:80) for mod_perl
>content.
>
>Also, be sure to turn on KeepAlives on the mod_perl server! You will no
>longer run out of children and mod_backhand will keep pools of open
>connections so that you don't have to reconnect for every request.

Done and working.

Thanks again! I'm sure that I'll have more questions shortly!

Bob Foster
System Administrator
Dissemination, Inc.
Hotresponse.com
(541) 617-5021
bfoster@hotresponse.com