1024programmer Nginx Deep Dive into Nginx: How We Designed for Performance and Scale

Deep Dive into Nginx: How We Designed for Performance and Scale

NGINX excels in network applications because of its unique design. Many network or application servers are mostly simple frameworks based on threads or processes. NGINX stands out for its mature event-driven framework, which can handle thousands of concurrent connections on modern hardware.

The NGINX Internals infographic starts at the top of the process framework and works its way down to reveal how NGINX handles multiple connections within a single process, and further explores how it works.

Scenario Setup — NGINX Process Model

To better understand this design pattern, we need to understand how NGINX works. NGINX has a main thread to handle privileged operations such as reading configuration files and port binding, as well as a set of working processes and auxiliary processes.

1

2

3

4

5

6

7

8

9

10

11

# service nginx restart

Restarting nginx

# ps ef forest | grep nginx

root 32475 1 0 13:36 ? 00:00:00 nginx: master process /usr/ sbin/nginx

c /</etc/nginx/nginx.conf

nginx 32476 32475 0 13:36 ? 00:00:00 _ nginx: worker <span style="fontsize:inherit !important;fontfamily:inherit;lineheight:inherit !important;font�� Accept connections, handle network communication (with new configuration environment).

  • Notifies old worker processes to gracefully roll out, and those worker processes stop accepting new connections. Once the currently processing HTTP request ends, the worker process will close the connection. The worker process exits once all connections are closed.
  • Loading a process will cause a small CPU and memory spike, but the overhead is negligible compared to the resources loaded from an active connection. The configuration file can be reloaded many times per second. NGINX worker processes that generate many waits for connections to close are generally problematic, but if they are, they can be resolved quickly.

    NGINX Binary Upgrades for Ultimate High Availability You can upgrade files online without any loss of connection, service downtime or interruption.
    Translator’s Note: When the on the fly program is running, the work can be done.

    The binary file upgrade process is similar to elegant configuration file overloading; the new NGINX main process runs parallel to the original main process and shares the listening socket. Both processes are active, handling their respective network communications. You can notify the original master process and its workers to exit gracefully.

    For a detailed description of the process, see NGINX Control

    Final remarks

    The NGINX internal infographic shows the panorama of NGINX’s high-standard functions. Behind the simple explanation is more than ten years of continuous innovation and optimization. Thanks to this, NGINX is widely used on various hardware platforms and has achieved the best performance. Even in modern times, when web applications need to be maintained for security and reliability, NGINX performs well.

    This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/deep-dive-into-nginx-how-we-designed-for-performance-and-scale/

    author: admin

    Previous article
    Next article

    Leave a Reply

    Your email address will not be published. Required fields are marked *

    The latest and most comprehensive programming knowledge, all in 1024programmer.com

    © 2023 1024programmer - Encyclopedia of Programming Field
    Contact Us

    Contact us

    181-3619-1160

    Online consultation: QQ交谈

    E-mail: [email protected]

    Working hours: Monday to Friday, 9:00-17:30, holidays off

    Follow wechat
    Scan wechat and follow us

    Scan wechat and follow us