What is nginx?

This is the back-end small class of the Xiuzhen Academy. Each shared article is from

[background introduction] [knowledge analysis] [common problems] [solutions] [coding practice] [extended thinking] [more discussion] [References]

Eight aspects of in-depth analysis of back-end knowledge / skills. This article shares:

[what is nginx?]

Hello, I am the eighth student of Shanghai Branch of it Academy. I am an honest, pure and kind java programmer. Today, I'd like to share with you the third task of Java on the official website of the academy to expand the knowledge points in thinking - what is nginx?

1 background introduction

1.1 the competitors of web server nginx - Apache, lighttpd, Tomcat, jetty and IIS are all web servers, It is also called WWW (World Wide Web) server. Accordingly, it also has the basic functions of web server: Based on the rest architecture style, it uses uniform resource identifier (URI) or uniform resource locator (uniform resource locator, URL) as the basis for communication, it provides various network services for client programs such as browsers through HTTP. However, these web servers are subject to many limitations in the design stage, such as the scale of Internet users, network bandwidth, product characteristics, etc., and their respective positioning and development direction are different The characteristics and applications of this web server are very distinct. Comparison: 1.2 web server comparison Tomcat and jetty are Java oriented. They are inherently heavyweight web servers, and their performance is not comparable with nginx, which is omitted here.

IIS can only run on Windows operating systems. As a server, windows is not as stable as UNIX like operating system in terms of other performance. Therefore, IIS may be "ignored" when high-performance web server is required.

Apache has been developing for a long time, and it is the undisputed world's largest web server. Apache has many advantages, such as stability, open source, cross platform, etc., but it has appeared for too long. In the era of its rise, the industrial scale of the Internet is far less than today, so it is designed as a heavyweight web server that does not support high concurrency. On the Apache server, if tens of thousands of concurrent HTTP requests are accessed at the same time, it will consume a lot of memory on the server. The inter process switching of hundreds of Apache processes by the operating system kernel will also consume a lot of CPU resources and reduce the average response speed of HTTP requests. All these determine that Apache cannot become a high-performance web server, This also led to the emergence of lighttpd and nginx.

Lighttpd, like nginx, is a lightweight and high-performance web server. European and American industry developers prefer lighttpd, while domestic companies prefer nginx and use lighttpd less.

1.3 why nginx? (1) Faster (2) high scalability (3) high reliability (4) low memory consumption (5) a single machine supports more than 100000 concurrent connections (6) hot deployment (7) the most free BSD license agreement

2 knowledge analysis

Reverse proxy: reverse proxy (reverse proxy) means that the proxy server is used to accept the connection request on the Internet, then forward the request to the upstream server in the internal network, and return the results obtained from the upstream server to the client requesting connection on the Internet. At this time, the external performance of the proxy server is a web server. Acting as a reverse proxy server is also a kind of nginx Common usage (the reverse proxy server must be able to handle a large number of concurrent requests). Dynamic and static separation because nginx is "powerful" Because of its high concurrency and high load capacity, it generally acts as a front-end server to directly provide static file services to clients, and uses Apache, Tomcat and other servers to process dynamic resources to realize dynamic and static separation. As a proxy server, load balancing generally needs to forward requests to the cluster of upstream servers. Load balancing here refers to selecting a strategy to distribute requests evenly to each upstream server as far as possible.

3 frequently asked questions

How to reduce the load of upstream servers?

4 Solutions

Using the reverse proxy of nginx can reduce the concurrency pressure of upstream servers.

5 coding practice

Preparations: configure two tomcat1 (Port 8080) and tomcat2 (port 8081) locally, create a test file, package it into a test.war package, add it to the webapps directory of tomcat1 (Port 8080) and tomcat2 (port 8081), and run Tomcat

6 extended thinking

(1) Nginx forward proxy and reverse proxy (2) upstream polling mechanism in nginx (3) how does nginx achieve high concurrency?

7 references

Tao Hui, in-depth understanding of nginx: module development and architecture analysis

8 more discussion

Ppt link video link

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>