All,
I have a PHP CURL request to an HTTPS site which takes a JSON and request and returns a JSON response. Usually it should not take more than 1 second. But, I have seen that the CURL response time is variable. Sometimes, it takes 4 seconds to respond and sometimes 1.2 seconds. Why is this so and How can I make it faster and process the whole request in less than a second?
Following is the curl response times for the same request in 3 different times..
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
)