Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAMPP on Win7 too slow

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.

like image 456
Martin Ille Avatar asked Dec 11 '09 21:12

Martin Ille


People also ask

Why does localhost take so long to respond?

The 'taking too long to respond' error indicates that there is a communication problem between the target server and the client (your web browser). It means that the targeted server is taking a long time to send a response to the client. The error is usually sent if the client cannot get a response within 30 seconds.

Does XAMPP slow your computer?

Doing a development on windows using XAMPP with default install on windows can give you a nightmares due to its dead slow speed of processing. I too had same issue of slow processing speed on XAMPP. XAMPP loads a lot of stuff you often don't need. I personally use docker virtualized webservers or run it in a linux vm.


2 Answers

If XAMP is slow under windows 7, the firewall settings make no difference.
The Security Essentials anti-virus makes no difference.

To solve this problem, the two things that make a big difference are:

1) in windows\system32\drivers\etc\hosts add the following lines:

127.0.0.1 127.0.0.1

127.0.0.1 localhost

2) If you're using PHP, in the XAMP php.ini file uncomment the eaccelerator line:

zend_extension = "C:\xampp\php\ext\php_eaccelerator_ts.dll"

After these two changes, restart Apache and it will be way faster.

like image 111
JoeV Avatar answered Oct 06 '22 01:10

JoeV


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).

like image 23
Pascal MARTIN Avatar answered Oct 06 '22 01:10

Pascal MARTIN