We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Extremely slow page load randomly


I'm current working on a REST interface for an app, and sometimes I run into page loads which take exactly ten seconds longer than usual, mostly after the server has been inactive for a while. It can't be a programmatical issue, because after the first load, the load time is around 22ms. Then I leave it for a while and reload, and the response time is instead 10022 ms. It's quite consistent, always adding ten seconds to the standard response time.

There's nothing in the Apache logs or anything. I have no idea where to start troubleshooting this. Any help?

My local dev setup is Mac OSX (10.8.5) and Zend Server (I need it becaue we use Zend Framework at work...) MAMP stack.


Best regards, dimholt

EDIT: The answer here marked as correct explains why this happens randomly, but it also happened on every request when my laptop was not plugged in. I learned from my sysadmin that since the traffic is always routed through the (W)LAN-card anyway, when the computer is in power save mode, the card will try to always fill the buffer or wait for timeout before returning the response, thus adding ten seconds to my small REST requests.

Exactly and consistently 10 seconds is really fishy. My immediate guess is there is some process that is halting/sleeping for 10 seconds.

I'd debug this by putting a call to

echo microtime(TRUE);

at the beginning and end of your action (calling exit() at the very end to ensure you see the output). If nothing's weird there - move the starting call earlier in the application - until you see something. If you don't find anything... then I'm not sure. Do you have Memcached or APC active?

edited Apr '14

I would reccomend using something like webgrid/kcachegrind/qcachegrind instead of manually inserting microtime statements everywhere.

You can get a complete dump of all the recursive function calls and the time spent in each function. The phalcon docs show a few of the different utilities and it is easy to setup on mamp/xampp. http://docs.phalcon.io/en/latest/reference/whats-next.html

Also - running from a vagrant box might help you deduce whether its an os level problem or a hardware issue.


Hi dimholt!

This is a sort of normal behaviour of apache / IIS / probably others. When vhost is not used for a while, OS or server pauses or moves it all to swap to make space for active tasks. Not much to worry about i think.


Hello people, and thank you for you replies and your time. It would appear that nazwas anwer the case, judging from the behavior of the server. I am intrigued by the cache grind software as well, and will look into them to further improve my code. Thank you again!