Friday Jun 15, 2007

lighttpd on Solaris

Build notes and Tuning tips for Solaris

lighttpd seems to be increasingly popular, so much so that netcraft has started tracking it's use on production websites. I've spent some time building, tuning and running simple performance stress tests on lighttpd 1.4.15 on Solaris and thought I'd share what I learnt.

Building lighttpd

My build of lighttpd uses the openldap library from Cool Stack. I also built and installed pcre-7.1 in /opt/coolstack using the following script :

#!/bin/sh
INSTALLDIR=/opt/coolstack
CFLAGS="-fast -xipo -xtarget=generic"

make distclean
./configure --prefix=$INSTALLDIR CFLAGS="$CFLAGS"
make
make install

And finally, here is a script to build lighttpd using Sun Studio compiler on Solaris :

#!/bin/sh
INSTALLDIR=/opt/coolstack
LDFLAGS="-L$INSTALLDIR/lib -L/usr/sfw/lib -lsendfile -R/usr/sfw/lib"
CFLAGS="-fast -xipo -xtarget=generic"
PCRECONFIG="$INSTALLDIR/bin/pcre-config"
PATH=/opt/SUNWspro/bin:/usr/ccs/bin:/usr/sbin:/usr/bin:
export PATH

make distclean

./configure --prefix=$INSTALLDIR/lighttpd  --with-pic \\ --with-openssl=/usr/sfw --with-ldap \\
--with-bzip2 --with-pcre=$INSTALLDIR --disable-ipv6 \\ CFLAGS="$CFLAGS" \\
LDFLAGS="$LDFLAGS" PCRECONFIG="$PCRECONFIG"

make
make install

Tuning lighttpd

By default, lighttpd uses poll as the event handler for Solaris; however it does include support for devpoll which scales better (no support for event ports yet). To use devpoll, add the following to your lighttpd.conf :

server.event-handler = "solaris-devpoll"

By default, lighttpd uses sendfilev to do the writes, but there are several issues in Solaris 10 and opensolaris which cause sendfilev to have  performance and stability problems:

6455727 - lighttpd cannot be killed because of hanging in senfilev()
6505740 - TCP does not wake up all waiting threads waiting for TCP zero copy completion notification
6532645 - implement ZCP sendfile for 64-bit apps
5003297 - sendfile/sendfilev should avoid data copy

Some of these issues are already fixed in later Nevada builds, but if you're running on Solaris 10,  it's best to use writev by adding the following :

server.network-backend = "writev"

If you're running on a multi-core system, it is necessary to set max-worker as well, as lighttpd by default is single-process and single-threaded. It is best to set the number of workers to two times the number of cores :

server.max-worker = 4


For other generic lighttpd tuning tips, see the lighttpd documentation.

About

I'm a Senior Staff Engineer in the Performance & Applications Engineering Group (PAE). This blog focuses on tips to build, configure, tune and measure performance of popular open source web applications on Solaris.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today