In addition to load balancing, Nginx can do a lot, limit, cache, black and white lists, etc.

Nginx now should be the hottest web server and reverse proxy, not one.

She was born in Russia, is a high-performance web server, especially at high concurrency, compared to Apache, has excellent performance. That in addition to load balancing, she what other uses it, let's look at the next.

92c68c8df1fb4354baf4db0ab2e67187


A static agent

Nginx good at handling static files, is a very good picture, a file server. To put all static resources on nginx, can apply static and dynamic separation, better performance.

Second, load balancing

Nginx can be achieved through the reverse proxy load balancing services, avoiding the single server node fails, the request is forwarded to a different server according to a certain strategy, to achieve the effect of the load. Common load balancing strategies,

6333699b60a341ccad28a8b52861e284



1, polling

Requests sequentially alternately assigned to the back-end server, the rear end of it balanced treat each server, without regard to the actual number of connections the server and the current system load.

2, WRR

Different back-end server may load the machine configuration and the current system is not the same, they are under pressure is not the same. A high-profile, low-load machine configuration higher weight, more please let process; arranged low, high load machines, to assign a lower weight, reduce the system load, weighted round-robin well address this issue and request order according to their weights and assigned to the rear end.

3, ip_hash (source address hashing)

The client's IP address acquired, calculating a value obtained by the hash function, the size of the server list modulo operation using this value, the result is that the client wants to access the server's sequence number. Using the source address hashing load balancing, the same IP address of the client when the same back-end server list, each time it is mapped to the same back-end server to access it.

4, Random

Random algorithm system, in accordance with the size of the list of values ​​randomly selected back-end servers to which a server is accessed.

5, least_conn (the minimum number of connection method)

Since the back-end server different configuration, processing the request for fast or slow, the minimum number of connector connection method according to the current back-end server, wherein the current backlog dynamically select the minimum number of connections a server to process the current request to improve the back-end service efficiency as much as possible, we will be responsible for reasonable diversion to each server.

Third, the current limit

Nginx limiting module is based on a leaky bucket algorithm implemented in a highly concurrent scenarios very practical.

92e937b9551448b39aa229cf8b758c0f



1, the configuration parameters

1) limit_req_zone defined at http block, $ binary_remote_addr means storing the client IP address in binary form.

2) shared memory region defined IP Zone status and URL access frequency. zone = keyword identifies the name of the region, as well as colon followed by area size. 16000 status information about the IP address of 1MB, so the sample can be stored in the region 160 000 IP addresses.

3) Rate defines the maximum rate of requests. Example the rate can not exceed 100 requests per second.

2, the current limiting provided

burst queue size, nodelay no time limit between a single request.

Fourth, the cache

1, browser cache, cache static resources with expire.

306f021006a44d74b2e04f9de4dec7bb



2, the cache proxy layer

6f6f1ceefacf4ee0b57be13c34b38543



Fifth, black and white list

1, limited flow whitelist

a02902f11df741f785598aff4d47f456



2, blacklist

30743406f2e7466f95c5676a866011ff



Well, the above is nginx several common features, static separation, load balancing, current limit, caching, black and white lists, etc., you understand yet?

Finally, to share with a [combat] Nginx documentation, Forward this article and follow the small series, and then join the group (Java fill the pit road) 789 337 293 to free access to!



Guess you like

Origin blog.51cto.com/13399166/2405298