-3

My php on linux server is too slow, but faster on my 127.0.0.1 (windows local host). any ideas to improve speed on linux server? I'm doing file reading, file writing processes in my php code.

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
sri
  • 111
  • 3
  • 9
  • 3
    The linux machine is remote? Define "Slow". Keep in mind that if you have a remote machine, the php processing time isn't the same as the time you need to see the results. For example a php script can take 0.005 seconds to perform an action, and due to your internet connection speed and other factors, see the result like at 1 second. Try using microtime() and loop a function for 1000 times to test the real php processing speed on both servers – aleation Apr 11 '13 at 07:56
  • 1
    possible duplicate of [PHP to EasyPHP MySQL server 1 second connection delay](http://stackoverflow.com/questions/11310564/php-to-easyphp-mysql-server-1-second-connection-delay) – uınbɐɥs Apr 11 '13 at 08:03
  • you mean your online (hosting) linux server is slow ? – NullPoiиteя Apr 11 '13 at 08:09
  • Please provide more information. What parts of it is slow? What code are you using? Is it just your network connection accessing the server or is it the actual server processing? Is it shared hosting ? Is it a dedicated server? what is the spec of the hosting. We need much more information to provide answers. – Dave Apr 11 '13 at 08:12
  • @aleation,@NullPonyPointer : yes, it's damn slow, it's online (hosting) linux server. – sri Apr 11 '13 at 08:12
  • @sri than talk to hosting providers about it ans make sure you are not running query in loop – NullPoiиteя Apr 11 '13 at 08:14
  • Try running something like this and tell us the echo on both of your servers... `$start = microtime(true); $counter = 0; for($i = 0; $i < 10000000; $i++){ $counter += $i; } echo microtime(true) - $start;` – aleation Apr 11 '13 at 08:18
  • localhost tends to be faster then remote, that's the nature of the internet. You really have to define slow, "damn slow" isn't good enough, it's not measurable. Like others have suggested time how long your PHP takes to execute in both environments so you can narrow it down. – Drew Khoury Apr 11 '13 at 08:25
  • @aleation 0.91329503059387 On windows, 0.903809070587 on linux hosting server. – sri Apr 11 '13 at 08:32
  • then php is not slower on linux hosting, they are the same, 0.01 difference is nothing. It´s the network/connection speed. try to ping your server and see the delay in ms you have. Also go to any speed test site to see your normal ping, this way you can determine if it´s your connection speed fault or it´s the server´s – aleation Apr 11 '13 at 08:38
  • ok friends, thanks for all ur valuable answers and quick responses. – sri Apr 11 '13 at 08:43

1 Answers1

3

it isn't too slow use 127.0.0.1 instead Localhost

its because when we use hostname (like localhost ) the mysql client first tries this with ipv6 host name and if it failed than it fallback with ipv4

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
  • i'm using 127.0.0.1 only as "define("DBHOST","127.0.0.1");" . is it ok ? or i need to change? – sri Apr 16 '13 at 05:43