Skip to content

2007

PRE-RELEASE: lighttpd-1.5.0-r1605.tar.gz

A lot of changes made it into the svn recently. It is time again to spread the code to more testers than just the few early adaptors who are using the svn-trunk/

Please try out the new stuff around async-io and dynamic compression of content. Even directory-listings are now automaticly compressed. Just load mod_deflate and set

deflate.mimetypes = ( "text/html" )

ChangeLog (r1605):

  • added check for leading slashes in mod_rewrite
  • improved async-io performance for files between 4k and 16k
  • fixed compression of static files in mod_deflate
  • fixed configure check for the library providing aio_read()
  • fixed moddirlisting, modstaticfile and the internal error-pages for mod_deflate
  • fixed compilation on FreeBSD and MacOS X

ChangeLog (r1593):

  • added O_NOATIME support to the network-backends linux-sendfile and writev
  • added a portable, threaded network-backend based on glib’s gthread
  • added threaded stat()
  • added url.redirect-code to mod_redirect to set other HTTP status-codes than 302
  • added filter-API and mod_chunked and mod_deflate for dynamic compression
  • added a static balancer for mod-proxy-core
  • added $HTTP[“request-method”] and $PHYSICAL[“path”] conditionals
  • fixed X-Sendfile support in mod-proxy-core
  • fixed crash if mtime is 0
  • added cmake as experimental build-system
  • fixed urls in AJP13-protocol of mod-proxy-core
  • added support for “now” and “weeks” to mod-expire
  • added mod-magnet

more threaded io

After a long night we finally have everything in place for a threaded stat() calls. Not only that, we also have a new network backend for all those platforms which have problems with the posix-aio on. You need to have glib2-2.6.0 or higher installed.

The new options are:

server.max-stat-threads = 4
server.max-write-threads = 8
server.network-backend = "gthread-aio"

Depending on the backend, your OS and the number of disks you might want to raise the two values, but keep in mind that you will get problems if you raise them too much. Performance will decrease again at a given point.

The performance of the different backends is: linux-aio-sendfile, posix-aio, gthread-aio, …

On the way linux-aio-sendfile and posix-aio should behave better under high concurrent load now. They even got some stats:

server.io.linux-aio.async-read: 1261
server.io.linux-aio.sync-read: 551

Time for benchmarks, check my earlier article about lighty-1-5-0-and-linux-aio and try to generate the same set of testfiles and take http_load to generate random load. It is important that you use more files then you can cache in memory.

Threaded stat()

Just as a proof of concept I implemented a threaded stat() call. It is a bit of a hack currently, but it looks promising when I look at the performance data:

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           5.00    0.00   26.60   68.40    0.00    0.00

Device:    rrqm/s wrqm/s   r/s   w/s  rsec/s  wsec/s    rMB/s    wMB/s avgrq-sz avgqu-sz   await  svctm  %util
sda          0.00   0.60 66.90  1.60 13019.20   22.40     6.36     0.01   190.39     6.10   88.20  14.49  99.28
sdb          0.00   0.60 66.60  1.60 13061.60   22.40     6.38     0.01   191.85    14.09  208.82  14.67 100.04

In Accelerating Small File-Transfers we tried the same without a async stat() and with fcgi-stat-accel. With the threaded stat() I moved the code into lighttpd itself which reduces the external communicating and manages everything in lighttpd itself.

name Throughput util% iowait%
no stat-accel 12.07MByte/s 81%
stat-accel (tcp) 13.64MByte/s 99% 45.00%
stat-accel (unix) 13.86MByte/s 99% 53.25%
threaded-stat 14.32MByte/s 99% 68.40%

(larger is better)

Accelerating Small File-Transfers

Thanks to some help from our #lighttpd IRC-channel we solved another long-standing problem:

As lighttpd is event-based web-server we have problems when it comes to blocking operations. In 1.5.0 we add async sendfile() operations which helps for large files alot. For small files most of the time is spent on the initial stat() call which has no async interface.

Fobax submitted a nice solution for this problem: move the stat() to a fastcgi app which returns with X-LIGHTTPD-send-file: and hands the request back to lighttpd. The fastcgi can block and spend some time while lighttpd moves on the with other requests. When the fastcgi returns the information for the stat() call is in the fs-buffers and lighttpd doesn’t block on the stat() anymore.

All this is documented by darix in the wiki at HowtoSpeedUpStatWithFastcgi

This works with mod_fastcgi in 1.4.0 or with mod-proxy-core in 1.5.0 + aio.