Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

The characteristics of Nginx


May 23, 2021 Nginx Getting started


Table of contents


Nginx features

Nginx, as an HTTP server, has several basic features:

  • Handle static files, index files, and automatic indexes;

  • Cacheless reverse proxy acceleration, simple load balancing and fault tolerance.

  • FastCGI, simple load balancing and fault tolerance.

  • Modular structure. I ncludes filters such as gzipping, byte ranges, chunked responses, and SSI-filters. If multiple SSIes that exist on a single page are processed by FastCGI or other proxy servers, this processing can run in parallel without waiting for each other.

  • Support for SSL and TLSSNI.

Nginx was developed for performance optimization, with performance as its most important consideration, with a high focus on efficiency in implementation. It supports the kernel Poll model, can withstand high loads, and has been reported to support up to 50,000 connecteds.

Nginx is highly stable. O ther HTTP servers, when experiencing spikes in access, or when someone maliciously initiates a slow connection, can also cause the server to run out of physical memory, lose its response, and only restart the server. F or example, once the current apache is up to more than 200 processes, the web response rate is significantly slower. N ginx, on the other end, has adopted a phased resource allocation technique that makes its CPU and memory footprint very low. N ginx officially says it keeps 10,000 inactive connections, which account for only 2.5M of memory, so an attack like DOS is basically useless to Nginx. In terms of stability, Nginx is better than lighthttpd.

Nginx supports hot deployment. I t's particularly easy to start up, and it's almost 7x24, with no need to restart even if it's been running for months. You can also upgrade the software version without uninterrupted service.

Using the master-slave model, Nginx takes full advantage of SMP and reduces the blocking latency of work processes on disk I/O. You can also limit the number of connections per process when calling with select()/poll().

Nginx code quality is very high, the code is very standardized, the method is mature, the module extension is also very easy. I n particular, the powerful Upstream and Filter chains are notable. U pstream lays a good foundation for writing modules for communication with other servers, such as reverse proxy. T he coolest part of the Filter chain is that each filter doesn't have to wait for the previous filter to finish executing. I t can use the output of the previous filter as the input to the current filter, which is a bit like unix's pipeline. This means that a module can start compressing requests sent from the back-end server and can turn the compressed flow to the client before the module receives the entire request from the back-end server.

Nginx has significantly improved performance with some of the latest features available from os, such as support for sendfile (Linux 2.2 plus), accept-filter (FreeBSD4.1 plus), and TCP_DEFER_ACCEPT (Linux 2.4 plus).

Of course, Nginx is still very young, more or less there are some problems, such as: Nginx is created by Russians, although in previous years the documentation is relatively small, but the current documentation is more comprehensive, the majority of English materials, Chinese information is also more, and there are specialized books and materials to find.

Nginx's authors and communities are constantly working hard to improve, and we have reason to believe that Nginx will continue to share the lightweight HTTP server market at a high rate of growth and have a better future.