开发者

PHP Memory spikes on Production server

开发者 https://www.devze.com 2023-04-10 07:49 出处:网络
I\'ve got 2 servers: my local server and remote production server. They\'ve got basically the same config: Ubuntu 10.10, Apache 2, PHP 5.3, PHP-APC, MYsql etc开发者_开发百科. I also have copies of a w

I've got 2 servers: my local server and remote production server. They've got basically the same config: Ubuntu 10.10, Apache 2, PHP 5.3, PHP-APC, MYsql etc开发者_开发百科. I also have copies of a webapp on both servers and here's the problem with PHP:

On my local server webapp uses only ~4 MB of memory, but on my production server memory usage spikes up to 50 MB of memory for no good reason. I tried to run memory_get_peak_usage() function to get memory usage at different stages of webapp execution and i've found that on production server memory spikes from 0.7 up to 49 MB on such function calls as class_exists().

What could be the problem?

Tanks.


Hate to sound a bore, but have you verified that they have exactly the same Apache/PHP config as they can easily become the source of these sort of differences.. Also are they experiencing the same sort of load, as code running on a server under load can behave very differently to code running with ample uncontested resources.

Are there any other differences in terms of other running applications that could be affecting stuff?

It maybe worth profiling the code on both the servers to see if there are any per-request differences, XHprof[1] is a great tool for this and it can safely be run in production (as long as you read the instructions)

[1] http://phpadvent.org/2010/profiling-with-xhgui-by-paul-reinheimer


Ok, i've found where was a problem. There is a class that was creating cache file containing information on user's browser (in order to recognize them later). Apparently there was a problem with that file and/or parser so it was using too much memory. Since then i've cleared cache files and if situation will repeat, i'll ditch that class altogether.

Thanks to all who answered/commented on problem.

0

精彩评论

暂无评论...
验证码 换一张
取 消