Sunday, February 12, 2023

Nginx Architecture - A Short Explanation

Many web servers are built with a single-threaded mechanism, which has several drawbacks, including an inability to handle demanding CPU applications efficiently. When multiple threads are present in a single-threaded process, each code or command is processed one by one, in sequence. This method of processing threads consumes a large amount of memory and as a result, leads to decreased performance and slower page loading times.

Contrarily, Nginx utilizes a non-threaded, event-driven architecture, allowing it to handle multiple requests at the same time and in an asynchronous manner. Nginx has a master process responsible for reading and checking configurations, as well as binding ports. The master process generates child processes such as the cache loader process, cache manager process, and worker processes.

The worker processes manage incoming requests in a non-blocking fashion and can be easily customized by setting an auto parameter in its directive, as follows:

worker_processes auto;


Post a Comment