Answer the question
In order to leave comments, you need to log in
Do I understand how a web server works correctly?
I'm just starting to deal with servers, in particular I'm interested in nginx . The documentation says:
Nginx has one main and several worker processes. The main task of the main process is to read and validate configuration and manage worker processes. Worker processes perform the actual processing of requests.
Answer the question
In order to leave comments, you need to log in
For example, the nginx configuration says worker_processes 2
Nginx starts as a master process that forks the number of workers described in the config. A worker is a child independent process, in each of which one thread processes data. In total, if you have two workers specified in the config, nginx essentially works in three processes, but the web server logic is processed by just two.
Further, about unicorn - this is the backend. Its existence has nothing to do with nginx at all.
A typical scheme - nginx starts with the number of workers equal to the number of processors in the system. Further, it hangs on port 80/443 and listens. It processes incoming connections according to the logic of configs. That is, either he gives something away, or he proxies further to the backend, providing the necessary headers. The backend is already, for example, unicorn, and nginx doesn't really care if it's alive or not, it will show 200 in a normal situation and 504 if unicorn falls off.
The nginx worker has nothing to do with unicorn, consider them as independent things
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question