我有一个PHP CURL请求到一个HTTPS站点,它接受一个JSON和请求并返回一个JSON响应。通常不会超过1秒钟。但是,我已经看到CURL响应时间是可变的。有时需要4秒才能回复,有时需要1.2秒。为什么会这样?我如何才能更快速地处理整个请求?变量CURL响应时间
以下是卷曲的响应时间在3个不同时间相同的请求..
Array
(
[url] => https://xx.xx.xxx.xx/site/y
[content_type] => application/json
[http_code] => 200
[header_size] => 198
[request_size] => 358
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 4.213941
[namelookup_time] => 2.1E-5
[connect_time] => 0.015284
[pretransfer_time] => 0.722955
[size_upload] => 222
[size_download] => 553
[speed_download] => 131
[speed_upload] => 52
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 4.015112
[redirect_time] => 0
)
Array
(
[url] => https://xx.xx.xxx.xx/site/y
[content_type] => application/json
[http_code] => 200
[header_size] => 198
[request_size] => 358
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 1.27581
[namelookup_time] => 8.3E-5
[connect_time] => 0.016223
[pretransfer_time] => 0.104996
[size_upload] => 222
[size_download] => 553
[speed_download] => 433
[speed_upload] => 174
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 1.273922
[redirect_time] => 0
)
Array
(
[url] => https://xx.xx.xxx.xx/site/y
[content_type] => application/json
[http_code] => 200
[header_size] => 198
[request_size] => 358
[filetime] => -1
[ssl_verify_result] => 20
[redirect_count] => 0
[total_time] => 1.294147
[namelookup_time] => 7.0E-5
[connect_time] => 0.025723
[pretransfer_time] => 0.123456
[size_upload] => 222
[size_download] => 553
[speed_download] => 427
[speed_upload] => 171
[download_content_length] => 0
[upload_content_length] => 0
[starttransfer_time] => 1.292577
[redirect_time] => 0
)
这不取决于网站的速度有多快,与卷曲无关吗? – 2010-01-21 18:06:33
这确实是一个问题,让你要求更快的网站回应,而不是更快的回应。 – 2010-01-21 18:08:20
您是否尝试过使用浏览器访问“https:// xx.xx.xxx.xx/site/y'并查看需要多长时间?另外,响应数据变化很大吗?如果没有,缓存可能是一个选项。 – 2010-01-21 18:15:38