Home > Backend Development > PHP Tutorial > Comparative analysis of three major WEB servers (apache, lighttpd, nginx)

Comparative analysis of three major WEB servers (apache, lighttpd, nginx)

WBOY
Release: 2016-07-30 13:31:03
Original
1718 people have browsed it

1. lighttpd

Lighttpd is a program with very low memory overhead, low CPU usage, good performance, and rich modules. lighttpd is one of the better ones among the many OpenSource lightweight web servers. Supports FastCGI, CGI, Auth, output compression, URL rewriting, Alias ​​and other important functions.

Lighttpd uses fastcgi to run php, which will use very few PHP processes to respond to a large amount of concurrency.

The advantage of Fastcgi is:

· From a stability point of view, fastcgi runs cgi in an independent process pool. If a single process dies, the system can easily discard it and then reassign a new process to run the logic.

·                                                                                                                                           with                         out out out out out out out of safety out   out of   fastcgi and host server. The IO processing is still left to the host server, so that the host server can concentrate on IO. For an ordinary dynamic web page, the logical processing may only be a small part, and the static IO processing of a large number of pictures does not require the participation of the logic program at all (note 1)

· In terms of scalability, fastcgi is a neutral technical standard that can fully support processing programs written in any language (php, java, python...)

2. apache

apache is the world's No. A web server, according to a survey conducted by netcraft (

www.netsraft.co.uk

), more than 50% of the world's web servers are using apache.In April 1995, the earliest apache (0.6. Version 2) is published and released by the Apache Group. The Apache Group is a non-profit organization that operates entirely through the Internet. It determines what content should be included in the standard distribution of the Apache web server. Anyone is allowed to modify hidden errors and provide new ones. Features and porting it to new platforms, among other tasks. When new code is submitted to the Apache group, the group reviews its specific content, tests it, and if it is satisfied, the code is integrated into Apache Among the major distributions.

apache features:

1) 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) Support common gateway interface (cgi)

5) Support virtual host.

6) Support http authentication.

7) Integrate perl.

8) Integrated proxy server

9) The status of the server can be monitored through a web browser, and the log can be customized.

10) Supports server-side inclusion commands (ssi).

11) Supports secure socket layer (ssl).

12) Has user session process Tracking capabilities.

13) Support fastcgi

14) Support java servlets

3.nginx

Nginx is a very lightweight HTTP server written by Russians, Nginx, it is pronounced as "engine X", is A high-performance HTTP and reverse proxy server, as well as an IMAP/POP3/SMTP proxy server. Nginx was developed by Russian Igor Sysoev for the second most visited Rambler.ru site in Russia.

Nginx is written in an event-driven manner, so it has very good performance and is also a very efficient reverse proxy and load balancing. It has the performance that matches Lighttpd, but does not have the memory leak problem of Lighttpd, and Lighttpd's mod_proxy also 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 caused by this. Therefore, FastCGI must be used to execute PHP programs.

nginx, as an HTTP server, has the following basic features:

Processing static files, index files and automatic indexing; turning on file descriptor buffering.

Cacheless reverse proxy acceleration, simple load balancing and fault tolerance.

FastCGI, simple load balancing and fault tolerance.

Modular structure. Including gzipping, byte ranges, chunked responses, and SSI-filter and other filters. If multiple SSIs present in a single page are processed by FastCGI or another proxy server, this processing can run in parallel without waiting for each other.

Nginx is specially developed for performance optimization. Performance is its most important consideration, and implementation pays great attention to efficiency. It supports the kernel Poll model and can withstand the test of high load. Reports indicate that it can support up to 50,000 concurrent connections.

