Server Information

Standalone versus Inetd

A daemon on a UNIX system is a process that runs all the time listening for events. The process runs in the background, disconnected from a terminal. The operating system communicates with a daemon by sending it messages. The kill command is used to send messages to daemons. The two signals that are sent to the HTTP daemon are -HUP and -TERM.

There are lots of daemons that can run on a UNIX system: FTP, telnet, HTTP. All of these are processes that listen for a particular type of a connection to the computer. When the corresponding request is made, then the daemon for that request handles it. Afterwards, the daemon continues to listen for more requests. For example, when you try to FTP to ftp://ftp.aul.fiu.edu, then the FTP daemon handles the request. When you try to access index.html on http://www.aul.fiu.edu, then the HTTP daemon handles the request.

If a daemon is doing its own listening, then it is in standalone mode.

In particular there is a daemon named Inetd. Inetd is a meta-daemon: other daemons register with it, so that Inetd listens instead of the actual daemon. For instance, the FTP daemon registers with Inetd, so that Inetd will listen for an FTP connection. When Inetd detects an FTP connection, then Inetd starts the FTP daemon, which then handles the FTP request. When the FTP request is completed, the FTP deamon stops, but Inetd continues to listen for more FTP requests. In essence, the FTP daemon says to Inetd, "I'm going to sleep, wake me up if anything interesting happens."

If a daemon registers with Inetd, then the daemon is in Inetd mode.

The Apache daemon normally runs in standalone mode, in order to make the fastest possible response to a request. When Apache starts, there is a considerable overhead involved in reading the configuration files. Contrast this with an FTP request, which has very little overhead and stays connected for a long time. If Apache ran under Inetd, then this startup overhead would happen each time a request was made to the server. The user would notice that the server was responding slowly. Just notice how long it takes for the server to actually start when you start your server. Since Apache requests are completed quickly, the overhead of starting the daemon for each request would create a noticeable delay.

Spare Servers

Running in standalone mode is one way to speed up the request cycle. In addition, Apache runs with several copies of itself ready to handle requests. The main Apache server is a daemon: it just listens for HTTP requests. When it detects a request, it clones itself. The clone actually handles the request, not the daemon. Just as there is an overhead involved in starting the main server, there would be an overhead starting a clone of the server. To reduce this overhead, the Apache server starts with several clones of itself already initialized. These are know as the spare servers. It is possible to set a minimum amount to keep around, and a maximum amount to keep around. Please note, that this does not limit the number of requests that can be made to the server. If there are not enough spare servers to handle all the requests, then the main server will just make additional clones of itself, regardless of the maximum setting. For example, if the maximum amount of spare servers was 5, but 8 requests came in, the main server would create 3 additional clones. When all the requests were handled, the number of spare servers above the maximum would be terminated.

It is like valet parking. When you pick up your car, there is one person who takes your receipt. That person then gives your keys to one of the attendants to get your car. The person could handle many requests, while each of the attendants is busy getting a car for just one person.

There are three directives that control the spare servers. These directives belong in httpd.conf.

The minimum, maximum and start numbers must be set to balance system resources against the speed of the response. Creating 1000 spare servers would slow down the entire server, so would indirectly slow down the responses. Having too few spare servers would also cause a slight delay when additional requests are received.

Apache will handle how many spare servers are available, but will keep the number between the minimum and maximum. If a spare server is idle for a long time, then it will be killed, as long as the total number of spare servers does not go below the minimum.

Maximum Clients

The MaxSpareServers does NOT limit the number of requests that can be made to a server. If MaxSpareServers is reached, then Apache will create additional clones to process requests; any inactive servers beyond the maximum will be killed.

The MaxClients directive controls how many simulataneous requests can be maded to a server.

  MaxClients 300
If the number of requests exceeds the maximum, then a message will be displayed to the browser.

Keep Alive Requests

In HTTP 1.0, the default connection type was close. This meant that after each request to the server the connection was closed. If more that one request was made to the same server, then mulitple connections would have to be made to the server. When the Web first started, pages were simple: they did not contain grafic images, they only contained text. For that time, it made sense to close the connection after every request.

In HTTP 1.1, the default connection type is keep alive. This means that one connection to a server can handle many requests from the browser. This occurs all the time. Consider a typical web page: there is some text, and there are several graphics. The browser makes a request for the page to the server, and the server delivers the page. However, the connection stays open for a short time, in case the browser need to get more information from your server, in particular the graphic images that are on the page. Remember that the graphic images are not stored in the same file as your HTML page. The graphics are stored in separate files. Under HTTP 1.0, a separate requests would be made to the server for the page, and for each of the graphics. Under HTTP 1.1, the page and the graohics could be sent using the same connection.

Think about what happens when you connect to a server. These are some of the messages you will see

With HTTP 1.0, you would see these for the page and for each of the graphics files. Under HTTP 1.1, youl will only see this once for all of the files.

There are three directives that can be set in httpd.conf that control a keep alive connection.

KeepAlive
Set this directive with On to enable keep alive requests; set it with Off to enable closed connections
KeepAliveTimeout
This directive sets the maximum time to keep the connection open between requests. If a subsequent request does not arrive within this time limit, then the connection will be closed.
MaxKeepAliveRequests
This directive sets the maximum number of consecutive requests that can be handled by one connection. After the maximum has been reached, the connection will be closed, even if the browser has more requests pending.