Is nginx the network IO of Synchronize or the asynchronous network IO?

as mentioned, all I know is that nginx is multi-process. The main process (parent process) registers the IO event with the kernel through epoll. When the IO event occurs, the kernel sends a signal to the parent process, which is the parent process notifies a child process to go to the kernel buffer to process the data. In other words, nginx uses "IO multiplexing". IO multiplexing means that the user process needs to use a thread of its own to copy data from the kernel buffer to the user buffer, which is Synchronize"s.

I don"t know if what I understood above is correct, but I read a lot of information on the Internet saying that nginx uses the asynchronous IO model. My understanding of asynchronous IO is: when the data reaches the kernel buffer, the kernel is responsible for copying the data from the inner buffer and the buffer to the user buffer.

so what exactly is the network model of nginx? And ask the god for advice! -sharp-sharp title text-sharp-sharp

Jun.05,2021

I understand that nginx's network IO is Synchronize's in a single concrete process. Because it is blocked by the network when it is processed.


POSIX defines: An asynchronous operation causes the requesting process to be blocked until that O operation does not cause the requesting process to be blocked;
A synchronous I POSIX O operation causes the requesting process to be blocked until that O operation completes;

epoll requires the user thread to read and write itself when the kernel returns a ready event, which is blocked, so it is Synchronize rather than asynchronous.


nginx generally uses epoll, in linux. It uses a registered callback function, which is automatically called when the data is ready. This process is actually blocked. Master assigns a connection to the worker process, and worker can only process one request if it is blocked at the same time. And nginx is the


of the multi-process model.

nginx uses IO multiplexing mechanism at the underlying layer, which is essentially Synchronize non-blocking, not really AIO, in the UNIX IO model, so in fact, for user mode, it is actually Synchronize

.

some materials (such as "detailed explanation of nginx High performance Server") say that nginx uses multi-process + asynchronous non-blocking
for "non-blocking", it should mean that when using IO multiplexing, socket is generally set to non-blocking
as for "asynchronous" it should be asynchronous in the sense of programming model (essentially Synchronize)

Menu