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.

Comments:

For running lighttpd after solaris startup, there's already a smf manifest file: /var/svc/manifest/network/lighttpd.xml at: http://trac.lighttpd.net/trac/wiki/LighttpdOnSolaris

Posted by Thorleif Wiik on June 15, 2007 at 06:10 AM PDT #

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. Shanti

Posted by Shanti on June 18, 2007 at 06:00 AM PDT #

Cool post, thanks for the info.

Posted by Derek Crudgington on June 19, 2007 at 06:25 AM 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 25, 2007 at 06:52 PM 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 04:09 AM 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 04, 2007 at 09:25 PM 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 07:25 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
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