The use of Apache on Windows amongst our enterprise customers is rare, with the majority opting to host the Subversion Apache servers on one of the flavours of Linux.
In the cases where Windows is the Subversion Apache server’s operating system, it is common that Administrators are plagued with overly high memory consumption by the Apache httpd process, leading in extreme cases to the Apache server shutting down.
All subversion binaries for windows only provide 32-bit versions of Apache. Apache on Windows is run as a single process, with child threads that handle the http connections. This means that the total amount of memory available to Apache on Windows is always limited to 2 Gb. Couple this with known memory leaks for Apache modules, and it becomes easy to see why an Apache Subversion server on Windows is likely to die frequently.
Thankfully there are ways to minimise Apache’s memory hemorrhaging and achieve long term uptime for the Subversion server. What follows are some key Apache configuration directives which are optimal for an Apache Subversion server on Windows:
Looking at each of the directives in turn:
KeepAlive On – Allows a connection to be re-used for multiple requests. This results in better performance as there is an overhead associated with establishing new connections.
KeepAliveTimeout 15 – close the connection if no new request occurs after 15 seconds. We can increase this value to improve performance for clients – but doing so will keep child threads tied up for longer.
MaxKeepAliveRequests 500 – each connection is allowed to service up to 500 requests before it is closed.
MaxRequestsPerChild 400 – each child thread is allowed to service 400 connections before it is killed.
MaxMemFree 8000 – each thread can keep 8Mb of free memory before it is forced to release it.
The strategy behind the above settings is to limit the life of each thread, so that if there are memory leaks, the memory gets released when the threads are killed.
Depending on the exact distribution of Apache Subversion installed, it is often the case that the default Apache configuration allows each thread to live forever and can keep an unlimited amount of free memory – “not the best”.
After applying the above settings, each thread will service MaxRequestsPerChild * MaxKeepAliveRequests = 200000 requests before being killed, and each thread is forced to relinquish any free memory once they have accumulated 8Mb.
MaxKeepAliveRequests and MaxRequestsPerChild may need to be fine tuned, depending on how users report performance and how much memory is consumed by Apache, the aim being to find an acceptable compromise between data transfer speed and Apache memory size.