Saturday, August 3, 2013

Apache Web servers alternatives

Web servers have become an important part of today's infrastructure for business, trading, entertainment and information. Some of the Web's sites take millions of hits every day, or even every hour. With all legacy server running Apache server for PHP,  all of us ignore the issues with it. Later landing in a situation where we solve a lot of load and memory issues limiting the performance. Apache server being one among the most experienced in the field of performance and feature, we generally ignore other alternatives to it.
Besides  good practice to  separate responsibilities to different servers, we ignore the fact we don't need MBs of forked process to serve simple files . We should not use  sward where simple talks can work. So instead of making use of heavy processes just to serve some static content i.e. to use the same service to serve dynamic and static pages.

How to measure web server performance?

  • First, Make sure your web server is tuned up for the maximum performance.
  • Turn off throttling by setting Outbound Bandwidth to 0.
  • Set the value of Max Keep-Alive Requests to a big number like 100000.
  • Set Max Connections as high as possible.
  • Set Connection Soft Limit and Connection Hard Limit to 1000 or higher in Per Client Throttling Control, depending on how many concurrent connections you need from one IP address.
  • Set Follow Symbolic Link to Yes and Restrained to No for the testing virtual host

There are three commonly used tools for benchmark: ApacheBench, Httperf and AutoBench.

Using ApacheBench:

ApacheBench is a command line performance-testing tool bundled with Apache httpd. It can simulate hundreds of HTTP/1.0 clients simultaneously accessing same resource on the server.
You can simply run it with command:
 ab -n 10000 -c 100 http://localhost:8088/index.html

or you can use keep-alive requests by
 ab -n 10000 -c 100 -k http://localhost:8088/index.html

For detailed information, please check Apache document.

Using Httperf:
You can get httperf from http://www.hpl.hp.com/personal/David_Mosberger/httperf.html.
Httperf uses HTTP/1.1 protocol by default and always use keep-alive requests. It has more command options, for detailed information please refer to its document.
Here is an example:
./httperf --server localhost --port 8088 --uri /index.html --rate 1000 --num-conn 100 --num-call 100 --timeout 50


Using Autobench:
Autobench is a simple Perl script calling httperf that automates the benchmark process of a web server.
You can get autobench from http://www.xenoclast.org/autobench/ For detailed information, please refer to its document.

You can use a tiny, lightning fast server to handle static documents & images, and pass any more complicated requests on to Apache on the same machine. This way Apache won't tie up its multi-megabyte processes serving simple streams of bytes. You can have Apache only get used, for example, when a php script needs to be executed.

TUX / "Red Hat Content Accelerator (atleast 6 times faster than Apache )
Red Hat Content Accelerator is a kernel-based Web server. It is currently limited to serving static webpages and coordinating with kernel-space modules, user-space modules, and regular user-space Web server daemons to provide dynamic content. Regular user-space Web servers do not need to be altered in any way for Red Hat Content Accelerator to coordinate with them. Red Hat Content Accelerator can serve static content very efficiently from within the Linux kernel.
Red Hat Content Accelerator also has the ability to cache dynamic content. To respond to a request for dynamic data, a Red Hat Content Accelerator module can send a mix of dynamically-generated data and cached pre-generated objects, taking maximal advantage of Red Hat Content Accelerator's zero-copy architecture.
A quick start  demo of installing and starting the service is mentioned here
The main differences between TUX and other webservers include:

  1. TUX runs partly within a customized version of the Linux kernel and partly as a userspace daemon.
  2. With a capable network card, TUX enables scatter-gather DMA from the page cache directly to the network.
  3. TUX is only able to serve static web pages.



kHTTPd
kHTTPd is a http-daemon (webserver) for Linux. kHTTPd is different from other webservers in that it runs from within the Linux-kernel as a module (device-driver). kHTTPd handles only static (file based) web-pages, and passes all requests for non-static information to a regular userspace-webserver such as Apache or Zeus. kHTTPd is actually not much different from a normal http dæmon in principle. The main difference is that it bypasses the syscall layer. “Accelerating” the simple case of serving static pages within the kernel leaves user-space dæmons free to do what they are very good at: generating user-specific, dynamic content. A user-space web server such as Apache, typically loaded with many features and many execution paths, can't be as fast as kHTTPd. There are, however, a few web servers that are as simple as kHTTPd but implemented in user space, so they are not expensive consumers of processor cycles, even compared with kHTTPd.
README is pretty clean and can get you a quick start

