Apache Tuning
Filed Under
Linux at 1st January 2009 1:58 by
Danny
Thread Manager
The modular nature of Apache has the ability to switch and replace modules interchangeably. In Apache 2 there is a new thread processing manager. Whilst it brings true multi threading to Apache, it increased the overhead and complexity of the web server.
To decrease the resources used and troubleshooting Apache errors such as
Cannot allocate memory: apr_thread_create: unable to create worker thread
use the old style module similar in Apache 1.3 which is safe for non thread safe modules.
To install this module in Ubuntu 8.04 use the command:
apt-get install apache2-mpm-prefork
Apache Connection Settings
Apache can control the number of clients connected to a website as well as how many processes it spawns for each site ready to handle a web request. These are all controlled in the apache2.conf file which, under Ubuntu 8.04 is located in
/etc/apache/
The main entries can toggle the different settings threads are:
- StartServers – How many child threads have to be created before Apache starts accepting client requests e.g to view a website
- MinSpareServers – The number of minimum idle threads ready to take requests
- MaxSpareServers – Maximum number of idle threads to create
- ServerLimit – Not sure what this is but it’s very important
- MaxClients – Maximum number of simultaneous connected web viewers
- MaxRequestsPerChild – The largest number of requests to a child thread before it dies. Creating a new child is expesnive in terms of resources
A guide for the “MaxClients” directive is the amount of RAM dedicated to Apache. The formula is
amount of RAM (MB) / 5
It’s divisable by 5 because it’s estimated to that each web request takes about 5MB of RAM.
Apache Benchmark
Apache has a benchmarking utility which are usually included in Linux distributions called Apache Benchmark or AB for short. It allows people to simulate web access by sending requests to the server as if some one was visiting a site. A useful example of this utility is:
ab -kc 10 -t 30 http://localhost/
where:
- ab – the benchmark program command
- -kc 10 – the number of simultaneous connections open
- -t – is how long to perform the benchmark for in seconds
- http://localhost/ – the website address
Mac Geekery on Apache Benchmark
Shabuz Lamp website
About Danny
I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog.
Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise.
Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school.
View all posts by Danny →
This entry was posted in
Linux and tagged
apache 2,
benchmark,
Linux,
linux distributions,
memory,
thread manager,
threads,
web access,
web request,
web server. Bookmark the
permalink.