1

I have Apache2 Web server and tiny PHP script

<?php
echo '1'

When refreshing page the waiting time value in Google Developers Tools can vary from 24-26 ms to 300-350 or somtimes it is even more than 1 second?

Of what does it depend on? How to control this value in a desired range or to minimize it?

4 Answers 4

1

Is the delay due to initial/pre-first index file load? If so, this could be due to DNS resolution.

You can take out this factor in the following tests:

  1. Add the IP of the server to your client's /etc/hosts so that no DNS queries are involved. Run the test again and see if you have more consistent results. If the results are consistent, then the variability is due to DNS resolution.

  2. If switching to static IP doesn't help, try referencing the host via IP address in the addressbar when you test the page with your web browser. On the off chance the /etc/host change didn't take.

  3. If using fixed IP doesn't clear the variability, then try a local test from the server itself, to rule out network variability. If you still see the issue from a localhost test, then the issue is with your app stack on the server. :(

Note:

Running a similar index.php test against one of my servers(VPS hosted), I see the following:

index.php load about 25-35ms consistently. There are some icons that attempt to load, which drives up the total page load time to around 200-300ms.

Screen Capture of index.php load time

2
  • 1
    Thank you very much for your answer. Really I have added IP-domain pair to the hosts file on my Windows client machine, and the response time is mostly often 26-30 ms, and sometimes up to 130 ms. So if the variablity is because of DNS resolution, how to deal with it?
    – zavg
    Apr 21, 2013 at 11:43
  • One manner of dealing with it is to set the DNS entries with a longer TTL, so that the information is cached for a longer period of time, reducing the number of queries that a browser feels the need to execute. It's worthwhile to also test from multiple locations, to ensure that the time delay issues aren't specific to any one particular network region. Apr 22, 2013 at 17:20
0

Is this a dedicated apache server for your web site only? If you have a web site on a commercial hosting service, then you are probably seeing network latency issues.

Also are you using a database backend like mysql?

It is hard to isolate response time issues without analysing the entire environment.

4
  • I have this issue on 2 different servers: on the dedicated server in datacenter for my application only, and on the Amazon EC2 instance.
    – zavg
    Apr 17, 2013 at 18:41
  • I am using MySQL, but for the test purposes I run just <?php echo "1"; script to test latency.
    – zavg
    Apr 17, 2013 at 18:42
  • are you running this test from the same server your website with mysql is running? Could it be that apache is busy serving other requests at the same time you are testing?
    – Renan
    Apr 17, 2013 at 20:09
  • @Renan No I run it on separate environment, and the right idea is published in Wing Tang Wong post - it is because of DNS resolution.
    – zavg
    Apr 21, 2013 at 11:48
0

If you're using Chrome, fire up the developer tools, click on the "Network" tab, and then hit refresh. Then mouse over the request until you see something like this:

connection

That will tell you where the hold up is. In your PHP script you can also add this to see how long the script takes to process:

<?php
$start = microtime(true);
echo '1';
echo 'took '. microtime(true) - $start .' seconds to complete';
?>

That should rule out PHP as the culprit.

0

I suggest you run a short series of test and plot them in a spreadsheet. The first one or two should be slower, as it has to get into the caches, but the rest should cluster around an average. Eyes and a scatter-graph are good tools for verifying this.

If the results don't cluster, you need to investigate as the other commentators suggested: what else is happening on the machine that runs the service, the network and the machine you run the test from?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .