0

I have a project that needs to fetch data from an XML API, I'm using php's cUrl to get the data from the API. Now the data download is as follows

  • 1 request to fetch data, 123kb file
  • 1 request to get data specific info 600 bytes file
  • 1..10 request to get images (max 170kb files)

In that order and nested from bottom to top, the data obtained is a school, an activity calendar and an image gallery

So you see, there are 12 curl request top

I have debugged my application logic, and the delay once the data is on memory to perform the operations is 3 secs.

The timing obtained by curl_getinfo is as follows

{  
   "url":"the url",
   "content_type":"text\/xml; charset=iso-8859-1",
   "http_code":200,
   "header_size":222,
   "request_size":600,
   "filetime":-1,
   "ssl_verify_result":0,
   "redirect_count":0,
   "total_time":0.942642,
   "namelookup_time":8.4e-5,
   "connect_time":0.179581,
   "pretransfer_time":0.17966,
   "size_upload":326,
   "size_download":12720,
   "speed_download":13493,
   "speed_upload":345,
   "download_content_length":-1,
   "upload_content_length":326,
   "starttransfer_time":0.576183,
   "redirect_time":0,
   "redirect_url":"",
   "primary_ip":"81.93.213.42",
   "certinfo":[  

   ],
   "primary_port":80,
   "local_ip":"192.169.233.75",
   "local_port":43479
}

This data is encoded as json, because it will be putted on a log server.

So my question is why if curl takes 1s to get the response from the API and my logic is executed between 2 and 3 seconds the response has a time of 1 min, where are the next 50s???

One thing to notice is that my website runs on godaddy, a VPS under https and the api runs on HTTP, does this has anything to do?

Thanks in advance

asolenzal
  • 500
  • 7
  • 23
  • Thanks Brad, nice edit – asolenzal Jul 10 '15 at 17:00
  • 1
    I must ask the obvious: are you using curl_multi_* ? – spenibus Jul 10 '15 at 17:18
  • did you say 12 seperate requests? The total time returned by getinfo relates to the last request . So 12 * requests = XXX. Cache the data somewhere. – David Jul 10 '15 at 17:21
  • I can not cache the requests, the stuff is that a request demands 1 sec aprox. so it will be 12 requests * 1s, 12 secs, where are the other that lasts for a minute. – asolenzal Jul 10 '15 at 17:23
  • I use curl_multi for the image gallery download process. Thanks – asolenzal Jul 10 '15 at 17:24
  • Is the question still relevant ? Because if curl_multi_* is the answer, it's basically a dupe of http://stackoverflow.com/questions/3900153/php-multiple-curl-requests – spenibus Jul 10 '15 at 17:58
  • No I guess is not a dupe, because I'm in fact using curl_multi* to handle multiple curl requests. Check the full question and you can see that is not a dupe. – asolenzal Jul 10 '15 at 18:29
  • Then you might have to show us your php code. Does setting __CURLOPT_TIMEOUT__ to a low value (like 10) cut the delay ? – spenibus Jul 10 '15 at 18:53

1 Answers1

0

Resolved, the server was delaying the download of the data for the curl requests, so I spoke to the hosting provider and removed the delay for downloads. So the curl requests were delayed by the server, not the code or the curl handle itself. Thanks to all comments.

asolenzal
  • 500
  • 7
  • 23