Improve performance by serving static files with a lightweight HTTP server


Feb 11, 2004
quentin submitted a new Article:

Improve performance by serving static files with a lightweight HTTP server

This article is of interest to you if:
- You run your site(s) on a dedicated server.
- You run a Un*x system.
- You run Apache as your HTTP server.
- You have a lot of traffic, are experiencing performance issues, or anticipating them.

In this article I will explain how to install Mathopd as a static file/image serving HTTP server, and why it will be beneficial.

Understanding Apache's Forking system

For you to understand why what we are going to do is useful, it is first necessary that you understand (from a high level) how apache works.

Basically, Apache handles a request with a process (known as a child). Each simultaneous request is handled by a different process. Therefore, the more simultaneous connections to your server are open, the more child processes Apache will create to handle these connections.
This is why, when you run the command top (or ps), you can see a number of httpd processes running on your server:


If you look into your apache's configuration file (httpd.conf), a number of parameters allow you to manipulate the way this process generation works:

MaxClients defines the max number of child processes that can be created by apache (hence the amx number of simultaneous requests served).
StartServers defines the number of processes that are created by default when apache is started.

Apache doesn't wait for incoming requests to create the processes that will treat them. This creation process takes time, and this would result in bad response times. Instead, it creates the processes in advance, and keeps them running waiting for a new connection. The variables MinSpareServers and MaxSpareServers define the min and max numbers of processes that must be created and waiting for incoming connections.

So the basic life of a child process is:

1) Apache creates the child process because there are less than MinSpareServers waiting for connections.
2) The child process waits for a connection.
3) A connection is made. The child process answers the request.
4) The child process goes back to the wait status to serve a new request.

Processes can be deleted for multiple reasons, for example because there are more than MaxSpareServers waiting, or more than MaxRequestsPerChild requests were already served by this process.

KeepAlive is a mechanism implemented in apache (and many...

Read more about this article here...
Last edited by a moderator:


Dec 21, 2006
Lighttpd is also a good lightweight server. Many sites have also used it to replace Apache for dynamic content


May 15, 2007
Lighttpd is the best choice btw and its better to use lighttpd for dynamic and static content.

Also it works on windows...


Jun 30, 2004
Great article, I missed this one.

Can you shred some details on:
What is IonCube or Zend Optmizers ?
What is Eaccelerator, Php Cache or XCache ?

This few things have confused me till day, if you can explain them in layman language.

Thank You.


Jun 24, 2008
I have a problem, but i don't know If Mathopd can resolve it?

Myserver is download file server only, with many internet client download files (not upload, have NOT Database other sevice).
When running, with many user download file, the number of httpd process is incresed very quickly, and reached MaxClients quickly as folowing (each 3 minutes):

2008-06-22 10:15:02-RESTART HTTPD service:
2008-06-22 10:18:02-COUNT HTTPD =63
2008-06-22 10:21:01-COUNT HTTPD =140
2008-06-22 10:24:02-COUNT HTTPD =173
2008-06-22 10:27:02-COUNT HTTPD =328
2008-06-22 10:30:02-COUNT HTTPD =434
2008-06-22 10:33:01-COUNT HTTPD =561
2008-06-22 10:36:02-COUNT HTTPD =630
2008-06-22 10:39:01-COUNT HTTPD =751
2008-06-22 10:42:01-COUNT HTTPD =877
2008-06-22 10:45:01-COUNT HTTPD =999
And this problem repeats and repeats...

My server installed Apache/2.0.52, 2G RAM, Xeon 2G, 320 GB HDD with settings:
KeepAlive Off
MaxKeepAliveRequests 100
KeepAliveTimeout 15

<IfModule prefork.c>
StartServers 16
MinSpareServers 3
MaxSpareServers 5
ServerLimit 1000
MaxClients 1000
MaxRequestsPerChild 1000
I've change some parameter, ex, decrease MaxRequestsPerChild (2000->1000->100...), KeepAlive Off ->On... and other changes... But problem still happens!

If Mathopd can resolve it?
Thanks very much!


Tazmanian Master
Sep 17, 2005
Excellent article - I find that using litespeed as my web server is better than apache - especially if you site has a lot of traffic, or you just want to be faster.