Linux a service of nginx service articles (concept)

nginx official website: http://nginx.org/

A, nginx and apache difference

Nginx

1 , lightweight , using C to write, the same web service, will take up less memory and resources.

2 , anti-concurrent , Nginx to epoll and kqueue as a development model, the processing request is asynchronous non-blocking load capacity than apache much higher, and apache is blocked type. In a highly concurrent nginx to maintain high performance low resource consumption , while apache in PHP under a great deal or slow front-end pressure, it is prone to surge in the number of processes, thereby denying the phenomenon services.

3 , nginx handle static files , static processing performance than apache three times or more.

4 , nginx 's highly modular design, the preparation module is relatively simple.

5 , nginx configuration is simple and regular configuration makes a lot of things simple, and can be used to change the complete configuration -t test configuration there is no problem, the Apache configuration complexity , reboot, I noticed something goes wrong, it will collapse.

6 , nginx as a load balancing server that supports 7 -layer load balancing.

7 , nginx itself is a reverse proxy server, but also as a very good mail proxy server.

8 , are particularly vulnerable to start , and can be done almost 7 * 24 non-stop operation, upgrade software version even when running several months do not need to reboot, but also to non-stop services

9 , community activists, quickly produced a variety of high-performance modules

Apache

1 , apache 's rewrite than nginx powerful, in rewrite under frequent case, the apache

2 , the Apache to the present, the module over more basic thought can be found

3 , the Apache more mature, less bug , nginx 's bug relatively more

4 , the Apache ultra-stable

5 , the Apache for PHP support is relatively simple, nginx needs to cooperate with other back-end

6 , apache handling dynamic requests have an advantage, nginx is tasteless in this regard, the general dynamic requests to apache do, nginx for static and reverse.

apache is still the mainstream, with a feature-rich, mature technology and community development

to sum up

Both the core difference is that apache is synchronized multi-process model, a connection corresponds to a process, but nginx is asynchronous, multiple connections (million level) may correspond to a process

In general, the required performance of web services, using nginx . If no performance just stable, more consideration Apache , which have various functional modules implemented former, e.g. ssl modules to better than the former, multiple items can be configured. epoll (freebsd is on kqueue) network IO model is nginx high processing performance of the underlying reasons, but not all cases are epoll victory, if itself provides static service on only a handful of a few files, the Apache 's select model perhaps more than epoll higher performance. Of course, this is only according to the network IO principle of a hypothetical model for real applications still require a repeat of the measured.

More general solution is, the front nginx anti-concurrent, back-end apache cluster, and together will be better.

Second, cluster

Briefly, the cluster is a group of independent computers, high-speed communication network consisting of a larger computer system services, each cluster node is run independently of each service server. Can communicate with each other, to provide synergy between the application server to the user, the system resources and data, and be managed in a single mode system. When a user requests a client cluster system, the cluster to the user the impression that a single server, but actually requested by the user is a set of clustered servers.

Cluster includes several features: a high-performance, price effectiveness, scalability, high availability, transparency, manageability and programmability.

1 , load balancing cluster

Common load balancing architecture includes a load-balanced cluster, high availability clustering, high performance computing clusters and so on. Here focuses on load-balanced cluster, the cluster approach does not describe other.

Load-balanced cluster to provide enterprises with a more practical, more cost-effective system architecture solutions. Clusters can load many customers centralized access request to share the load pressure as far as possible the average processing computer cluster. Customer access request load balancing typically includes application processing load and network traffic load balancing. Such a system is very suitable for using the same set of applications and services provided to a large number of user mode, each node can assume some load pressure of an access request, the access request and the dynamic allocation can be realized between nodes, for load balancing.

Cluster load balancing operation, typically by one or more front end load balancer to distribute client requests access to a set of back-end server, the entire system to achieve high performance and high availability. General high availability clustering and load balancing cluster using similar techniques, or co-worker has the characteristics of high availability and load balancing. Load balancing role: sharing of user access and data traffic to maintain business continuity, used in Web services and database services from the library and other servers.

2 , Nginx load balancing cluster description

Internet companies in the common open source clustering software: Nginx , LVS , Haproxy , Keepalived other hardware F5 , Netscaler and so on.

Strictly speaking, Nginx is just as Nginx Proxy reverse proxy use, because the effect of the performance reverse proxy functionality is load balancing cluster effect, it is also called Nginx load balancing. Reverse proxy load balancing and load balancing difference is usually packet forwarding requests (there may be rewriting data packet) is transmitted, wherein the DR mode feature is distinct from the load balancing server nodes below the point of view, receiving to request or real user client from the load balancer. The reverse proxy, reverse proxy access to a user's request is received, the user agent will re-initiate under the node server request broker, and finally the data back to the client user. In view of the server node, the node server to access the client user is a reverse proxy server, rather than the real Web site to access the user.

Nginx load balancing module has two main, ngx_http_proxy_module , ngx_http_upstream_module . The time required to compile these two modules compiled into it.

Guess you like

Origin www.cnblogs.com/renyz/p/11283840.html