In the previous part of this tutorial, I talked about basic MediaWiki tweaks that can have a significant effect on your website’s performance. However, sometimes, tweaking MediaWiki alone does not bear desirable fruit.
MediaWiki is a very complex application and it is heavy on available computing resources. Often times, it is Apache server that chokes available memory and causes the entire MediaWiki installation to crash. It is important to properly configure Apache if you wish to run a largish MediaWiki website.
Apache functioning can be tuned using a number of directives. You can set the value of these directives either in httpd.conf file or through the interface provided by your VPS host. See: How to find location of httpd.conf
MaxClients
This perhaps is the most crucial among all the directives that can be set for Apache. You have to set just the right value for MaxClients because both too high or too low values cause problems.
This directive sets the limit on the number of simultaneous requests that will be served. The maximum value of MaxClients is limited by another directive called ServerLimit.
Well, many people misunderstand what MaxClient is for. Some people think that this defines the number of maximum simultaneous connections that Apache will allow and they set it to a value equal to or a bit higher than the maximum number of active users that are there on their website at a given moment (number of active users can be known using Google Analytics)
Tips for increasing MediaWiki performance.But the truth is that MaxClient is the number of simultaneous requests that Apache can serve. A request is made when a user wants to view a page on your website. Let’s assume that there are 100 active users on your website at this moment. That does not necessarily mean that there would also be 100 simultaneous requests! When user gets the desired page; s/he goes through it for sometime before clicking on another link and request another page.
My MediaWiki website serves about two million pages per month and there are about 70 to 80 active users at any given moment (at peak it is over 110). I have set MaxClient to 50.
StartServers
This directive is to set the number of child processes with which Apache will make a beginning. If you have a high load website, then it is a good idea to increase the default value of 5. The default value of 5 will launch just 5 child processes and therefore startup of your Apache server could be slow because a much higher number of requests may be made at startup.
This directive is, however, of significance only if Apache is restarted frequently (for example, during tweaking phase!)
I keep it at 10.
MinSpareServers and MaxSpareServers
These directives control the minimum and maximum number of child server processes to be kept in spare at any given moment. Let’s assume that the MinSpareServers value is 5. So, Apache will create new child process if only 5 idle child processes are left. If you keep MinSpareServers too low (e.g. 2) and then suddenly 10 requests come in –Apache won’t be able to handle them and will have to queue up 8 requests while creating new child processes. Creating child processes is expensive stuff –so, it is better to keep an appropriate number of child servers in stock to handle a sudden inflow of large number of requests.
MaxSpareServers should not be set too high because each child process takes up memory and having too many idle spare servers is nothing but waste of memory.
MaxRequestsPerChild
This directive tells Apache as to the maximum number of requests a child process will handle before dying. By default, it is set to zero –which means the child process will never die and keep serving requests.
Sometimes, unexpected problems, like memory leaks, do happen in child processes and that can make their functioning slow. Therefore, it is a good idea to kill child process after having served a set number of requests.
One should not set MaxRequestsPerChild too low because it will cause frequent killing of processes and creation of new processes. Creation of new processes is, as I said before, an expensive task.
KeepAlive and KeepAliveTimeout
If KeepAlive is set to be on –it allows several requests to be sent on the same TCP connection. It is particularly important to keep this directive on if the pages you are serving are made up of a large number of components (like images, css, js files). If you will switch this directive off –the TCP connection made between Apache and the requesting client will be reset on every request.
KeepAliveTimeOut defines the number of seconds for which the request handling process will wait for a new request over the same TCP connection. After expiry of this period the connection is automatically closed. It is better to keep this value around 2 or 3 seconds. You can even test a value of 1 and see how your Apache installation works!
I keep KeepAlive as on and KeepAliveTimeout set to 1.
Now that we know a few tweaks about MediaWiki and Apache, in the next part of this tutorial, I will talk a bit about MySQL tweaking.
Please comment to let us know if you have more tips/tweaks to enhance performance of Apache web server. Thanks!
Leave a Reply