php卷曲-缓慢上传限制-如何优化?

php卷曲-缓慢上传限制-如何优化?,php,curl,Php,Curl,我正在使用cURL在我的网站和合作伙伴的网站之间传输数据 请求非常长(约18秒),但信息量非常小(约207字节) 以下是生成请求的代码: // Send the subscription $resource = curl_init($url); curl_setopt($resource, CURLOPT_RETURNTRANSFER, true); curl_setopt($resource, CURLOPT_POST, count($postFields)); curl

我正在使用cURL在我的网站和合作伙伴的网站之间传输数据

请求非常长(约18秒),但信息量非常小(约207字节)

以下是生成请求的代码:

// Send the subscription           
$resource = curl_init($url);
curl_setopt($resource, CURLOPT_RETURNTRANSFER, true);
curl_setopt($resource, CURLOPT_POST, count($postFields));
curl_setopt($resource, CURLOPT_POSTFIELDS, $postString);
$result = curl_exec($resource);
以下是curlinfo调试的结果:

17.418212 total_time : Total transaction time in seconds for last transfer
0.064612 namelookup_time : Time in seconds until name resolving was complete
0.437222 connect_time : Time in seconds it took to establish the connection
0.946509 pretransfer_time : Time in seconds from start until just before file transfer begins
17.418172 starttransfer_time : Time in seconds until the first byte is about to be transferred
0 redirect_count : Number of redirects
0 redirect_time : Time in seconds of all redirection steps before final transaction was started
207 size_upload : Total number of bytes uploaded
11 speed_upload : Average upload speed
130 size_download : Total number of bytes downloaded
7 speed_download : Average download speed 
在curlinfo文档:,据说上传大小和上传速度分别以字节和字节/秒为单位

10字节/秒不是很快,是吗? 在哪里可以找到其他调试信息,我可以做些什么来提高速度?

其他信息: 发送和接收数据的服务器都具有良好的带宽
而且两者都在同一个城市

看起来服务器端出现了性能问题

curl_getinfo()报告的速度计算如下:

bytesPerSecond = totalBytesReceived/totalTime
其中totalTime是curl_exec执行时间


如果服务器响应延迟(服务器忙等),您可以等待1分钟,以便在最后一毫秒内获得60个字节,并且报告的速度将为每秒1个字节,这与服务器之间的网络连接速度无关。

+1感谢您调试了一个curl调用。这里有curl问题的大多数用户甚至不知道
curl\u error()
。欢迎使用堆栈溢出!:)在浏览器中发出请求的速度有多快?是否远程脚本需要17秒才能生成数据?服务器端似乎存在性能问题。我现在正在浏览器中测试请求,这不是一个简单的url,所以让我计算所有这些:)@Pekka웃 实际上,通过浏览器的请求也很长。我仍然要从合作伙伴的角度来验证这一点,但似乎远程脚本正在减慢我们的速度。我仍然需要对此进行优化,但现在我知道cURL不是原因。啊,是的,很明显,使用字节/秒计数方法,我直观地将这种上传速度视为网络连接,但这样做很有意义。您的回答+Pekka的洞察力让我走上了正确的道路。@np1987所以您应该设法优化服务器端的代码。祝你好运