Okay I have some problems.

I am a fairly new developer at drupal and I am writing my own custom module. It is all going pretty well but right now I am making some ajax calls for auto completion (using jquery).

Maybe later I will convert my items into nodes and use some ready auto completion but for now during testing thats not interesting...

what is interesting is that my queries takes almost always around 4.2 seconds from I send them (checking trough firebug).
I thought the database lookup was the culprit so I made it benchmark and the times came out to like 0.2ms for my query (not including other stuff being run by drupal). In fact all my own code for that ajax call takes less then 0.4ms or 0.0004seconds.
The drupal is run on an apache (win) with mysql run on the same machine I am calling from and it's a pretty beefy machine.

My drupal installation is pretty new and I haven't installed that many components or anything. So what on earth can make it take 4 seconds?

where can I start digging??

Comments

jmmec’s picture

I am also developing a custom module using AJAX: I'm running an Apache2 server on an old 486 with 512MB RAM with Drupal 5.6 and firebug is reporting 800ms to 1sec response times. So I'm getting much better than 4sec response time that you see.

I haven't started to investigate this, but my guess is that (in my case) the time is taken up by the Drupal startup (MENU_CALLBACK bootstrapping MySql?) when the requests comes in from the AJAX client:

$items[] = array('path' => 'roster/mco/processClient',
'title' => t('Roster MCO Client'),
'callback' => 'roster_mco_processClient',
'access' => user_access('access roster'),
'type' => MENU_CALLBACK);

When I process the client AJAX message, I do some quick database lookups and respond to the client. Nothing that should take very long at all to complete.

But, maybe I'm wrong and it isn't the Drupal bootstrap taking up all the time.... :)

BTW, you probably aren't doing this, but if you pop up an 'alert' box when processing the response at the client, then Firebug will continue to count-up and increase the processing time until you press "OK".

nevets’s picture

If it was bootstrap causing the time delay all page loads would take 4 seconds or more.

jmmec’s picture

Hmm.... interesting.

Out of curiosity, I used the 'profile' tool in firebug and it doesn't show anything taking much time at all on the client browser. So something at the server is taking the 800ms to 1sec to process and respond to the query.

I haven't investigated much, and right now the response time isn't much of an issue for me. Thankfully I'm not looking at 4sec response times, tho...

lyrd’s picture

this is a bit embarrassing but I found my problem.

After making apache report request times and seeing it report 0.2 seconds when my browser got 4.2 seconds... it hit me.

I accessed the page using http://machineName/path when i changed it to http://127.0.0.1/path all of a sudden firebug showed the same response times as apache.

0.2 seconds does scare me a bit tho, quite a lot considering this is an ajax call only and I have barely started development so it's still tiny. But then again I haven't installed APC or done optimizations yet either.
If I can get it to render complete pages in 0.2s when everything is done then I'm happy.