Differences in Server Environments
*Data and content sourced from the internet
1. Software Introduction (Apache, Lighttpd, Nginx)
1. Lighttpd
Lighttpd is characterized by very low memory usage, low CPU consumption, good performance, and a rich set of modules. It is one of the more excellent lightweight OpenSource web servers. It supports important features such as FastCGI, CGI, authentication, output compression, URL rewriting, and aliasing.
Lighttpd runs PHP using FastCGI, responding to a large number of concurrent requests with very few PHP processes.
The advantages of FastCGI include:
· From a stability perspective, FastCGI runs as an independent process pool for CGI; if a single process dies, the system can easily discard it and reallocate a new process to handle logic.
· From a security perspective, FastCGI operates completely independently from the host server; regardless of how FastCGI fails, it will not crash the server.
· From a performance perspective, FastCGI separates dynamic logic processing from the server itself; the heavy I/O workload remains with the host server, allowing it to focus solely on I/O. For a typical dynamic webpage, the logic processing is usually only a small part, with large amounts of static I/O, such as images, requiring no involvement from the logic program (Note 1).
· From an extensibility perspective, FastCGI is a neutral technical standard, and it can fully support processing programs written in any language (PHP, Java, Python, etc.).
2. Apache
Apache is the world's number one web server. According to a survey by Netcraft (www.netsraft.co.uk), over fifty percent of web servers worldwide are using Apache.
In April 1995, the earliest version of Apache (0.6.2) was released by the Apache Group. The Apache Group is a non-profit organization that operates entirely over the internet, and it decides what content should be included in the standard release of the Apache web server. It permits anyone to modify bug fixes, provide new features, and port it to new platforms, along with other tasks. When new code is submitted to the Apache Group, the group reviews its details, conducts testing, and if satisfied, the code is integrated into the main release of Apache.
Features of Apache:
1) It can run on almost all computer platforms.
2) Supports the latest HTTP/1.1 protocol.
3) Simple and powerful file-based configuration (httpd.conf).
4) Supports Common Gateway Interface (CGI).
5) Supports Virtual Hosting.
6) Supports HTTP Authentication.
7) Integrated Perl.
8) Integrated Proxy Server.
9) Server status can be monitored through a web browser, and logs can be customized.
10) Supports Server Side Includes (SSI).
11) Supports Secure Socket Layer (SSL).
12) Has the capability to track user session processes.
13) Supports FastCGI.
14) Supports Java Servlets.
3. Nginx
Nginx is a very lightweight HTTP server written by a Russian. Nginx, pronounced as “engine X,” is a high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. It was developed by Igor Sysoev for Rambler.ru, the second most visited site in Russia.
Nginx is written in an event-driven manner, so it has excellent performance, serving as a very efficient reverse proxy and load balancer. It matches Lighttpd in performance while avoiding Lighttpd's memory leak issues; additionally, Lighttpd's mod_proxy is somewhat problematic and hasn't been updated in a long time. However, Nginx does not support CGI execution due to potential programming vulnerabilities; thus, PHP programs must be executed via FastCGI.
As an HTTP server, Nginx has the following basic features:
Processes static files, index files, and automatic indexing; opens file descriptor buffering.
Non-caching reverse proxy acceleration, simple load balancing, and fault tolerance.
FastCGI, simple load balancing, and fault tolerance.
Modular structure. Includes gzipping, byte ranges, chunked responses, and SSI filters. If multiple SSIs within a single page are handled by FastCGI or other proxy servers, this processing can run in parallel without waiting on each other.
Nginx is developed with performance optimization in mind; performance is its most important consideration, and efficiency is emphasized in its implementation. It supports kernel Poll models and can withstand high loads, with reports indicating support for up to 50,000 concurrent connections.
Nginx has very high stability. Other HTTP servers may exhaust physical memory or frequently swap when experiencing peak access or when slow connections are maliciously initiated, resulting in a loss of responsiveness requiring a server restart. For instance, once Apache reaches over 200 processes, web response speed significantly slows down. In contrast, Nginx employs a phased resource allocation technique that keeps its CPU and memory utilization very low. The official Nginx documentation states that maintaining 10,000 inactive connections requires only 2.5 MB of memory, making it virtually impervious to DOS-like attacks. In terms of stability, Nginx outperforms Lighttpd.
Nginx supports hot deployment. Its startup is particularly easy, and it can run continuously 24/7 without interruption, even functioning for months without needing a reboot. You can also upgrade the software version without interrupting service.
2. Comparison of the Three WEB Servers:
Server |
Apache |
Nginx |
Lighttpd |
Proxy |
Very Good |
Very Good |
Average |
Rewriter |
Good |
Very Good |
Average |
Fcgi |
Poor |
Good |
Very Good |
Hot Deployment |
Not Supported |
Supported |
Not Supported |
System Load Comparison |
Very High |
Very Low |
Relatively Low |
Stability |
Good |
Very Good |
Poor |
Security |
Good |
Average |
Average |
Technical Support |
Very Good |
Rarely |
Average |
Static File Handling |
Average |
Very Good |
Good |
Vhosts Virtual Hosting |
Supported |
Not Supported |
Supported |
Reverse Proxy |
Average |
Very Good |
Average |
Session Sticky |
Supported |
Not Supported |
Not Supported |
Note: For relatively comparative large websites, the saved server costs are undoubtedly objective. However, some small websites often do not have many servers; if they adopt traditional web servers like Apache, they might still manage to survive. But there are very obvious downsides: Apache is prone to overload during traffic surges (such as web crawlers or the Digg effect), making Nginx the most suitable choice in such cases.
Recommended solution:
Apache as the backend server (mainly handling PHP and some functional requests like Chinese URLs)
Nginx as the frontend server (leveraging its low resource usage advantage to handle a large number of static page requests)
Lighttpd as the image server
Overall, as Nginx's functionalities improve, it will become the mainstream web server in the future.
3. Performance Testing:
The response times of three software systems will be tested separately for dynamic and static page requests, as well as under concurrent conditions.
l Static Page: Sohu Homepage
LIGHTTPD
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
100000/100 |
64 |
60 |
462.75 |
21.6 |
100000/200 |
67 |
60 |
312.07 |
32.4 |
100000/500 |
83 |
60 |
137.24 |
72.8 |
100000/1000 Errors and packet loss occurred |
94 |
60 |
126.6 |
78.9 |
NGINX
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
100000/100 |
34.6 |
140 |
943.66 |
10.597 |
100000/200 |
35.6 |
110 |
924.32 |
10.818 |
100000/500 |
34.3 |
110 |
912.68 |
10.956 |
100000/1000 |
37 |
160 |
832.59 |
12.106 |
APACHE
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
100000/100 |
40.6 |
170 |
690.72 |
14.47 |
100000/200 |
41.1 |
180 |
685.39 |
14.59 |
100000/500 |
42.3 |
190 |
633.64 |
15.78 |
100000/1000 |
43.1 |
200 |
547.53 |
18.26 |
l Dynamic Page: Internal Community Homepage
LIGHTTPD
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
1000/100 |
50 |
200 |
33.54 |
29.816 |
1000/200 |
52 |
210 |
30.43 |
32.858 |
1000/500 |
54 |
230 |
25.79 |
38.76 |
1000/1000 |
62 |
250 |
24.83 |
40.28 |
NGINX
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
1000/100 |
53.8 |
250 |
83.12 |
12.305 |
1000/200 |
55.8 |
250 |
74.05 |
13.504 |
1000/500 |
56 |
260 |
58.99 |
16.951 |
1000/1000 |
58 |
260 |
43.41 |
23.347 |
APACHE
n/-c (ab parameter) |
cpu% |
Mem |
Requests per Second |
Time taken for tests |
1000/100 |
45.2 |
220 |
66.54 |
15.21 |
1000/200 |
46.3 |
230 |
60.75 |
15.38 |
1000/500 |
47.5 |
240 |
55.28 |
15.92 |
1000/1000 |
48.6 |
250 |
50.12 |
16.51 |
<p align="justify">cpu%</p>
</td>
<td valign="center" width="78">
<p align="justify">Mem</p>
</td>
<td valign="center" width="232">
<p align="justify">RequestsperSecond</p>
</td>
<td valign="center" width="113">
<p align="justify">Time taken for tests</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/100</p>
</td>
<td valign="center" width="92">
<p align="justify">60</p>
</td>
<td valign="center" width="78">
<p align="justify">200</p>
</td>
<td valign="center" width="232">
<p align="justify">27.37</p>
</td>
<td valign="center" width="113">
<p align="justify">36.541</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/200</p>
</td>
<td valign="center" width="92">
<p align="justify">61</p>
</td>
<td valign="center" width="78">
<p align="justify">220</p>
</td>
<td valign="center" width="232">
<p align="justify">23.82</p>
</td>
<td valign="center" width="113">
<p align="justify">41.981</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/500</p>
</td>
<td valign="center" width="92">
<p align="justify">73</p>
</td>
<td valign="center" width="78">
<p align="justify">150</p>
</td>
<td valign="center" width="232">
<p align="justify">20.59</p>
</td>
<td valign="center" width="113">
<p align="justify">48.562</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/1000</p>
</td>
<td valign="center" width="92">
<p align="justify">53</p>
</td>
<td valign="center" width="78">
<p align="justify">200</p>
</td>
<td valign="center" width="232">
<p align="justify">27.18</p>
</td>
<td valign="center" width="113">
<p align="justify">36.796</p>
</td>
</tr>
</tbody>
</table>
<p style="text-align: left;">l PHPINFO function page</p>
<p style="text-align: left;" align="justify">LIGHTTPD</p>
<table style="float: left;">
<tbody>
<tr>
<td valign="center" width="100">
<p align="justify">n/-c(ab parameter)</p>
</td>
<td valign="center" width="318">
<p align="justify">cpu%</p>
</td>
<td valign="center" width="60">
<p align="justify">Mem</p>
</td>
<td valign="center" width="131">
<p align="justify">RequestsperSecond</p>
</td>
<td valign="center" width="75">
<p align="justify">Time taken for tests</p>
</td>
</tr>
<tr>
<td valign="center" width="100">
<p align="justify">100000/100</p>
</td>
<td valign="center" width="318">
<p align="justify">45</p>
</td>
<td valign="center" width="60">
<p align="justify">20</p>
</td>
<td valign="center" width="131">
<p align="justify">168.06</p>
</td>
<td valign="center" width="75">
<p align="justify">59.504</p>
</td>
</tr>
<tr>
<td valign="center" width="100">
<p align="justify">100000/200</p>
</td>
<td valign="center" width="318">
<p align="justify">47</p>
</td>
<td valign="center" width="60">
<p align="justify">22</p>
</td>
<td valign="center" width="131">
<p align="justify">140.64</p>
</td>
<td valign="center" width="75">
<p align="justify">71.103</p>
</td>
</tr>
<tr>
<td valign="center" width="100">
<p align="justify">100000/500</p>
</td>
<td valign="center" width="318">
<p align="justify">49</p>
</td>
<td valign="center" width="60">
<p align="justify">24</p>
</td>
<td valign="center" width="131">
<p align="justify">52.80</p>
</td>
<td valign="center" width="75">
<p align="justify">189.386</p>
</td>
</tr>
<tr>
<td valign="center" width="100">
<p align="justify">100000/1000</p>
</td>
<td valign="center" width="318">
<p align="justify">The test program crashed upon reaching 4840 requests</p>
</td>
<td valign="center" width="60">
</p>
</td>
<td valign="center" width="131">
<p> </p>
</td>
<td valign="center" width="75">
<p> </p>
</td>
</tr>
</tbody>
</table>
<p style="text-align: left;" align="justify">NGINX</p>
<table style="float: left;">
<tbody>
<tr>
<td valign="center" width="169">
<p align="justify">n/-c(ab parameter)</p>
</td>
<td valign="center" width="92">
<p align="justify">cpu%</p>
</td>
<td valign="center" width="78">
<p align="justify">Mem</p>
</td>
<td valign="center" width="232">
<p align="justify">RequestsperSecond</p>
</td>
<td valign="center" width="113">
<p align="justify">Time taken for tests</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/100</p>
</td>
<td valign="center" width="92">
<p align="justify">70</p>
</td>
<td valign="center" width="78">
<p align="justify">120</p>
</td>
<td valign="center" width="232">
<p align="justify">143.46</p>
</td>
<td valign="center" width="113">
<p align="justify">69.706</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/200</p>
</td>
<td valign="center" width="92">
<p align="justify">72</p>
</td>
<td valign="center" width="78">
<p align="justify">130</p>
</td>
<td valign="center" width="232">
<p align="justify">140.57</p>
</td>
<td valign="center" width="113">
<p align="justify">71.140</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/500</p>
</td>
<td valign="center" width="92">
<p align="justify">73</p>
</td>
<td valign="center" width="78">
<p align="justify">150</p>
</td>
<td valign="center" width="232">
<p align="justify">135.87</p>
</td>
<td valign="center" width="113">
<p align="justify">73.601</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/1000</p>
</td>
<td valign="center" width="92">
<p align="justify">77</p>
</td>
<td valign="center" width="78">
<p align="justify">160</p>
</td>
<td valign="center" width="232">
<p align="justify">132.18</p>
</td>
<td valign="center" width="113">
<p align="justify">75.657</p>
</td>
</tr>
</tbody>
</table>
<p style="text-align: left;" align="justify">APACHE packet loss</p>
<table style="float: left;">
<tbody>
<tr>
<td valign="center" width="169">
<p align="justify">n/-c(ab parameter)</p>
</td>
<td valign="center" width="92">
<p align="justify">cpu%</p>
</td>
<td valign="center" width="78">
<p align="justify">Mem</p>
</td>
<td valign="center" width="232">
<p align="justify">RequestsperSecond</p>
</td>
<td valign="center" width="113">
<p align="justify">Time taken for tests</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/100</p>
</td>
<td valign="center" width="92">
<p align="justify">70</p>
</td>
<td valign="center" width="78">
<p align="justify">180</p>
</td>
<td valign="center" width="232">
<p align="justify">245.73</p>
</td>
<td valign="center" width="113">
<p align="justify">40.694</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/200</p>
</td>
<td valign="center" width="92">
<p align="justify">72</p>
</td>
<td valign="center" width="78">
<p align="justify">190</p>
</td>
<td valign="center" width="232">
<p align="justify">245.79</p>
</td>
<td valign="center" width="113">
<p align="justify">40.684</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/500</p>
</td>
<td valign="center" width="92">
<p align="justify">75</p>
</td>
<td valign="center" width="78">
<p align="justify">200</p>
</td>
<td valign="center" width="232">
<p align="justify">241.29</p>
</td>
<td valign="center" width="113">
<p align="justify">41.443</p>
</td>
</tr>
<tr>
<td valign="center" width="169">
<p align="justify">100000/1000</p>
</td>
<td valign="center" width="92">
<p align="justify">77</p>
</td>
<td valign="center" width="78">
<p align="justify">220</p>
</td>
<td valign="center" width="232">
<p align="justify">236.74</p>
</td>
<td valign="center" width="113">
<p align="justify">42.239</p>
</td>
</tr>
</tbody>
</table>
<p style="text-align: left;" align="justify">IV. Resource list of major website WEB servers</p>
<p style="text-align: left;" align="justify">Website name Operating system Web server</p>
<p style="text-align: left;" align="justify">1. Portal websites:</p>
<p style="text-align: left;" align="justify">Sohu LINUX apache 1.3.37</p>
<p style="text-align: left;" align="justify">Sina LINUX apache 2.0.54</p>
<p style="text-align: left;" align="justify">Thunder LINUX nginx 0.6.31</p>
<p style="text-align: left;" align="justify">163 LINUX apache 2.2.6</p>
<p style="text-align: left;" align="justify">2. Search engines</p>
<p style="text-align: left;" align="justify">Baidu unknown BWS 1.0</p>
<p style="text-align: left;" align="justify">Google linux gws</p>
<p style="text-align: left;" align="justify">Sougou FreeBSD apache 2.2.4</p>
<p style="text-align: left;" align="justify">Hao123 linux apache 2.2.4</p>
<p style="text-align: left;" align="justify">4. Email services</p>
<p style="text-align: left;" align="justify">126 linux apache</p>
<p style="text-align: left;" align="justify">Hotmail win2003 microsoft-IIS 6.0</p>
<p style="text-align: left;" align="justify">Sina Mail F5 Big-IP apache 2.2.8</p>
<p style="text-align: left;" align="justify">263 linux apache 2.2.6</p>
<p style="text-align: left;" align="justify">5. Blogging services</p>
<p style="text-align: left;" align="justify">Sina Blog linux nginx 0.5.35</p>
<p style="text-align: left;" align="justify">Sohu Blog linux nginx</p>
<p style="text-align: left;" align="justify">Thunder Blog linux
nginx 0.6.32
Tianya Blog F5 Big-IP Microsoft-IIS/5.0
6. Video Category
Youku Linux Apache
Tudou Linux Apache
Ku6 Linux Apache
Liujianfang Linux nginx 0.6.14
文章评论