thttpd
thttpd is a simple, small, portable, fast, and secure HTTP server. Besides a few use cases for thttpd, but there are several other scenarios in which it may be useful:
  • Slow machines--Machines with old hardware that are able to run a Unix-like operating system (such as NetBSD) are often powerful enough to serve static content with thttpd.
  • Heavily loaded machines--You may have a very powerful machine that runs other heavy processes, such a DBMS, yet you need it to serve some web content (statistics, for example). In this case, thttpd can do well.
  • Simple requirements--Sometimes you may want to provide web content to the public, but you do not need much of the fancy stuff provided by powerful servers such as Apache. In this case, a lightweight server may be enough for your needs. Furthermore, given their smaller code sizes, they have fewer chances to fail and you can audit their code more easily.
  • Serving static content alongside a powerful server--You may have a server running Apache with a load of modules, parsing very complex dynamic pages. These pages often need to include other files, most commonly static images. In this case, thttpd can serve the static data alongside Apache, which will exclusively handle the complex content. There is a section dedicated to this specific use case later.
thttpd notes can help  and get you started


LiteSpeed Web Server
LiteSpeed Web Server is the leading high-performance, high-scalability web server. It is completely Apache interchangeable so LiteSpeed Web Server can quickly replace a major bottleneck in your existing web delivery platform. With its comprehensive range of features and easy-to-use web administration console, LiteSpeed Web Server can help you conquer the challenges of deploying an effective web serving architecture.

LiteSpeed Web Server has superior performance in terms of both raw speed and scalability. Our benchmarks demonstrate that it is more than 6 times faster than Apache. When serving static content, LiteSpeed surpasses well-respected content accelerators including thttpd, boa and TUX. When it comes to dynamic content, LiteSpeed is more than 50% faster in PHP content delivery than Apache with mod_php. Don't just take our word for it. Download the LiteSpeed free or trial version and experience it for yourself.


Caudium & Roxen
Caudium is a Web server based on a fork. The server is written in C and Pike, and Pike is also used to create extensions to the server. Caudium differs from Apache in many ways including the directory structure, programming language, and type of configuration.
scrolling down to http://www.tldp.org/HOWTO/Caudium-HOWTO/index.html can help getting started.

If you are worried about running Dynamic pages
GWAN is the fastest  till date
G-WAN powers the next-generation, massively-scalable EON, Inc PaaS able to deploy the most demanding Web Applications using a variety of programming languages in an elastic, fail-safe, and remarkably efficient CloudG-WAN is known to  an hello.java with 10x less CPU and 24x less RAM handling 11x more requests in 13x less time than Apache Tomcat on a 6-Core. Many other languages (PHP, C#, JS...) benefit even more.

 [1-1000 range] hello world (dynamic contents, HTTP keep-alives)
 
G-WAN + C     Average RPS:801,585 Time:1,551 seconds [00:25:51]
G-WAN + Java  Average RPS:759,726   Time: 1,648 seconds [00:27:28]
G-WAN + Scala Average RPS:757,767   Time: 1,660 seconds [00:27:40]
G-WAN + JS    Average RPS:768,659   Time: 1,696 seconds [00:28:16]
G-WAN + Go    Average RPS:784,113   Time: 1,892 seconds [00:31:32]
G-WAN + Lua   Average RPS:757,588   Time: 1,920 seconds [00:32:00]
G-WAN + Perl  Average RPS:782,088   Time: 1,977 seconds [00:32:57]
G-WAN + Ruby  Average RPS:778,087   Time: 2,054 seconds [00:34:14]
G-WAN + PythonAverage RPS:774,180   Time: 2,110 seconds [00:35:10]
G-WAN + PHP   Average RPS:613,389   Time: 2,212 seconds [00:36:52]

 Tomcat         Average RPS: 76,556   Time:20,312 seconds [05:38:32]
 Node.js        Average RPS: 14,209   Time:80,102 seconds [22:15:02]
 Google Go      Average RPS: 12,801   Time:84,811 seconds [23:33:31]

Performance report


ConcurrencyApache 1.3.33Apache 2.0.55thttpd 2.25bLighttpd 1.4.8LiteSpeed 2.1 StandardLiteSpeed 2.1 EnterpriseLiteSpeed 2.1 Enterprise (2 Clients)
1205921512296235526312620-
109731107051118511566115271587820100
1009241100641189711558131731767427312
2009581100101173011920131781675026808
500866495431154011539120321603525213
1000859092361086710570114421523224820

Small Static File (Non-Keepalive) Benchmark

ConcurrencyApache 1.3.33Apache 2.0.52thttpd 2.25bLighttpd 1.4.8LiteSpeed 2.1 StandardLiteSpeed 2.1 EnterpriseLiteSpeed 2.1 Enterprise (2 Clients)
1367836412288399255465540-
1015782167141076015218217203776442000
10015384159261196814909216875672191352
20014825152161158014865216635841193143
50014734150941123013888215055704583010
100013478142411090614056174035213781050