Comparison and Analysis of three major WEB servers (apache, lighttpd, and nginx)
I. Software introduction (apacheLighttpdNginx)
1. lighttpd
Lighttpd features low memory overhead, low cpu usage, good performance, and rich modules. Lighttpd is one of the many OpenSource lightweight web servers. Supports FastCGI, CGI, Auth,Output compress, URL rewriting, Alias, and other important functions.
Lighttpd uses fastcgi to run php, which uses a small number of PHP processes to respond to a large amount of concurrency.
Fastcgi has the following advantages:
·In terms of stability, fastcgi uses an independent process pool to run cgi. When a single process dies, the system can easily discard it and re-allocate a new process to run the logic.
·In terms of security, fastcgi is completely independent from the host server, and fastcgi will not crash the server even if it is down,
·In terms of performance, fastcgi separates the processing of dynamic logic from the server,Heavy IO processing is left to the host server,In this way, the host server can focus on IO. For a common dynamic web page,Logical processing may only have a small part,Large volumes of static IO processing such as images do not require the involvement of Logic Programs (Note 1)
·In terms of scalability, fastcgi is a neutral technical standard,Fully supports processing programs written in any language (php, java, python ...)
2. apache
Apache is the world's top web server,According to netcraft (www. netsraft. co. uk), more than 50% of the world's web servers are using apache.
April 1995,The earliest apache version 0.6.2 was released by apache group. apache groupIs a non-profit organization that operates completely over the internet,It determines what content should be included in the standard release of apache web server.Allow anyone to modify hidden errors,Provide new features and port them to the new platform,And other work.When the new Code is submitted to the apache group,The Group reviews its specific content,Test,If satisfied,This code will be integrated into the main apache release.
ApacheFeatures:
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 hosts.
6)Http authentication is supported.
7)Integrate perl.
8)Integrated Proxy Server
9)You can use a web browser to monitor the server status,You can customize logs.
10)Supports server-side commands (ssi ).
11)Supports Secure socket Layer (ssl ).
12)Tracking the user session process.
13)Fastcgi support
14)Support for java servlets
3. nginx
Nginx is a lightweight HTTP server compiled by Russians. It is pronounced as "engine X" and is a high-performance HTTP and reverse proxy server, it is also an IMAP/POP3/SMTPProxy Server. Nginx is a RussianIgor Sysoev is the second highest traffic in RussiaRambler.ru site development.
Nginx is written in event-driven mode, so it has excellent performance and is also a very efficient reverse proxy and load balancing. It has matchingThe performance of Lighttpd does not cause Lighttpd Memory leakage, and the mod_proxy of Lighttpd has some problems and has not been updated for a long time. However, Nginx does not support running in cgi Mode because it can reduce some program vulnerabilities. Therefore, you must use FastCGI to execute PHP programs.
As an HTTP server, nginx has the following basic features:
Process static files, index files, and automatic indexes; enable file descriptor buffering.
Non-Cache reverse proxy acceleration, simple load balancing and fault tolerance.
FastCGI, simple load balancing and fault tolerance.
Modular structure. Including gzipping, byte ranges, chunked responses, andSSI-filter and Other filters. If FastCGI or another Proxy Server Processes multiple SSI in a single page, the processing can run in parallel without waiting for each other.
Nginx is designed for performance optimization. performance is the most important consideration, and efficiency is very important in implementation. It supports the kernel Poll model and is able to withstand the high load test. The report shows that it supports up50,000 concurrent connections.
Nginx has high stability. When other HTTP servers encounter access peaks or maliciously initiate slow connections, the server may also consume physical memory and exchange frequently. In this case, the server can only be restarted if the response is lost. For example, once apache has over 200 processes, the web response speed is obviously very slow. Nginx adopts the phased Resource Allocation technology, making it very low in CPU and memory usage. Nginx officially said that it maintains 10,000 idle connections, which only occupies MB of memory. Therefore, DOS-like attacks are basically useless for nginx. In terms of stability, nginx is better than lighthttpd.
Nginx supports hot deployment. It is particularly easy to start,In addition, it can run almost without interruption and does not need to be restarted even if it is running for several months. You can also upgrade the software version without interrupting the service.
Ii. Comparison of the three WEB servers:
Server
Apache
Nginx
Lighttpd
Proxy
Very good
Very good
Average
Rewriter
Good
Very good
Average
Fcgi
Not good
Good
Very good
Hot deployment
Not Supported
Supported
Not Supported
System pressure comparison
Very large
Very small
Relatively small
Stability
Good
Very good
Not good
Security
Good
Average
Average
Technical Support
Very good
Very few
Average
Static File Processing
Average
Very good
Good
Vhosts Virtual Host
Supported
Not Supported
Supported
Reverse Proxy
Average
Very good
Average
Session sticky
Supported
Not Supported
Not Supported
Note: in relatively large websites, the server cost saved is undoubtedly objective. Some small websites often have few servers.ApacheThis type of traditionWebThe server also seems to be supported. But it has obvious drawbacks:ApacheWhen processing traffic bursts (such as crawlers orDiggEffect)It is easy to overload.NginxMost suitable.
Recommended solution:
ApacheBackend server (mainly processing php and some functional requests such as Chinese URLs)
NginxFront-End Server (using it to handle a large number of static page requests with the advantage of using less system resources)
LighttpdImage Server
In general, the improvement of nginx functions will make it the mainstream for web servers in the future.
Iii. Performance Testing:
The response time for dynamic and static page requests and concurrency of the three software types will be tested respectively.
LStatic Page Sohu Homepage
LIGHTTPD
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
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
Error Packet Loss
94
60
126.6
78.9
NGINX
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
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
RequestsperSecond
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
LDynamic page internal Community Homepage
LIGHTTPD
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
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
RequestsperSecond
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
RequestsperSecond
Time taken for tests
100000/100
60
200
27.37
36.541
100000/200
61
220
23.82
41.981
100000/500
73
150
20.59
48.562
100000/1000
53
200
27.18
36.796
LPHPINFO function page
LIGHTTPD
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
Time taken for tests
100000/100
45
20
168.06
59.504
100000/200
47
22
140.64
71.103
100000/500
49
24
52.80
189.386
100000/1000
When the request reaches 4840, the test program will die.
NGINX
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
Time taken for tests
100000/100
70
120
143.46
69.706
100000/200
72
130
140.57
71.140
100000/500
73
150
135.87
73.601
100000/1000
77
160
132.18
75.657
APACHEPacket Loss
N/-c (AB parameter)
Cpu %
Mem
RequestsperSecond
Time taken for tests
100000/100
70
180
245.73
40.694
100000/200
72
190
245.79
40.684
100000/500
75
200
241.29
41.443
100000/1000
77
220
236.74
42.239
4. List of WEB Server resources of various websites
Website nameOperating SystemWeb Server
1. portal website:
SohuLINUXApache 1.3.37
SinaLINUXApache 2.0.54
ThunderLINUXNginx 0.6.31
163LINUXApache 2.2.6
2. Search
BaiduUnknown(BWS 1.0)
GoogleLinuxGws
SougouFreeBSDApache 2.2.4
Hao123LinuxApache 2.2.4
4.Email
126LinuxApache
HotmailWin2003Microsoft-microsoft IIS 6.0
Sina mailF5 Big-IPApache 2.2.8
263LinuxApache 2.2.6
5.Blog
Sina BlogLinuxNginx 0.5.35
Sohu blogLinuxNginx
Thunder blogLinuxNginx 0.6.32
Tianya blogF5 Big-IPMicrosoft-Microsoft IIS/5.0
6. Video
YoukuLinuxApache
TudouLinuxApache
Ku6LinuxApache
Room 6LinuxNginx 0.6.14