httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Behlendorf <>
Subject Hints on running a high-performance web server (fwd)
Date Tue, 10 Oct 1995 21:15:52 GMT

I added his comments to docs/perf.html and docs/virtual-host.html - what 
do you think about his patch to add setrlimit() calls?  I think it 
determine the value to set NOPROC_LIMIT to either be a config file call 
or a multiple of the number of virtual hosts used....


--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--  http://www.[hyperreal,organic].com/

---------- Forwarded message ----------
Date: Tue, 10 Oct 1995 13:29:42 -0600
From: Aaron Gifford <agifford@InfoWest.COM>
Subject: Hints on running a high-performance web server


I noticed that on performance hints page (
you mention a problem with the listen() queue under Linux.  I've also seen
this problem under BSD/OS 1.1 (the old version from BSDI) and under FreeBSD
2.0.5.  The fix was the same on both machines:

Edit the following two files:

In each file, look for the following:
     * Maximum queue length specifiable by listen.
    #define SOMAXCONN       5

Just change the "5" to whatever appears to work.  I bumped the two machines I
was having problems with up to 30 and haven't noticed the problem since.

After the edit, recompile the kernel and recompile the apache server then

Another problem I had was encountering resource limits for the number of
processes allowable on the system for the user under which the server
was running (I run apache as a standalone and start it as root, then
the server becomes user "http" on my system).  I lame fix for this was to
edit http_main.c and at the top of the "main()" function add some setrlimit()
calls at the top.  No effort was made to make this any sort of general
solution, just a quick fix for the problem on my system.

Here's what mine looks like:
    main(int argc, char *argv[])
        int c;
        struct rlimit rlp;
        rlp.rlim_cur = rlp.rlim_max = 350;
        if (setrlimit(RLIMIT_NPROC, &rlp)) {
            fprintf(stderr, "setrlimit(RLIMIT_NPROC) failed.\n");
        rlp.rlim_cur = rlp.rlim_max = 512;
        if (setrlimit(RLIMIT_NOFILE, &rlp)) {
            fprintf(stderr, "setrlimit(RLIMIT_NOFILE) failed.\n");

One of the symptoms of the resource limitation was seen as a failure of many
external cgi scripts and an error_log entry that mentioned the inability
to fork.  I also fixed a problem that didn't exist on my systems (or at least
I hadn't noticed it causing problems) by also doing a setrlimit() to boost
the no. of fd's allowed.  I probably didn't need to do the second setrlimit().

On a REALLY heavily used system, an additional change or two to the kernel
might be necessary to increase the overall system resource limits compiled
into the kernel.

While I do operate a few BSD based systems (running on Pentiums), I'm still
a newbie to the BSD 4.3 and 4.4 systems and have only lightly browsed a few
of the kernel source files, so I'd be HAPPY to hear of better ways to do
what I've done.  Likewise, feel free to let me know what I might have done

Aaron Gifford
InfoWest Networking

View raw message