I am performing POST request to local api web service (via LAN) with dummy method, that works very fast itself (less then a second).
Problem is that if i use php5-fpm it
I just track down a similar issue of my own. I think it might be the same reason. I encounter the similar issue like avasin. I found that php-fpm curl to localhost is slow, but php-cli curl to localhost is extremely fast. Plus, debugging curl timing shows high starttransfer_time
in php-fpm but rather low in php process.
I found the root cause yesterday, the issue is the php-fpm www.conf config. Becuase php-fpm has low start_server
, php-fpm actually has to process curl with limited number of php-fpm processes. The solution is to increase the number of start_server
, this will affect the number of concurrency which your php-fpm could handle. The performance will decrease drastically when the concurrency exceeds the number of current php-fpm processes. Hence, making everything feels slow. The php-cli does not have the same issue since it could launch many php processes as long as you have enough memory, so it is always fast. I did a lot of experiments here php curl localhost is slow when making concurrent requests. Take a look if you're interested.
One thing I've noticed on my own instance of FPM (using Nginx) is that I will not get interim output. I've never bothered to investigate this as it has never mattered for my own usage needs (small units of work with little output).
In your case, perhaps the response is being sent quickly but the connection is kept alive -- causing the recipient to wait around for more data that never arrives. You may be able to check on this by investigating server side logging to check response times from the server's point of view.