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.

Posted by Thorleif Wiik on June 15, 2007 at 01:10 PM PDT #
Posted by Shanti on June 18, 2007 at 01:00 PM PDT #
Posted by Derek Crudgington on June 19, 2007 at 01:25 PM PDT #
Hey, I would like to see a version of lighttpd and all necessary things, like a cgi version of php and also python, in Coolstack. I think the support for Solaris Zones should also be improved, because it needs some time to get it running with multiple zones.
Posted by Sebastian on August 26, 2007 at 01:52 AM PDT #
Using solaris-devpoll works when run outside of SMF. But doesn't work when I run it through SMF using the privileges:
basic,!proc_session,!proc_info,!file_link_any,net_privaddr
I get this error in the logs:
2007-11-08 11:58:04: (server.c.1429) fdevent_poll failed: Invalid argument
If I don't explicitly specify a event handler, I am able to run lighttpd through SMF... maybe indicating that there might be another privilege that it might need?
Posted by Anil on November 08, 2007 at 12:09 PM PST #
Anil, I've posted an entry on my blog about why we believe this is happening and how you can work around it. The link to the entry is http://blogs.sun.com/mandy/entry/lighttpd_smf_troubles. If you have any questions, post them to my blog and I'll do my best to answer them. Mandy
Posted by Mandy on December 05, 2007 at 05:25 AM PST #
Sorry for the fake name/email.
As far as I can tell, the LDAP in your build does not work, nor can I get it to work when building myself.
In fact, the lighttpd binary lists LDAP as not enabled.
$ strings lighttpd|grep LDAP
- LDAP support
$
Posted by mr.ldap on March 26, 2008 at 02:25 PM PDT #