I have 2 servesr both on a LAMP stack. Two servers running almost the same PHP code. And on the second server i have troubles with loading time, where ttfb is too high, sometimes it is up to 17 sec. The second one has more recent version of PHP, MySql and Apache also it has 3 times better specs, the database is 17 times smaller.
However it works much slover than first one ttfb 0.5 vs 17 sec. I'm 100% sure I'm the only visitor on the site. I've tried to track php exeecution time and it's on avarage 5 sec
<?php $GLOBALS["start"]= microtime(true); //mycode $GLOBALS["end"]= microtime(true); $execution_time = ($GLOBALS["end"] - $GLOBALS["start"]); echo '<b>Total Execution Time:</b> '.$execution_time.' sec';
When i track CPU usage it always show that mysql process uses the most resources.htop screenshot
I've tried to repair and optimize my db but no improvements. Slow query log doesn't show me queries that current script executes. How can i fix this?