If the reader has done web development before, you should know how to build a Web server to run your Web site, under Windows you may choose to use IIS, very fast, under Linux, you may first think of Apache, "one Brother" ( W3TECHS site data ranking)
Today's small series to introduce the Up-and-comer Nginx to implement the Web server. Small series in front of the blog also talked about the use of Apache, now also for the use of Nginx, the reader may later build a Web server will not know what kind of choice, O (∩_∩) o~, don't worry, small set this to give the reader analysis of Nginx and Apache differences, In the future, readers can choose their own web site characteristics to select its excellent.
The difference between Project 1:nginx and Apache
1. The advantages of Apache relative to Nginx:
Rewrite, stronger than Nginx's rewrite.
Dynamic page, Nginx processing dynamic request is chicken, general dynamic request to Apache to do, Nginx only for static and reverse.
A large number of modules, the basic thought can be found
Fewer bugs, nginx bugs relatively more hyper-stable
2. The advantages of nginx versus Apache:
Lightweight, the same as Web services, consumes less memory and resources than Apache, supports more concurrent connections, and represents greater efficiency, which makes Nginx particularly popular with virtual hosting providers. In the case of high connectivity concurrency, Nginx is a good alternative to Apache servers: Nginx is one of the most frequently chosen software platforms for owners of virtual hosting businesses in the United States. Can support the response of up to 50,000 concurrent connections, thanks to Nginx for choosing Epoll and Kqueue as the development model.
Anti-concurrency, Nginx processing requests are asynchronous non-blocking, while Apache is blocking, in high concurrency Nginx can maintain low resource consumption high performance
Highly modular design, relatively simple to write modules
Community active, a variety of high-performance modules produced quickly AH
Nginx itself is a reverse proxy server
The load balancing ability is outstanding, Nginx can support both Rails and PHP programs externally, and can support the external service as an HTTP proxy server. Nginx use C to write, whether it is the system resource cost or CPU efficiency is much better than Perlbal.
3. The core difference: Apache is a synchronous multi-process model, one connection corresponds to a process; Nginx is asynchronous, multiple connections (million levels) can correspond to a process
In general, Web services that require performance are nginx. If you don't want the performance to be stable, then Apache. The latter of the various functional modules to achieve than the former, such as the SSL module is better than the former, configurable items more. It should be noted here that Epoll (FreeBSD is kqueue) network IO model is the root cause of high performance nginx processing, but not all cases are epoll swept, if the static service itself provides only a few files, Apache Select The model may be more high-performance than Epoll.
First say select:
Socket quantity Limit: The number of sockets that can be manipulated by this mode is determined by fd_setsize, and the kernel defaults to 32*32=1024.
Operation restrictions: Through the traversal fd_setsize socket to complete the scheduling, regardless of which socket is active, are traversed (this is the reason for the slow Apache).
Besides Epoll:
Unlimited number of sockets
Unrestricted operation: Based on the reflection mode provided by the kernel, when there is active socket, the kernel accesses the socket's callback and does not need to traverse polling (which is, of course, nginx fast).
Part of the principle of small parts think readers know this is enough, at least when people ask you to choose one of the reasons you have enough to deal with, of course, small knitting also give you recommend a compromise scheme, nginx do the front-end, Apache to do the back end
Project 2: Installing Nginx