Wednesday, June 27, 2007

Tuning for Web Server

Then you modify the following variables:

sysctl -w kern.ipc.nmbclusters=16384
sysctl -w kern.ipc.maxsockets=16384

Other tips:

set httpd simultaneous connections very high
you must know your performance characteristics, make graps with your performance, analyze your server parameters
use a dedicate server for your web server (do not mix with other server, like mail server)
httpd.conf (apache):StartServers should be high (default is 5, for a dedicate server make it higher

MaxRequestPerChild= 10000
Timeout (to get a TCP ACK for a GET request) should be 60 (default is 300)
MaxClients (FreeBSD) = 256
Tuning for a File Server
When tuning a FreeBSD Box for a File Server you must be aware that

large files are transferred
network connection live longer
less transfers are made

Then you modify the following variables.

sysctl -w kern.ipc.nmbclusters=1024Tuning for Mail Server
When tuning a FreeBSD Box for a Mail Server you must be aware that mail servers will need a very large number of network connections and small amount of data for a short period of time.

You can find how many network buffers you use:

netstat -m

Then you modify the following variables.

sysctl -w kern.ipc.nmbclusters=2048
sysctl -w kern.ipc.maxsockets=2048
Tuning a FreeBSD router
This is a work in progress mini howto. More informations will be added later. Also some aspects are about optimizing a pppoe server built with mpd.

If you've build a router with FreeBSD to serve a huge number of lan users some sysctl tunings can be done:

Add the following options to /etc/sysctl.conf

kern.polling.enable=1
kern.ipc.nmbcluster=32768
kern.ipc.maxsockbufs=2097152
kern.ipc.somaxconn=8192
kern.maxfiles=65536
kern.maxfilesperproc=32768
net.inet.tcp.delayed_ack=0
net.inet.tcp.sendspace=65535
net.inet.udp.recvspace=65535
net.inet.udp.maxdgram=57344
net.local.stream.recvspace=65535
net.local.stream.sendspace=65535

To be able to activate device polling you must recompile kernel with options DEVICE_POLLING and also your nic driver must support polling.

Also add the following options to /boot/loader.conf if you use pppoe server with mpd:

net.graph.maxalloc=512
net.graph.maxdgram=45000
net.graph.recvspace=45000

If you do not increase net.graph.maxdgram and net.graph.recvspace variables you will not be able to connect more than 130 pppoe users (with mpd).

If you've built your traffic shaper with pf packet filter and you use ALTQ HFSC algorythm you will have increase the maximum number of queues permitted by HFSC algorythm:

Edit file: /sys/contrib/altq/altq_hfsc.h
Modify #define HFSC_MAX_CLIENTS 64 to
#define HFSC_MAX_CLIENTS 500

And remember that HFSC is a linear algorythm, it will work fine for hundreads of queues but not for thousands.



sysctl -w kern.ipc.maxsockets=1024