Network: Apache: Speeding up your webserver

(last edit: 2001-06-13)


Apache and the GENERIC kernel are a bit slow. This is because you will run out of available buffers. You can 'fix' this by compiling a new kernel (read below). NOTE: this is not THE solution to a slow webserver. The prolem can be a slow (IDE) disk, not enough memory, etc.

Kernel changes

You'll have to add/change the following kernel options: maxusers 32 options NMBCLUSTERS=1024 Taken from '/usr/src/sys/i386/conf/LINT': "# The `maxusers' parameter controls the static sizing of a number of # internal system tables by a complicated formula defined in param.c." The 'NMBCLUSTERS' option has no comment in the LINT file. You shouldn't choose a higer value than 512 for 'maxusers'. This option is already in your kernel, just change the value. The max value of 'NMBCLUSTERS' is unkown to me, I currently have it at 10000 without any problems. You should first try a higher maxusers before adding the 'NMBCLUSTERS' option to your kernel. Before the tweak: $root@host:/#sysctl -a ... kern.maxproc: 532 kern.maxfiles: 1064 ... kern.maxfilesperproc: 1064 ... kern.ipc.nmbclusters: 1024 ... kern.ipc.nmbufs: 4096 After the tweak: $root@host:/#sysctl -a ... kern.maxproc: 8212 kern.maxfiles: 16424 ... kern.maxfilesperproc: 16424 ... kern.ipc.nmbclusters: 10000 ... kern.ipc.nmbufs: 40960 Read this document if you don't know how to compile a kernel.


One of the programs you can use for testing is '/usr/ports/www/http_load'. Below are some before and after results (note that this is NOT the max you can get from your machine, it is not a intensive test, this test depend also highly on the hardware, etc, etc it is just an illustration). Before the tweak: $root@host:/#http_load -parallel 40 -seconds 2 node No buffer space available ... No buffer space available No buffer space available 936 fetches, 11 max parallel, 1.22616e+06 bytes, in 2.00591 seconds 1310 mean bytes/connection 466.622 fetches/sec, 611275 bytes/sec 0.327848 mean msecs/connect 5.83531 mean msecs/first-response After the tweak: $root@host:/#http_load -parallel 40 -seconds 2 node 1630 fetches, 17 max parallel, 2.1353e+06 bytes, in 2.00011 seconds 1310 mean bytes/connection 814.955 fetches/sec, 1.06759e+06 bytes/sec 0.314662 mean msecs/connect 6.33601 mean msecs/first-response So tweak, test, tweak, test until your happy (don't forget to think about your hardware!!)

Click here to go back to the index.