Nginx has high stability. When other HTTP servers encounter access peaks, or someone maliciously initiates a slow connection, it is also likely to cause the server's physical memory to be exhausted, frequent swapping, and loss of response, and the server can only be restarted. For example, once apache currently has more than 200 processes, the web response speed will be obviously very slow. Nginx adopts phased resource allocation technology, which makes its CPU and memory usage very low. nginx officially states that it maintains 10,000 inactive connections and it only occupies 2.5M of memory, so attacks like DOS are basically useless to nginx. In terms of stability, nginx is better than lighthttpd.

Nginx supports hot deployment. It is particularly easy to start, and can run almost 24/7 without any interruption, even if it runs for several months, it does not need to be restarted. You can also upgrade the software version without interrupting service.


Proxy Good Very goodNot supportedRelatively smallbadAverageaverageGoodSupportedNormalNot supported

server

Apache

Nginx

Lighttpd

very good

Fcgi

bad

good

Hot deployment

Not supported

Supported

The system pressure is relatively high

Very small

stability

good

very good

safe Sex

Good

Average

technical support

very good

rare

Static file processing

average

very Good

Vhosts virtual host

Supported

Not supported

Reverse proxy

average

very Good

Session sticky

Supported

Not supported

Note: On a relatively larger website, the server cost saved is undoubtedly objective. Some small websites often don't have many servers. If they use traditional web servers like Apache, they seem to be able to survive. But it has obvious disadvantages: Apache is easily overloaded when dealing with traffic bursts (such as crawlers or Digg effects). In this case, Nginx is most suitable.

Recommended solution:

Apache backend server (mainly handles php and some function requests such as: Chinese url)

Nginx front-end server (use it to occupy less system resources Gain the advantage to handle a large number of requests for static pages)

Lighttpd image server

In general, with the improvement of nginx, it will become the mainstream of web server in the future.


We will test the response time of 3 kinds of software in response to requests and concurrency of dynamic pages and static pages respectively

l                                                                                                                                                                                          -c (ab parameter)

cpu%

Mem100000/1006460100000/2006760100000/50083 60100000/100060n/-c (ab parameter)

RequestsperSecond

Time taken for tests

462.75

21.6

312.0 7

32.4

137.24

72.8

Error packet loss

94

126.6

78.9

NGINX

cpu%

Mem100000/10034.6140100000/20035.6110100000/50034.3110100000/100037160n/-c (ab parameter)

Re questsperSecond

Time taken for tests

943.66

10.597

924.32

10.818

912.68

10.956

832.59

12.106

APACHE

cpu%

Mem100000/10040.6170100000/20041.1180100000/50042.3190100000/100043.1200

RequestsperSecond

Time taken for tests

690.72

14.47

685.39

14.59

633.64

15.78

547.53

18.26

l Dynamic page internal community homepage

LIGHTTPD

n/-c (ab parameter)

cpu%

M em

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

l                                                     PHPINFO function page Mem

RequestsperSecond
Time taken for tests59.50471.103189.386

100000/100

45

20

168.06

100000/200

47

22

140.64

100000/500

49

24

52.80

100000/1000

The test program died when the request reached 4840

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

APACHE packet 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

Website name Operating system Web server

1. Portal website category:

Sohu LINUX apache 1.3.37

Sina LINUX apache 2.0.54

Thunder LINUX nginx 0.6.31

163 LINUX apache 2.2.6

2.Search class

Baidu unknown BWS 1.0

Google linux gws

Sougou FreeBSD apache 2.2.4

Hao123 linux apache 2.2.4

4. Email class

126 linux apache

Hotmail win2003 microsoft-IIS 6 .0

Sina Mailbox F5 Big-IP apache 2.2.8

263 linux apache 2.2 .6 类5. Blog 浪 Sina blog Linux nginx 0.5.35

Sohu blog Linux nginx

Thunder blog Linux nginx 0.6.32

Tianya blog F5 Big-IP microsoft-IIS/5.0

6. Video category

Youku                                                                                                                                                                             ​ nginx 0.6.14

The above has introduced the comparative analysis of the three major WEB servers (apache, lighttpd, nginx), including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template