views:

948

answers:

2

I'm running XAMPP 1.7.1 on Windows 7 Ultimate. Everything (Apache & MySQL) is working fine except for speed.

When I open http://localhost/, I must wait probably 1-3 seconds for view a webpage. In my opinion, it should be at most some hundreds miliseconds.

Basic facts:

  • while waiting to load a localhost webpage, status bar says "Waiting for localhost..."
  • CPU is still idle (no increased activity while loading)
  • on localhost is no demanding PHP scripts, problems are when there is simple phpinfo() even if there is long heavy scripts.
  • disabling MySQL server don't affect speed
  • my PC: AMD Turion 64 X2; 1,6 GHz dual-core, 2 GB RAM, 100 GB HDD

I've made a little simple benchmark PHP script to test HDD/CSS speeds:

<?php

function getmicrotime() { 
    list($usec, $sec) = explode(" ", microtime());
    return ((float)$usec + (float)$sec);
}

function testReadWrite() {
 $timeStart = getmicrotime();
 $filename = "test.txt";

 file_put_contents( $filename, '' ); // prepare empty file

 for ( $i = 0; $i < 1000; $i++ ) {
  $a = file_get_contents( $filename );
  file_put_contents( $filename, $a . '.' );
 }

 return round( getmicrotime() - $timeStart, 3 );
} 


function testCpuSpeed() {
 $timeStart = getmicrotime();

 $var = '';
 for ( $i = 0; $i < 100000; $i++ ) {
  $var = sha1( md5( $i * $i * $i * $i * $i * $i * $i * $i * $i * $i ) );
 }

 return round( getmicrotime() - $timeStart, 3 );
}

echo "Read/write #1: " . testReadWrite() . "<BR>";
echo "Read/write #2: " . testReadWrite() . "<BR>";
echo "Read/write #3: " . testReadWrite() . "<BR>";
echo "CPU speed #1: " . testCpuSpeed() . "<BR>";
echo "CPU speed #2: " . testCpuSpeed() . "<BR>";
echo "CPU speed #3: " . testCpuSpeed() . "<BR>";

?>

My PC results:

  • Read/write: 5.134 / 3.431 / 3.494
  • CPU speed: 0.816 / 0.767 / 0.795

A webhosting results:

  • Read/write: 7.768 / 7.69 / 7.371
  • CPU speed: 0.232 / 0.234 / 0.234

One of my server's results (as idle computer nearly as my PC, but a little bit faster):

  • Read/write: 0.088 / 0.168 / 0.185
  • CPU speed: 0.191 / 0.189 / 0.189

So I don't think that it is because of my PC speed, but I'm sure that there's some another problem. Do you have some experience with XAMPP speed on Windows 7 (or Vista) ?

Thanks.

+2  A: 

How about giving Wamp Server a try?

The installation file is a lot smaller (16mb) compare to XAMPP (44mb).

http://wampserver.com/

Yada
I just installing it, thanks. I will know here, if it helps.
Martin
Thanks! I don't know why, but it helps and resolved my problem :) Now I'm going to move all the vhosts from XAMPP to WAMP.
Martin
Glad it worked. WampServer definitely has a smaller footprint.
Yada
+1  A: 

Not sure this might be the cause of your problems, but this might be an idea : do you have a line that looks like this :

::1 localhost

in your hosts (it should be somewhere like C:\WINDOWS\system32\drivers\etc\hosts, if I remember correctly) file ?

If yes, comment that line by adding a # at the beginning.


This way, the only line that's about localhost should be

127.0.0.1    localhost

which is an IPv4 address ; and the one you commented being an IPv6 -- which is quite not useful for what you are trying to do.


As I said, not sure your problem is related to this, but I've seen this sugestion help a couple of times for problems quite similar to your (i.e. waiting a long time before doing anything on the server).

Pascal MARTIN
Yes, I have uncommented that line. Unfortunately, it didn't help.
Martin
Oh, too bad :-( (I suppose you meant "commented", and not "uncommented)
Pascal MARTIN
Did you do a reboot, too?
Franz