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 basic concepts and principles of Nginx?

2025-04-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail what the basic concepts and principles of Nginx are. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

I. basic concepts of Nginx

(engine x) is a high-performance HTTP and reverse proxy web server, while also providing IMAP/POP3/SMTP services. It is characterized by less memory and strong concurrency ability. in fact, the concurrency ability of nginx performs better in the same type of web server. Chinese mainland uses nginx website users: Baidu, JD.com, Sina, NetEase, Tencent, Taobao and so on.

Nginx is developed for performance optimization, which is the most important consideration of the device. It pays great attention to efficiency in implementation, can withstand the test of high load, and is reported to support up to 50000 concurrent connections.

Nginx can not only be a reverse proxy to achieve load balancing, but also can be used as a forward proxy to access the Internet and other functions.

Second, reverse agency

Configure the proxy server on the client (browser) and access the Internet through the proxy server. The proxy object is the client, and I don't know who the server is.

The client can access it without any configuration, just send the request to the reverse proxy server, and the reverse proxy server selects the target server, gets the data and returns it to the client. External only one server, exposed is the reverse proxy server address, hiding the real server IP address. The proxy object is the server, and I don't know who the client is.

III. Load balancing

The client sends multiple requests to the server, the server processes the request, some may have to access the database, and the server returns the results to the client after processing.

This architecture mode is single and suitable for the case of few concurrent requests, but how to solve it when the amount of concurrency is large?

First of all, you may want to upgrade the server configuration, but the performance improvement of the hardware can not meet the growing demand, so think of the server cluster, increase the number of servers, and then change the original request for a single server to distribute the request to multiple servers and distribute the load to multiple servers, which is what we are talking about.

IV. Separation of movement and movement

In order to speed up the parsing speed of the website, dynamic pages and static pages can be parsed on different servers to reduce the pressure on the server and speed up the parsing speed.

Fifth, principle

Mater&worker

After receiving the signal, the master assigns the task to the worker for execution, and there can be multiple worker.

VI. How does worker work

After the client sends a request to master, the mechanism for worker to get the task is neither direct allocation nor polling, but a contention mechanism, which "grabs" the task and then executes the task, that is, select the target server tomcat, etc., and then return the result.

Worker_connection

Sending a request took up two or four connections to the woker.

The maximum concurrency of ordinary static access is: worker_connections * worker_processes/ 2 + 2 / 2

If HTTP is used as a reverse proxy, the maximum number of concurrency should be worker_connections * worker_processes/ 4 / 4.

Of course, it is not better to have as many worker numbers as possible. It is most appropriate when the number of worker is equal to the number of CPU on the server.

Advantages:

You can use nginx-s reload for hot deployment and nginx for hot deployment

Each woker is an independent process. If there is a problem with one of the woker, the others will continue to compete to implement the request process without causing service interruption.

This is the end of the article on "what are the basic concepts and principles of Nginx". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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