========================
Performance Improvements
========================

------------
Module: core
------------

:Author: Jan Kneschke
:Date: $Date: 2004/08/29 09:44:53 $
:Revision: $Revision: 1.2 $

:abstract:
  handling performance issues in lighttpd
  
.. meta::
  :keywords: lighttpd, performance
  
.. contents:: Table of Contents

Description
===========

Performance Issues
------------------

lighttpd is optimized into various directions. The most important is
performance. The operation system has two major facalities to help lighttpd
a deliver it best performance.

HTTP Keep-Alive
---------------

Disabling keep-alive might help your server if you suffer from a large
number of open file-descriptors.

::

  server.max-keep-alive-requests = 128
  server.max-keep-alive-idle = 30
  server.max-read-idle = 60
  server.max-write-idle = 360

Event Handlers
--------------

The first one is the (Event Handler)_ which cares about notifying the server
that one of the connections is ready to send or to recieve. As you can see
every OS has at least the select() call which has some limitations. 

========== ========== ===============
OS         Method     Config-Value  
========== ========== ===============
all        select     select
Unix       poll       poll
Linux 2.4+ rt-signals linux-rtsig
Linux 2.6+ epoll      linux-epoll
Solaris    /dev/poll  solaris-devpoll
\*BSD      kqueue     freebsd-kqueue
========== ========== ===============


For more infomation in this topic take a look at http://www.kegel.com/c10k.html

Configuration
`````````````

The event-handler can be set by specifying the 'Config-Value' from above
in the ``server.event-handler`` variable

e.g.: ::

  server.event-handler = "linux-epoll"
  
Network Handlers
----------------

The basic network interface for all platforms at the syscalls read() and
write(). Each modern OS provides its own syscall to help network servers
to transfer files as fast as possible. 

If you want to send out a file from the webserver it does make any sense 
to copy the file into the webserver just to write() it back into a socket
in the next step.

sendfile() minimizes the work in the application and pushes a file directly
into the network card (idealy spoken). 

lighttpd supports all major platform specific calls:

========== ========== 
OS         Method     
========== ==========
all        write     
Unix       writev       
Linux 2.4+ sendfile   
Linux 2.6+ sendfile64 
Solaris    sendfilev
FreeBSD    sendfile
========== ========== 

They are selected automaticly on compile-time. If you have problems check
./src/network_backend.h and disable the corresponding USE\_... define.

