For the same interface, the client sends two AJAX requests in a short time. When the first request has not been returned, how does the PHP server handle the second request? For the same interface, the client sends two AJAX requests in a short time.
When the first request has not been returned, how does the PHP server handle the second request?
Reply content:
For the same interface, the client sends two AJAX requests in a short time.
When the first request has not been returned, how does the PHP server handle the second request?
Currently, server programs that support PHP on the market generally run in multi-process mode, that is, there will be multiple PHP processes to process requests at the same time. When a request is still being processed and another request arrives, the request is sent to other processes for processing. Wait in queue until the number of concurrent processes exceeds the configured number of concurrent requests.
Taking PHP-FPM as an example, it is a multi-process FastCGI service embedded with PHP interpreter implemented by C. A worker process can only process one request at a time. Other requests enter the listen. the queue is waiting for processing in the backlog (511 by default) queue. i/O intensive operations with Nginx can be separated to the PHP-FPM specific process pool for operations, computation intensive operation FPM process number can be set to 2 times the number of CPU cores, i/O-intensive resources can be multiple points. therefore, only a small amount of PHP code can achieve high performance. Obviously, many PHP frameworks are contrary to this. This is why the father of PHP does not like the framework, because his original intention of developing PHP is to encapsulate a set of C APIs for convenient Web development, it can be considered that PHP is the Web framework implemented by C.