Magento Site Performance Optimization
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Chapter 2<br />
The keepAlive and max processes<br />
In this second round for optimizing Apache2, we will use the keepAlive module,<br />
which authorizes to keep a connection alive longer than usual. As such, our server<br />
will not deal with opening and closing the TCP connection as often as before. In<br />
order to do so, you have to again open the .htaccess file at the root directory of your<br />
<strong>Magento</strong> and add the following code:<br />
KeepAlive On<br />
MaxKeepAliveRequests 100<br />
KeepAliveTimeout 15<br />
Activate the corresponding module and restart the Apache service using the<br />
following commands:<br />
sudo a2enmod header<br />
sudo /etc/init.d/apache2 restart<br />
We will continue to optimize our Apache2 server by reducing the number of processes<br />
it is allowed to create in our server. The first thing is to determine how much memory<br />
a process needs to run. In order to discover this value, you can simply run a test using<br />
Apache Benchmark and run the following command on your host server:<br />
$ top<br />
The preceding command will show you the running processes on your server and<br />
the memory that each process will occupy.<br />
In our case, the Apache2 processes require 42 MB of memory while under charge<br />
and we have 2048 MB of memory available. As we have other services running on<br />
your server (MySQL and so on), we cannot dedicate all our memory to Apache2. We<br />
choose to dedicate 1 GB. So, we have divided 1048 MB of memory by 42 MB, which<br />
gives us almost 25. This means that Apache2 can create 25 processes, which each<br />
requiring 42 MB of RAM before jamming the other services on the server. To set the<br />
new value of the max, add the following to the .htaccess file:<br />
<br />
StartServers 25<br />
MinSpareServers 25<br />
MaxSpareServers 35<br />
ServerLimit 256<br />
MaxClients 256<br />
MaxRequestsPerChild 10000<br />
<br />
[ 23 ]<br />
www.it-ebooks.info