KEMBAR78
Beyond Apache: Faster Web Servers | PDF
Beyond Apache: Faster Web
         Servers
       Siddharth Vijayakrishnan
        mail@bluefireworks.net




                                  Beyond Apache: Faster Web Servers – p.1/11
About me
 •   Application developer with Oracle India
 •   Work on web servers in my free time
 •   Contributor to Lighttpd




                                      Beyond Apache: Faster Web Servers – p.2/11
Executive summary
  •   How does a web server work?
  •   How can it made to work faster
  •   Apache
  •   Other web servers
  •   Lighttpd
  •   The road ahead




                                       Beyond Apache: Faster Web Servers – p.3/11
Let’s write a web server
  •   First try:socket(), bind(), listen(),
      accept(),sendresponse(), close()
  •   Second try: socket(), bind(),listen(), accept(),
      fork() etc
  •   Second try better than the first since it can handle
      multiple connections
  •   A lot of web servers do just this and work just fine




                                         Beyond Apache: Faster Web Servers – p.4/11
What’s wrong then?
  •   This model does not scale well
  •   Model breaks down completely under overload
      conditions
       • Slashdot effect / "Thundering Herd" problem
       • Distributed Denial of Service attacks




                                      Beyond Apache: Faster Web Servers – p.5/11
Threads v/s Event Driven
  •   Threads:-
       • Kernel schedulers are getting better at their
         job
       • Scales well on SMP systems
       • Throughput degrades drastically under heavy
         load




                                        Beyond Apache: Faster Web Servers – p.6/11
Threads v/s Event Driven
  •   Event Driven:-
       • Avoids the nasty beasties - synchronization,
         dead lock, adaptive process spawning etc
       • Scales nicely under overload
       • A single process event driven design cannot
         take advantage of SMP
       • Blocking I/O can degrade performance of the
         event driven model




                                       Beyond Apache: Faster Web Servers – p.7/11
The Apache Web Server
  •   Poster child of the OSS revolution
  •   Feature rich
  •   Module API allows extensions to server
      functionality
  •   Apache2 supports multiple processing models
       • prefork
       • worker
       • experimental event driven mode




                                      Beyond Apache: Faster Web Servers – p.8/11
What Ails Apache?
  •   Slow adoption of Apache2 (some stats here)
  •   Apache 1.3 (the most popular version) suffers
      from generic multi process server scalability
      issues
  •   Rich feature set can sometimes be a problem e.g
        • httpd.conf / rewrite / virtual hosting are not
          the easiest to get right
        • Support for .htaccess slows down processing




                                         Beyond Apache: Faster Web Servers – p.9/11
Others in the fray
  •   thttpd
        • Really fast at serving static content
        • Not much support for anything else

  •   zeus
        • Fast but not open source

  •   Others:
        • gatling, cherokee, boa, nginx, mathopd
        • Matrix showing features present and lacking




                                       Beyond Apache: Faster Web Servers – p.10/11
Experimental Efforts
  •   Tux (kernelspace httpd), Flash
       • Inspired by the Mindcraft survey that showed
         IIS to be faster than Apache
       • Tux was a nice experiment till sendfile()
         arrived
  •   Flash
       • has an excellent specWEB 99 score
       • Hybrid design model - Asymmetric
         Multiprocess Event Driven
       • Judicious use of threads to get around the
         flaws in the event driven model
  •   Lazy Asynchronous I/O
                                      Beyond Apache: Faster Web Servers – p.11/11
Lighttpd: A Viable Alternative
  •   Began as an experiment to prove that a web
      server running as a single process could
      withstand the thundering herds
  •   Stuff to be added here




                                      Beyond Apache: Faster Web Servers – p.12/11
Lighttpd: Features
  •   Standard Set
       • HTTP/1.1 support, SSL,
         FastCGI,CGI,WebDAV, IPv6
       • Module API available

  •   Unique Features
       • Works with different event handlers
       • Memcache integration
       • Workarounds for most of the problems that
         event driven servers face
       • Really simple configuration




                                      Beyond Apache: Faster Web Servers – p.13/11
Lighttpd: Currently
  •   19,000 installations as per the last Netcraft survey
  •   Phenomenal growth rate in the number of servers
      running lighty
  •   Release 1.4.7 is out
       • Release early, Release often -> A release
         every two or three weeks
  •   Enthusiastic response from the ’frameworks’
      crowd
       • RoR users form the most vocal support group

  •   Some popular sites running Lighttpd
       • www.nexopia.com
       • wikipedia image/download servers
       • Textdrive                       Beyond Apache: Faster Web Servers – p.14/11
Lighttpd: How Does It Compare
  •   benchmark data goes here




                                 Beyond Apache: Faster Web Servers – p.15/11
