Understanding Nginx’s Three Process Types: Master, Worker, and Cache
This article explains the three types of Nginx processes—master, worker, and cache—detailing each one's responsibilities, from configuration loading and socket management to request handling, cache indexing, and inter‑process communication, while also covering smooth reloads, upgrades, and cache index management.
Master Process
The master process starts when Nginx launches and handles communication with the outside world as well as managing internal processes.
Main responsibilities
Read and validate configuration files.
Create, bind, and close sockets.
Generate, manage, and terminate worker processes according to configuration.
Receive commands such as restart, upgrade, or shutdown.
Perform seamless reloads and upgrades without service interruption, and roll back on failure.
Open log files and acquire file descriptors.
Worker Process
Generated by the master process, the number of worker processes is defined in the configuration and they live for the entire lifetime of the master.
Main responsibilities
Accept incoming requests.
Pass requests through various functional modules for filtering.
Perform I/O operations to obtain response data.
Communicate with backend servers and receive processed results.
Cache data, access cache indexes, query and retrieve cached content.
Send the final response back to the client.
Receive commands from the master process such as restart, upgrade, or shutdown.
Cache Process
There are two types of cache processes.
Cache index rebuilding process
Created by the master process after Nginx starts; it exits automatically once the cache metadata reconstruction is complete. It scans the cache directory structure and builds an in‑memory index database.
Cache index management process
Exists for the entire lifetime of the master process and is responsible for determining whether cached metadata has expired after updates.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java High-Performance Architecture
Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
