Home >Backend Development >PHP Tutorial >nginx infrastructure
Key constraints in web server design
Performance
Network performance, single request latency, network efficiency
Scalability
Simplicity
Modability
Evolvability, scalability, Customizability, configurability, reusability
Visibility
The extent to which the operation of key components can be monitored
Portability
Reliability
nginx’s architectural design
Excellent modular design
Highly abstract module interface
All modules follow the same ngx_module_t interface design specification. This approach brings good simplicity, static scalability, and reusability
The module interface is very simple and highly flexible
The basic interface ngx_module_t of the module is simple enough and only involves module initialization, exit and processing of configuration items
The ngx_module_t structure is a common interface for all modules. It only defines init_master, init_module, init_process, init_thread, exit_thread, exit_process, and exit_master;
The commands array of type ngx_command_t specifies how the module handles configuration items.
Design of configuration module
ngx_conf_module provides high availability, high scalability, high customizability, and high scalability
Simplification of the core module interface
The official core type module has a total of 6 specific modules: ngx_core_module , ngx_errlog_module, ngx_events_module, ngx_openssl_module, ngx_http_module, ngx_mail_module
Multi-level, multi-category module design
Event-driven architecture
nginx will not use processes or threads as event consumers. The so-called event consumer can only be a certain module.
Multi-stage asynchronous processing of requests
Decompose the blocking method into two stages according to the relevant triggering events
Decompose the blocking method call into multiple stages of method calls according to time
When "doing nothing" and must wait When the system's response causes the process to idle, use a timer to divide the stages
If the blocking method cannot continue to be divided at all, you must use an independent process to execute this blocking method
Management process, multi-worker process design
Advantages:
Platform-independent code implementation
Design of memory pool
This memory pool The biggest advantage is: integrating multiple operations of requesting memory from the system into one operation, which greatly reduces the consumption of CPU resources and reduces memory fragmentation
Using the http filtering module of the unified pipeline filter mode
The core structure in the nginx framework Body ngx_cycle_t
ngx_listening_t structure
ngx_cycle_t structure
').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });The above has introduced the nginx infrastructure, including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.