httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Jung <rainer.j...@kippdata.de>
Subject Re: [users@httpd] Searchin better solution as mod_proxy/vhost
Date Thu, 30 Dec 2010 20:20:15 GMT
On 30.12.2010 15:50, Igor Galić wrote:
>
> ----- "Joost de Heer"<joost@sanguis.xs4all.nl>  wrote:
>
>> On 29-12-2010 20:00, Michelle Konzack wrote:
>>> Hello *,
>>>
>>> On my gateway I use a bunch of files (currently 1782) like
>
> Why a single file for each of these?
>
>>> ----8<------------------------------------------------------
>>> <VirtualHost 88.168.69.36:80>
>>>       ServerName          $HOST_NAME
>>>
>>>       ProxyRequests       off
>
> This is default.
>
>>>       ProxyVia            on
>
> Set this in server context.
>
>>>       ProxyPass           / http://$HOST_IP/
>>>       ProxyPassReverse    / http://$HOST_IP/
>>>       ProxyPreserveHost   on
>
> Set this in server context.
>
>>>       <Proxy *>
>>>           Order           deny,allow
>>>           Allow           from all
>>>       </Proxy>
>
> This should be default, unless we're talking Debian...
> http://wiki.apache.org/httpd/DebianDeb0rkification
>
>>>    </VirtualHost>
>>> ----8<------------------------------------------------------
>>>
>>> and it works perfectly, but i disike the memory consumation of
>> apache2.2
>>> so, my question is:
>>>                           How can I do this better?
>
> Before asking such a question, you should ask yourself, *why* does
> it consume so much memory?
> What MPM are you using, what MPM settings do you have. What modules
> do you have loaded, what other than proxying does your server do?
> How much load is on the server, etc...
>
>> With mod_rewrite and rewritemap. It should look something like this
>> (untested):
>>
>> urlmap.txt [textfile]
>> host1		ip1
>> host2		ip2
>> host3		ip3
>> .
>> .
>> .
>>
>> httpd.conf:
>> RewriteEngine On
>> RewriteMap urlmap txt:/path/to/urlmap.txt
>> # Only rewrite if there is a host header
>> RewriteCond %{HTTP_HOST} !^$
>> # Lowercase the hostheader
>> RewriteCond ${lowercase:%{HTTP_HOST}} ^(.+)$
>> # Rewrite only if there is an entry in the urlmap
>> RewriteCond ${urlmap:%1} ^([0-9].*)$
>> RewriteRule /(.*) http://%1/$1 [P,L]
>
> # this should make the rewrite rule more efficient.
>
> RewriteRule ^ http://%1$0 [P,L]
>
> But as a whole I believe mod_rewrite decreases readability. I don't
> think it will do any thing much in terms of reducing memory foot print.
>
> Walking the vhost chain is a core feature and should work efficiently
> out of the box. If it doesn't something's off.
>
> I much prefer mod_macro:
>
> ProxyVia on
> ProxyPreserveHost on
>
> <Macro ProxyVHost $servername $server_ip $remote_ip>
>    <VirtualHost $server_ip:80>
>        ServerName $servername
>        ProxyPass / http://$remote_ip/
>        ProxyPassReverse / http://$remote_ip/
>    </VirtualHost>
> </Macro>
>
> # then you have one line -- not one file! -- per vhost:
>
> Use example.org 88.168.69.36 10.1.42.36
> Use example.net 88.167.70.37 10.2.43.37
> Use example.com 88.166.71.38 10.3.44.38
> Use example.edu 88.165.72.39 10.4.45.39
>
>
> Not sure if the rewrite method, or this method help reduce memory
> foot print, they will definately reduce the effort on startup, etc...
>
> I still think that the memory footprint is caused by something
> entirely unrelated to what you're describing.

One difference will be the pooling of the backend connections. ProxyPass 
defines explicit workers, which are able to do keep-alive and connection 
pooling. mod_rewrite proxy flags without ProxyPass (I think) use the 
default reverse proxy worker, which does neither keep-alive nor 
connection pooling.

So the latter seems more appropriate for backends that are only used 
occasionally with litte load, the explicit configuration via ProxyPass 
seems more appropriate for backends used with high load. I would also 
expect more memory needed for this, but the difference might not be 
substantial.

Regards,

Rainer

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Mime
View raw message