The completion process of an HTTP transaction: (Web server side)
1. Establishing a TCP connection
2, accept the request (the Linux kernel accepts the request from the network card, after verifying the port number and hostname, sent to the corresponding web process)
3. Processing requests (Web service process)
4. Get the resource (the Web process reads the data from the hard disk into the memory space of the Linux kernel through the kernel, and then copied to the memory space of the web process)
5. Build response (Web software build response message)
6. Echo Response (message + Resource)
7. Record Log
When the user requests a Web page content, its data needs to enter from the network card, after TCP unpacking, found to be sent to listen to the 80 port of the web process, and then give it.
Multi-process:
The memory address space for each process is independent so that the amount of I/O is larger when copying data from the kernel space
Due to the process switch, need to keep the process of the site, and then switch back to the scene when you need to reply.
So you can't start too many processes
Multithreading:
The thread shares the resources of the memory address space of the process, so the I/O volume is smaller.
If the corresponding worker process crashes, all the threads under it will crash.
Nginx's working mode is to have a master master process, and n worker worker threads.
The master master process replicates only the read configuration, builds on demand, and recycles worker worker threads. The worker thread is only responsible for responding to user requests.
When Nginx upgrades only need to replace binary execution files, when a new connection comes in, the new worker thread will be used. The old connection still uses the old worker thread until it is disconnected until it is reclaimed.
This article is from the "Boys Kicked" blog, please be sure to keep this source http://rainbow168.blog.51cto.com/1060170/1551233
The completion process of an HTTP transaction: (Web server side)