Lighttpd: Future
  •   Filters
  •   Windows port (if someone gets the time)
  •   Get the server into all major distributions
  •   More and more modules (contributions will be
      gratefully accepted)




                                      Beyond Apache: Faster Web Servers – p.16/11

Beyond Apache: Faster Web Servers

  • 1.
    Beyond Apache: FasterWeb Servers Siddharth Vijayakrishnan mail@bluefireworks.net Beyond Apache: Faster Web Servers – p.1/11
  • 2.
    About me • Application developer with Oracle India • Work on web servers in my free time • Contributor to Lighttpd Beyond Apache: Faster Web Servers – p.2/11
  • 3.
    Executive summary • How does a web server work? • How can it made to work faster • Apache • Other web servers • Lighttpd • The road ahead Beyond Apache: Faster Web Servers – p.3/11
  • 4.
    Let’s write aweb server • First try:socket(), bind(), listen(), accept(),sendresponse(), close() • Second try: socket(), bind(),listen(), accept(), fork() etc • Second try better than the first since it can handle multiple connections • A lot of web servers do just this and work just fine Beyond Apache: Faster Web Servers – p.4/11
  • 5.
    What’s wrong then? • This model does not scale well • Model breaks down completely under overload conditions • Slashdot effect / "Thundering Herd" problem • Distributed Denial of Service attacks Beyond Apache: Faster Web Servers – p.5/11
  • 6.
    Threads v/s EventDriven • Threads:- • Kernel schedulers are getting better at their job • Scales well on SMP systems • Throughput degrades drastically under heavy load Beyond Apache: Faster Web Servers – p.6/11
  • 7.
    Threads v/s EventDriven • Event Driven:- • Avoids the nasty beasties - synchronization, dead lock, adaptive process spawning etc • Scales nicely under overload • A single process event driven design cannot take advantage of SMP • Blocking I/O can degrade performance of the event driven model Beyond Apache: Faster Web Servers – p.7/11
  • 8.
    The Apache WebServer • Poster child of the OSS revolution • Feature rich • Module API allows extensions to server functionality • Apache2 supports multiple processing models • prefork • worker • experimental event driven mode Beyond Apache: Faster Web Servers – p.8/11
  • 9.
    What Ails Apache? • Slow adoption of Apache2 (some stats here) • Apache 1.3 (the most popular version) suffers from generic multi process server scalability issues • Rich feature set can sometimes be a problem e.g • httpd.conf / rewrite / virtual hosting are not the easiest to get right • Support for .htaccess slows down processing Beyond Apache: Faster Web Servers – p.9/11
  • 10.
    Others in thefray • thttpd • Really fast at serving static content • Not much support for anything else • zeus • Fast but not open source • Others: • gatling, cherokee, boa, nginx, mathopd • Matrix showing features present and lacking Beyond Apache: Faster Web Servers – p.10/11
  • 11.
    Experimental Efforts • Tux (kernelspace httpd), Flash • Inspired by the Mindcraft survey that showed IIS to be faster than Apache • Tux was a nice experiment till sendfile() arrived • Flash • has an excellent specWEB 99 score • Hybrid design model - Asymmetric Multiprocess Event Driven • Judicious use of threads to get around the flaws in the event driven model • Lazy Asynchronous I/O Beyond Apache: Faster Web Servers – p.11/11
  • 12.
    Lighttpd: A ViableAlternative • Began as an experiment to prove that a web server running as a single process could withstand the thundering herds • Stuff to be added here Beyond Apache: Faster Web Servers – p.12/11
  • 13.
    Lighttpd: Features • Standard Set • HTTP/1.1 support, SSL, FastCGI,CGI,WebDAV, IPv6 • Module API available • Unique Features • Works with different event handlers • Memcache integration • Workarounds for most of the problems that event driven servers face • Really simple configuration Beyond Apache: Faster Web Servers – p.13/11
  • 14.
    Lighttpd: Currently • 19,000 installations as per the last Netcraft survey • Phenomenal growth rate in the number of servers running lighty • Release 1.4.7 is out • Release early, Release often -> A release every two or three weeks • Enthusiastic response from the ’frameworks’ crowd • RoR users form the most vocal support group • Some popular sites running Lighttpd • www.nexopia.com • wikipedia image/download servers • Textdrive Beyond Apache: Faster Web Servers – p.14/11
  • 15.
    Lighttpd: How DoesIt Compare • benchmark data goes here Beyond Apache: Faster Web Servers – p.15/11
  • 16.
    Lighttpd: Future • Filters • Windows port (if someone gets the time) • Get the server into all major distributions • More and more modules (contributions will be gratefully accepted) Beyond Apache: Faster Web Servers – p.16/11