HTTP

Easy to understand: That’s when a browser on some computer sends a predefined HTTP Request to my computer, and I process it (usually a file with an.html extension from my hard drive) and send it back as a text Response, It’s as simple as that.

The HTTP 1.0

  • Simple to understand: transmission of HTTP data needs to be communicated, and communication needs to be connected to the network, which involves TCP connection, connection using Socket communication, the client needs to involve a Socket communication program to monitor the port and receive data/send data

  • Disadvantages: Receiving data is blocked if the response is slow, and new connection requests cannot be processed

HTTP 2.0 multi-process

  • When a connection is received, the new socket is not processed in the main process. Instead, a new child process is created to take over the socket

  • Disadvantages: If the number of connection requests per second increases, it will create a large number of processes to deal with it, which is exactly the case, the system resources are a lot of waste, see here, most people will think of using threads to deal with, but threads also need a lot of switching

HTTP 3.0 SELECT model

  • Socket connection is simply a File Descriptor (File Descriptor is an integer) that can send up to 1024 Socket FDS at a time

  • Select model: the Socket sent when a client requests a connection. The fd_set data structure, which is an array of type long, is sent to the operating system kernel, and blocks, waiting for the operating system to tell it that the operating system will mark the socket number, that is, the marked socket can be processed, and then wake up the Http Server to process the marked socket

  • Disadvantages: All socket data needs to be traversed each time, and operation on unmarked sockets is inefficient

HTTP 4.0 epoll model

  • For the SELECT model, this model is in the operating system for the corresponding processing, sent valid socket data, no HTTP Server to process unmarked data

conclusion

Simple surface level of understanding, no details involved, you consider the view, in addition to this for the “code farmers turn over” this book combined with understanding output, if there are mistakes please put forward, I will be modified