Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the uses of Nginx

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly shows you "what is the use of Nginx", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "what is the use of Nginx" this article?

Nginx should be the most popular web and reverse proxy server right now, not one of them. It is a high-performance web server born in Russia, especially in the case of high concurrency, which has excellent performance compared to Apache. Besides load balancing, what other uses does she have? let's take a look.

I. static agent

Nginx is good at dealing with static files and is a very good image and file server. Putting all the static resources on nginx can make the application dynamic and static separation, and the performance is better.

Second, load balancing

Nginx can achieve load balancing of services through reverse proxy, avoid single node failure of the server, and forward requests to different servers according to a certain strategy to achieve the effect of load. The commonly used load balancing strategies are

1. Polling

The requests are distributed sequentially to the back-end servers, which treats each server evenly, regardless of the actual number of connections to the server and the current system load.

2. Weighted polling

Different back-end servers may not have the same machine configuration and current system load, so their resilience is also different. Machines with high configuration and low load are configured with higher weights to handle more requests, while machines with low and high loads are assigned lower weights and lower system load. Weighted polling can handle this problem well and assign requests sequentially and according to weights to the backend.

3. Ip_hash (source address hash)

According to the IP address of the client, a numerical value is calculated by the hash function, and the value is used to modularize the size of the server list. The result is the serial number of the client to access the server. The source address hash method is used for load balancing. Clients with the same IP address will be mapped to the same backend server for access every time when the list of backend servers remains unchanged.

4. Random

Through the random algorithm of the system, one of the servers is randomly selected for access according to the list size of the back-end servers.

5. Least_conn (minimum number of connections method)

Because the configuration of the back-end server is different, and the processing of the request is fast and slow, according to the current connection situation of the back-end server, the minimum connection method dynamically selects the server with the least backlog of connections to deal with the current request, improves the utilization efficiency of the back-end service as much as possible, and will be responsible for reasonable diversion to each server.

III. Current restriction

The current limiting module of Nginx is based on leaky bucket algorithm and is very practical in high concurrency scenarios.

1. Configuration parameters

1) limit_req_zone is defined in the http block, and $binary_remote_addr represents the binary form in which the client IP address is saved.

2) Zone defines the shared memory area of IP status and URL access frequency. The name of the area identified by the zone=keyword, and the size of the area followed by the colon. The status information of 16000 IP addresses is about 1MB, so the area in the example can store 160000 IP addresses.

3) Rate defines * request rate. The rate in the example cannot exceed 100 requests per second.

2. Set current limit

Burst queue size. Nodelay does not limit the time between individual requests.

IV. Caching

1. Browser cache, static resource cache uses expire.

2. Proxy layer caching

V. Black and white list

1. Unlimited whitelist

2. Blacklist

These are all the contents of this article entitled "what are the uses of Nginx?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report