Nginx---Knowledge Chapter|What can be done?

Introduction : Quickly understand Nginx

 What is/what is Nginx used for?

  Introduction

   1. Introduction

   2. Application

1. Introduction to Nginx

Nginx is the abbreviation of enginex. It is an excellent open source high-performance HTTP and reverse proxy server.

The founder of Nginx is Igor Sysoev, the Russian IT guru.

Nginx is a lightweight proxy server. As a very powerful, high-performance Web and reverse proxy server, it has many excellent features: Nginx is lighter and can handle a larger number of concurrencies (Nginx’s concurrency is among the best in the same type). The service performs very well and is used by many Chinese users, such as major Internet companies Baidu, JD.com, NetEase, Tencent, Taobao, etc.), and has high processing capabilities for HTTP concurrent connections (a single server can usually handle 30,000 to 60,000 Concurrent requests), a single link processing occupies a small amount of memory, and is usually used to process static pages and reverse proxy services.

Both Nginx and Apache adopt standardized structural designs. In the case of high concurrency, Nginx is a good substitute for Apache service: Apache's download package is very large, while Nginx's download package is very small. The current version is only a few megabytes. size, installation is very easy. It can support a maximum of 60,000 concurrent connections, which is its unparalleled advantage.

2. Nginx application

1.Http proxy and reverse proxy

   The forward proxy is a bit like the NAT network structure. Users access the website by requesting the gateway. The gateway server is responsible for connecting with the external network server to request access and return the results;

   The reverse proxy uses a proxy server to accept the client's access request, and then the server strategically forwards the request to the actual working business server, and returns the processing results from the business server to the client.

Schematic diagram

2. Load balancing

Load balancing is built on the existing network structure. It provides a cheap, effective and transparent method to expand the bandwidth of network devices and servers, increase throughput, enhance network data processing capabilities, and improve network flexibility and availability.

It uses some reverse proxy functions and algorithm strategies to achieve the purpose we want to access

Load balancing strategies mainly include: polling, weighted polling, and IP hash

Polling :

If there are three servers and three clients, the first server accepts the request during the first visit; the second server accepts the request during the second visit; and the third server accepts the request during the third visit. . . By analogy, allocate in order

 Weighted polling :

Make a weighted distribution of accepted requests. Servers with higher configurations will bear more requests, and servers with lower configurations will accept fewer requests. If the second server is twice as large as the first server, the second server can be executed twice and the first server once per unit time.

IP  hash

It performs a hash algorithm operation on the IP requested by the client, and then distributes the request for the same client IP to the same server for processing based on the hash result, which can solve the problem of session not being shared.

 3.Web caching

 Starting from version 0.7.48, Nginx supports Squid-like caching functionality. This cache treats the URL and related combinations as Key, encodes the hash with md5 and saves it to the hard disk, so it can support any URL link and also supports non-200 status codes such as 404/301/302.

Although the current Nginx Web cache service on the official website can only set the expiration time for the specified URL or status code, it does not support the PURGE instruction similar to Squid, and the cached page can be manually specified. However, through a third-party Nginx module, the specified URL cache can be specified.

NginxWeb cache service mainly consists of proxy_cache related instruction set and fastcgi_cache related instruction set. The former is used to cache the back-end content source server during reverse proxy, and the latter is mainly used to cache FastCGI dynamic programs. The functions of both are basically the same

Guess you like

Origin blog.csdn.net/weixin_56461027/article/details/130448751