| Apache httpd config to compete with nginx and lighttpd [message #94387] |
Thu, 19 January 2012 21:42  |
|
Here is the start of a configuration that will pass the 50 user test from loadimpact.com with no sweat with a heavy php application like Drupal 7. This is from a CentOS base install and will not work for SSL or VirtualHosts as is. I will add that later. I want the community to try this out and let me know what they think in general.
The idea is that httpd-light acts as lighttpd or nginx and servers only static content. It directs php requests to the httpd config.
Here it is!:
#Install the LAMP components
yum -y install httpd mysql mysql-server php53 php53-gd php53-pdo php53-mbstring php53-xml php53-mysql
#Create init.d script for httpd-light
cp /etc/init.d/httpd /etc/init.d/httpd-light
sed -i 's/httpd Startup/httpd-light Startup/g' /etc/init.d/httpd-light
sed -i 's/processname: httpd/processname: httpd-light/g' /etc/init.d/httpd-light
sed -i 's,/etc/httpd/conf/httpd.conf,/etc/httpd-light/conf/httpd.co nf,g' /etc/init.d/httpd-light
sed -i 's,/etc/sysconfig/httpd,/etc/sysconfig/httpd-light,g' /etc/init.d/httpd-light
sed -i 's,/var/run/httpd.pid,/var/run/httpd-light.pid,g' /etc/init.d/httpd-light
sed -i 's,prog=httpd,prog=httpd-light,g' /etc/init.d/httpd-light
sed -i 's,/var/lock/subsys/httpd,/var/lock/subsys/httpd-light,g' /etc/init.d/httpd-light
sed -i '/STOP_TIMEOUT=/ a\
OPTIONS="-f /etc/httpd-light/conf/httpd.conf"' /etc/init.d/httpd-light
#Create httpd-light configuration directory and configure httpd-light
cp -r /etc/httpd/ /etc/httpd-light
sed -i 's,ServerRoot "/etc/httpd",ServerRoot "/etc/httpd-light",g' /etc/httpd-light/conf/httpd.conf
sed -i 's,PidFile run/httpd.pid,PidFile run/httpd-light.pid,g' /etc/httpd-light/conf/httpd.conf
#Create new file /etc/httpd-light/conf.d/reverseproxy.conf
echo LoadModule proxy_module modules/mod_proxy.so> /etc/httpd-light/conf.d/reverseproxy.conf
echo ProxyPreserveHost on>> /etc/httpd-light/conf.d/reverseproxy.conf
echo ProxyPassReverse / http://127.0.0.1:8080/>> /etc/httpd-light/conf.d/reverseproxy.conf
echo RewriteEngine on>> /etc/httpd-light/conf.d/reverseproxy.conf
echo RewriteCond %{REQUEST_URI} .*\\.\(php\)$>> /etc/httpd-light/conf.d/reverseproxy.conf
echo RewriteRule ^/\(.*\) http://127.0.0.1:8080/\$1 [P]>> /etc/httpd-light/conf.d/reverseproxy.conf
#No need for php on the httpd-light
rm -f /etc/httpd-light/conf.d/php.conf
#Configure httpd config
sed -i 's/Listen 80/Listen 127.0.0.1:8080/g' /etc/httpd/conf/httpd.conf
#Configure httpd for 10 max clients (uses about X MB)
sed -i 's/ServerLimit 256/ServerLimit 10/g' /etc/httpd/conf/httpd.conf
sed -i 's/MaxClients 256/MaxClients 10/g' /etc/httpd/conf/httpd.conf
#invalidate the worker config in the main httpd.conf for httpd-light
sed -i 's/<IfModule worker.c>/<IfModule worker-old.c>/g' /etc/httpd-light/conf/httpd.conf
#Configure httpd-light for worker max clients (uses about X MB)
sed 's,#HTTPD=/usr/sbin/httpd.worker,HTTPD=/usr/sbin/httpd.worke r,g' /etc/sysconfig/httpd > /etc/sysconfig/httpd-light
echo "<IfModule worker.c>
ThreadLimit 1024
StartServers 2
MaxClients 2048
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 1024
MaxRequestsPerChild 0
</IfModule>"> /etc/httpd-light/conf.d/worker.conf
chkconfig httpd on
chkconfig httpd-light on
chkconfig mysqld on
service httpd start
service httpd-light start
service mysqld start
https://www.mercuryvps.com
HyperVM Xen VPS hosting
[Updated on: Wed, 25 January 2012 21:06] Report message to a moderator
|
|
|
|
|
|
|
|
| Re: Apache httpd config to compete with nginx and lighttpd [message #94571 is a reply to message #94483] |
Wed, 25 January 2012 21:09   |
|
Updated to worker. I still need to run through it a few times.
Neat things I will add.
Multiple php pools, for instance - httpd-php-free, httpd-php-premium, httpd-php-exclusive1.
Basically this config should make it possible to have some virtual hosts use the free, others use premium, and even have exclusive pools. Also I want to add a php6 and maybe php5X choices to the mix.
Next thing I post should be the SSL and then the virtual hosts. It may take me a bit to get that working well.
https://www.mercuryvps.com
HyperVM Xen VPS hosting
[Updated on: Wed, 25 January 2012 21:10] Report message to a moderator
|
|
|
|
|
| Re: Apache httpd config to compete with nginx and lighttpd [message #94584 is a reply to message #94583] |
Thu, 26 January 2012 10:15   |
|
I want to have this thoroughly working as standalone first. I then MIGHT add it as a hidden driver, where a file flag must be set to use. This will allow great testing, and make sure that a person does not just choose it without having to know that it is still in testing.
So please test out this config as I go along to make sure it is sane and will do what I want. This is set up to work very well on 512 MB. If you set up on a 1GB,you should be able to double the httpd-light MaxClients and also double the httpd MaxClients.
Any thoughts on the separate php pools?
https://www.mercuryvps.com
HyperVM Xen VPS hosting
|
|
|
| Re: Apache httpd config to compete with nginx and lighttpd [message #94642 is a reply to message #94584] |
Sat, 28 January 2012 21:00   |
|
This is purely for show and for people to have a little peak at what this configuration will be able to do. This can currently run on 256 MB of memory but could go over just a little bit, so have some swap if you test some heavy php. Also you could manually lower the MaxClients for the httpd prefork from 10 to 5. The httpd-light will hold over 2000 concurrent connections:)
How to test...
Install Kloxo as normal.
Download this file:
https://raw.github.com/shazarlx/kloxo/2609820317b6d4fa89945c 6b2bc642b284f78790/kloxo/httpdocs/lib/domain/web/driver/web_ _httpdlightlib.php
Copy it to /usr/local/lxlabs/kloxo/httpdocs/lib/domain/web/driver/
Backup the old web__apachelib.php and rename web__httpdlightlib.php to web__apachelib.php
Add a domain under admin.
Manually restart the httpd and httpd-light services as I haven't added that part yet.
Add some static files and some php files and test it.
Stop httpd and you will notice php files will fail.
Stop httpd-light and all requests will fail.
I've not tested much else and I know not much else will work.
This is very early and I plan to make a lot of changes in how the install and configuration goes. The way I did this rides on the way the current driver is written.
https://www.mercuryvps.com
HyperVM Xen VPS hosting
[Updated on: Sat, 28 January 2012 21:02] Report message to a moderator
|
|
|
|
|
| Re: Apache httpd config to compete with nginx and lighttpd [message #94707 is a reply to message #94704] |
Tue, 31 January 2012 09:09   |
|
Spacedust - from what you've shown in other threads, you don't know how to configure Apache. Of course if you have mod_php with MaxClients set to 256 you will crash your system with almost any amount of memory. Each mod_php apache process takes up at least 30 MB. Each process supports a single concurrent connection/request. This configuration that I have presented does the same thing that lighttpd and nginx does but is pure apache. Apache is THE webserver of choice bar none.
If you check out that file that I linked to you will be able to add a domain from Kloxo and a virtual host will be made. I've already figured out a better way to consolidate the configuration though. I would like you to test it.
Benchmarks with ab are completely useless. I have been using loadimpact.com against a Drupal 7 install. It is very php intensive and comes default with a ton of objects that need to load on every page. With 256 MB of memory it passes the 50 concurrent users without a problem. The default apache config would crash your system almost instantly if you kept it at 256 MaxClients. If you tweaked it to not crash (MaxClients 5), the 10 clients part of the test would be slow and you would most likely not get passed the 20 mark.
Regarding other webservers, I have absolutely no interest in anything other than apache.
Please feel free to use this as a chance to run the benchmarks. If you use the ab application to do it, it proves absolutely nothing as it only does the single page you request and not the linked objects and also if you use it locally, you have no Internet latency. ab ends up being more CPU intensive when run locally and shows absolutely nothing about real world performance. I use ab to max out my connections to review the full memory usage though.
https://www.mercuryvps.com
HyperVM Xen VPS hosting
[Updated on: Tue, 31 January 2012 09:12] Report message to a moderator
|
|
|
|
|
|
| Re: Apache httpd config to compete with nginx and lighttpd [message #94943 is a reply to message #94841] |
Thu, 09 February 2012 10:24   |
|
I just revamped the code I am working on for this and missed a little mistake. Just wanted to warn anyone who was trying to test it. I think I will have a pretty good working driver ready sometime this weekend. I rewrote it in a way that should allow most of the existing apache driver code to still do it's tasks and work with my changes. I still plan to revamp the entire driver. I think that if I go over every single piece of it, I can better provide bug fixes in the future.
https://www.mercuryvps.com
HyperVM Xen VPS hosting
|
|
|
|