I quite like the widely covered thick/thin model for apache/mod_perl configeration, and I've been doing a little playing to try to find out if its possible to do something similar using port based virtual hosts. Whilst I doubt that it will be as beneficial as running seperate instances of apache, and don't know enough to comment, it looks like it could be usefull for my development environment.
# Minimal Reference Example
ServerRoot "/home/user/httpd"
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
LoadModule perl_module modules/mod_perl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
DocumentRoot /home/user/httpd/htdocs
ServerAdmin you@example.com
DirectoryIndex index.html
DefaultType text/plain
TypesConfig conf/mime.types
HostnameLookups Off
ServerTokens Full
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent
# Now for virtual servers
Listen 7188
Listen 7180
# First the 'Thin' Virtual Server
CustomLog logs/access.log common
ErrorLog logs/error_log
LogLevel warn
ProxyRequests Off
Order deny,allow
Allow from all
ProxyPass /scripts http://localhost:7180/
ProxyPassReverse /scripts http://localhost:7180/
# Now for the mod_perl enabled one
ErrorLog logs/perl_error_log
LogLevel warn
Include conf/mod_perl_app.conf
where mod_perl_app.conf contains:
PerlModule MyApache::PrintEnv2
And PrintEnv2 is the printenv example off of the mod_perl website. Whilst I haven't given it a proper shake down yet, intially, as far as my linux based development environment goes ( the ports and directories might give this away ) it looks promising.
How did your think/thin Apache2 experiment go? Google only found this journal entry, where have you seen this technique used before?
Re:Thick/Thin Good?
lilstevey on 2005-01-18T09:52:18
I can't remember getting too far futher with it to be honest. I've configered Apache 1.3 with the thick/thin setup a couple of times, using either seperate binaries, or two different shell scripts to run two apaches from the same binary ( using DSO's for the relevant modules ) - This is quite heavily documented, but may not be what you are looking for ( perl.apache.org ), along with using squid for the same purpose, although I have an irrational fear of squid, so have never used that configeration.
I seem to remember coming across an issue with the setup used here in that for some reason the request ( in the browser ) would migrate to the backend port, rather than proxy through. It might have been something stupid I was doing though. I have heard that there is a webserver that can be added to the kernal, and configered to serve the static html and images, leaving apache to do the hard work, but i'm not sure if that works on a proxy basis, or on seperate ports/IPs requested from the client.Re:Thick/Thin Good?
ajt on 2005-01-18T10:24:40
I've seen the technique advocated a number of times, either a simple Apache front end or with a dedicated Squid proxy, and the a complex heavy Apache/mod_perl backend. I've never actually tried it myself, hence my interest in your experience.
My feeling was that as Apache shares mod_perl memory so to run Apache/mod_Perl in think/thin you'd need to run two instances rather than two virtual servers in the same instance, though I'd like to be proved wrong.
The kernel server you are think of is called TUX, and is still available, but from what I recall, a well configured Apache2 system on a modern Kernel is almost as fast, and in theory more secure - not being a Kernel module. When I was tinkering about with RedHat Enterprise 3, it definatly had the TUX server in the install options.
Re:Thick/Thin Good?
lilstevey on 2005-01-18T18:06:17
I may be revisiting this area soon, so I'll let you know how I get on. I'm not ready to throw mod_perl 1.9x/2.0RC into production yet, but I'm yet to decide between a fat apache 1.3 and apache 2, or a dual apache 1.3 config.
My gut feel was that I wouldn't save any memory by using the thick thin virtual server config ( though I probably ought to check ), but I'm a bit cautious when it comes to testing, and often have multiple versions of the same mod_perl app running on different apaches on the same physical server - it lets me test upgrades and dependencies, and is very good for team working. By replicating the "feel" of a thick thin environment, my objective was to simulate the app without the hassle of starting and stopping different apaches in x different instances.
Thanks for the link to TUX, although I'll probably heed your advice and leave kernel to do kernel things, and let http take care of its self in application space.Re:Thick/Thin Good?
ajt on 2005-01-18T19:41:46
I'd be very interested in whatever conclusions you reach.