Overview
Today we mainly compare these mainstream WEB servers: lighttpd, apache, nginx
1, LIGHTTPD
1.1 Brief introduction
ā Lighttpd is a German-led open source web server software, with very low memory overhead, low cpu usage, good performance, and abundant modules. Support FastCGI, CGI, Auth, output compression (output compress), URL rewriting, Alias āāand other important functions.
When it uses FastCGI to run PHP, it will use a few PHP processes to respond to a large amount of concurrency.
1.2 Advantages
1) From the standpoint of stability, FastCGI runs CGI in a separate process pool. When a single process dies, the system can easily discard it and then redistribute it. The process of running logic;
2) From a security perspective, FastCGI and the host server are completely independent, and fastcgi will not break the server no matter how down;
3) From a performance perspective, FastCGI The processing of dynamic logic is separated from the server, and the heavy load of IO processing is still left to the host server, so that the host server can focus on IO. For an ordinary dynamic web page, the logic processing may only have a small part, a large number of pictures, etc. Static IO processing does not require the participation of logic programs (Note 1)
4) In terms of scalability, FastCGI is a neutral technical standard and can fully support processing programs written in any language (php, java, python... )
1.3 Support operating system
- Linux(binary packages for FC3,SuSE,Debian,Gentoo,PLD-Linux,OpenWRT)
- BSD(FreeBSD,NetBSD,OpenBSD, MacOSX)
- SGIIRIX
- Windows(Cygwin)While it is known to compile cleanly on
- Solaris
- AIX
588d7#
588d7#
588d7#
05588da#935 Brief description
ā Apache is the world's number one web server. According to a survey, more than 50% of the world's web servers use apache.
ā Apache is a process-based structure. The process consumes more system expenses than threads and is not suitable for multi-processor environments. Therefore, in an Apache Web When a site expands, it is usually to increase servers or expand cluster nodes rather than increase processors. Many famous websites in the world such as Amazon, Yahoo!, W3 Consortium, Financial Times, etc. are all products of Apache.
2.2 Advantages
- can run on almost all computer platforms.
- supports the latest http/1.1 protocol
- Simple and powerful file-based configuration (httpd.conf).
- Support common gateway interface (cgi)
- Support virtual host.
- Support http authentication.
- Integrate perl.
- Integrated proxy server
- can monitor the status of the server through a web browser, and can customize the log.
- supports server-side containing commands (ssi).
- supports secure socket layer (ssl ).
- has the ability to track the user session process.
- supports fastcgi
- supports java servlets
2.3 supports the operating system
- 2#cfb7#cfdb7#Windows#
- Other
3ćNGINX
3.1 Brief description
ā Nginx is a very lightweight HTTP server written by the Russians, Nginx, It is pronounced "engine X" and 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 site in Russia, Rambler.ru. Nginx is a lightweight web server/reverse proxy server and email (IMAP/POP3) proxy server, and is issued under a BSD-like protocol. Its characteristics are that it occupies less memory and has strong concurrency. In fact, nginx's concurrency capabilities do perform better in the same type of web server. Mainland Chinese users of nginx websites include: Baidu, Jingdong, Sina, Netease, Tencent, Taobao, etc.
Nginx is written in an event-driven (epoll) manner, so it has very good performance, and is also a very efficient reverse proxy and load balancing. Studies have shown that it can support up to 50,000 concurrent connections. . It has the performance that matches Lighttpd, and there is no memory leak of Lighttpd, and Lighttpd's mod_proxy also has some problems and has not been updated for a long time. But Nginx does not support cgi mode operation, the reason is that it can reduce some of the vulnerabilities in the program. So you must use FastCGI to execute PHP programs.
3.2 Advantages
- Process static files, index files and automatic indexes;
- open file descriptor buffer;
- cacheless reverse proxy acceleration, simple Load balancing and fault tolerance;
- FastCGI, simple load balancing and fault tolerance;
- modular structure. Including filters such as gzipping, byte ranges, chunked responses, and SSI-filter. If FastCGI or other proxy servers process multiple SSIs in a single page, this process can run in parallel without waiting for each other.
- Nginx is specially developed for performance optimization. Performance is its most important consideration. The implementation pays great attention to efficiency.
- Nginx has high stability. Other HTTP servers, when encountering a peak of access, or someone maliciously initiates a slow connection, it is very likely that the physical memory of the server will be exhausted and frequent exchanges will be lost, and the server can only be restarted. For example, once Apache reaches more than 200 processes, the web response speed is obviously very slow. Nginx has adopted a staged resource allocation technology, making itThe CPU and memory usage is very low. Nginx officially stated that it maintains 10,000 inactive connections, and it only occupies 2.5M of memory, so attacks like DOS are basically useless for nginx. In terms of stability, nginx is better than lighthttpd.
- Nginx supports hot deployment. It is particularly easy to start, and it can almost run 7*24 uninterrupted, even if it runs for several months, it does not need to be restarted. You can also upgrade the software version with uninterrupted service.
3.3 operating system
- Linux
- Windows (ported version)
- other
3.41a041a04 Recommended architecture nginx as the front-end web cache system, the usual architecture is as follows:
The advantages of this structure:
- can use nginx front-end for many complex Configuration, these configurations were previously impossible or troublesome to do in Squid, such as anti-leech for directories.
- nginx front-end can directly forward some requests that do not need to be cached.
- Because nginx is more efficient than Squid, nginx caching can be used to reduce Squid pressure in some cases.
- can implement allocation strategies such as url hash.
- can enable gzip compression at the front end, so that the subsequent squid caches purely uncompressed documents, which can avoid a lot of unnecessary penetration.
- Because the stability of nginx is relatively high, lvs does not need to be adjusted frequently, it can be adjusted through nginx.
- squid's file open number is more than enough at the default 1024, but there are no fewer requests processed.
- can enable the log function of nginx to replace squid. In this way, the URL can be accurately located during real-time traffic statistics, and there is no need to use inefficient grep to filter.
- Because the load capacity of nginx is higher than that of Squid, there is no need to be particularly balanced when using lvs to divert, and the probability of a single point of failure is relatively low.
The web server front-end system architecture built by nginx and squid:
The front-end lvs and squid, according to the installation method, turn on epoll, The configuration file is copied, basically there are not many problems.
The difference between this architecture and the app_squid architecture is also the key point: the addition of a first-level middle-level proxy, the benefits of the middle-level proxy are too many:
- gzip compression: compression can be done through nginx, so, No matter if the back-end application server is apache, resin, lighttpd or even iis or other weird servers, there is no need to consider the function of compression.
- Load balancing and fault shielding: nginx can be used as a load balancing agent and has a fault shielding function. In this way, it becomes a small case to formulate a load balancing strategy based on a directory or even a regular expression.
- Convenient operation and maintenance management, and flexible plans can be made in various situations.
- Clear permissions: This machine is the responsibility of maintenance personnel who do not write programs. Programmers generally do not need to manage this machine, so if there is a failure, it is easy to find the right person. For application servers and database servers, it is best to disappear from the sight of maintenance personnel. My goal is that these services can run as long as they can run, and everything elseIt can be disposed of externally.
Comparison of 3 kinds of WEB servers
The following are some comparisons of these three web servers:
Analysis from above A more recommended solution is:
- Apache background server (mainly processing PHP and some function requests such as: Chinese url)
- Nginx front-end server (using it to take advantage of less system resources to process static pages A large number of requests)
- Lighttpd picture server
will share more devops and DBA content later, interested friends can follow~