Performance Blog

lighttpd on Solaris

Posted on: June 15, 2007

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 :

CFLAGS="-fast -xipo -xtarget=generic"

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

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

LDFLAGS="-L$INSTALLDIR/lib -L/usr/sfw/lib -lsendfile -R/usr/sfw/lib"
CFLAGS="-fast -xipo -xtarget=generic"
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" \

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 : = "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.


7 Responses to "lighttpd on Solaris"

For running lighttpd after solaris startup, there’s already a smf manifest file: /var/svc/manifest/network/lighttpd.xml at:

Thanks for the pointer to the SMF files. Although, this make a great start, it doesn’t use the power of SMF to limit privileges. I’ve just edited that link to do this.

Cool post, thanks for the info.

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.

Using solaris-devpoll works when run outside of SMF. But doesn’t work when I run it through SMF using the privileges:
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?

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 If you have any questions, post them to my blog and I’ll do my best to answer them. Mandy

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

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Shanti's Photo


Latest Tweets



%d bloggers like this: