Maybe its only me, but I think a typical response of 3.5 sec for a
query with
10 items returned, or 9 to 15 sec for 30 items returned (remember this
is only
server to server!), seems to be a bit long. So, has anyone experienced
this api with shorter response times, or even worse? Or is Google well
aware of those timings and does consider this (beta) service working as
intended?
To begin with, first question is of course, how can I improve my code
to
boost performance?
Here are the timings (in sec) for 33 successful requests to the api,
each
one returned 10 items (first line, label "request"). So, no retry or
"502"
response go into this. Each request is composed of 3 consecutive
sections of code (labeled here "fsockopen", "firstfgets", and
"otherfgets"),
plus some php code, which contributes to the timings below the msec
only.
min median max %
33 1.986 3.433 9.851 100 request
33 0.113 0.114 0.154 3 fsockopen
33 1.754 3.044 9.62 90 firstfgets
33 0.112 0.115 1.03 7 otherfgets
The main point here: a single instruction, typically taking 3 sec to
complete,
is responsible for 90% of the transaction time!
Code actually used, complete with measurement points:
$etime[] = microtime(); $descr[] = 'request';
$fp = fsockopen('api.google.com', 80, $errno, $errstr, 10);
if (!$fp) {
echo '<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">',
'<pre>', $errstr ($errno), '</pre></Envelope>';
return true;}
fwrite($fp, $headers);
fwrite($fp, $soap_env);
stream_set_timeout($fp, 20);
$i = 1;
$etime[] = microtime(); $descr[] = 'fsockopen';
$response = fgets($fp);
$etime[] = microtime(); $descr[] = 'firstfgets';
$status = stream_get_meta_data($fp);
while(!feof($fp) && !$status['timed_out']) {
$response .= fgets($fp);
$status = stream_get_meta_data($fp);
$i = $i + 1;}
$etime[] = microtime(); $descr[] = 'otherfgets';
Regards, Manfred
Regards,
Frank
Regards, Manfred
A big Thanks goes to the API folks, for improving the service
dramatically, so both together brought my response time well
_below_ 1 sec.
Regards, Manfred
I use NuSOAP in PHP, and last year and earlier, spelling suggestion
requests from the API server would take an average of 0.25 seconds.
Nowadays, I consider myself lucky if I get a response in under 3
seconds.
> Did you work with the API team to get this working?
No, they did their work independently, and it looks good so far!
Let us know, whether your response times have changed now.
Also, did your measurements include retries from 502?
Regards, Manfred
I put together a little test script to gage the speed of the API
service to help me in making changes to the NuSOAP library, and
suddenly the API service is running MUCH faster today!
Have you noticed any change? I'm not getting errors, response times
are generally under 0.2 seconds... it's just like the old days again!
Maybe I'm just getting lucky with my tests...
Regards, Manfred