On 30.12.2010 15:50, Igor GaliÄ wrote:
----- "Joost de Heer"<joost@xxxxxxxxxxxxxxxxx> wrote:On 29-12-2010 20:00, Michelle Konzack wrote:Hello *, On my gateway I use a bunch of files (currently 1782) likeWhy a single file for each of these?----8<------------------------------------------------------ <VirtualHost 88.168.69.36:80> ServerName $HOST_NAME ProxyRequests offThis is default.ProxyVia onSet this in server context.ProxyPass / http://$HOST_IP/ ProxyPassReverse / http://$HOST_IP/ ProxyPreserveHost onSet 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 ofapache2.2so, 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@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx