A GraphQL API, which takes up to 7 seconds to investigate and analyze (Can Windows php-fpm handle multiple requests at the same time?)
1. A GraphQL API, which takes up to 7 seconds. as shown in Figure 1
2. The time to query this request in Laravel Telescope, 1345 ms. as shown in Figure 2
3. Instead of requesting the GraphQL API on the page, it takes 1.87 seconds to request a separate request using the Altair GraphQL Client. Approximately the time in Laravel TeleScope. as shown in Figure 3
4. The current operating environment: Windows 10, Nginx and PHP FastCGI. This environment is limited, that is, only one HTTP request can be served at a time. This leads to the waiting time of the GraphQL API for up to 7 seconds.
5. The current Nginx configuration is as follows
http {
## PHP-FPM Servers ##
upstream php-fpm {
server 127.0.0.1:9000;
}
server {
location ~ \.php$ {
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
6. Reference:https://stackoverflow.com/questions/15819351/can-windows-php-fpm-serve-multiple-simultaneous-requests.
7. Adjust the Nginx configuration as follows
http {
## PHP-FPM Servers ##
upstream php-fpm {
server 127.0.0.1:9000;
}
upstream php_farm {
server 127.0.0.1:9003 weight=1;
server 127.0.0.1:9004 weight=1;
server 127.0.0.1:9005 weight=1;
server 127.0.0.1:9006 weight=1;
}
server {
location ~ \.php$ {
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_pass php_farm;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
8. Start several php-cgi processes and bind them to different ports: 9003, 9004, 9005, 9006. as shown in Figure 4
9. After restarting Nginx. as shown in Figure 5
10. Refresh the page in the browser again to check the GraphQL API request time. It has been shortened to about 2 seconds. in line with expectations. as shown in Figure 6





