We have an old facebook app, running smoothly written in native php.
This month we decided to rewrite it in zend-framework 2. Yesterday, after switching to new app it crashed our server with lots of out of memory errors. So we turned back to old app.
I installed xdebug to profile the app. Using memory_get_peak_usage() function i noticed high memory usage.
In the old app, a static page uses only 1 mb memory. But the new one using 7-8 mb approximately on the same page.
Here’s the top two rows from webgrind:
Function Invocation Count Total Self Cost Total Inclusive Cost
Composer\Autoload\ClassLoader->loadClass 224 23.31 47.20
Composer\Autoload\ClassLoader->findFile 224 9.57 10.23
Also tried tha apache’s ab tool
ab -n 50 -c 5 -C PHPSESSID=SESSIONID http://myhost.com
Result is:
Percentage of the requests served within a certain time (ms)
50% 368
66% 506
75% 601
80% 666
90% 1073
95% 1812
98% 2278
99% 2278
100% 2278 (longest request)
All these results from the production server not localhost.
Is 7-8 mb for a single page normal? If not, how can i reduce it? Should i look for it in zf2 or composer?
I can give code samples if you need. Thank you.
I spent a day to figure out problem. Tried xdebug, xhprof. There was no problem in the code.
We switched back to 2.0.0 and problem solved. I don’t know what is wrong with new versions, for now stick with the 2.0.0.
Overall memory usage is around 4mb, no crashes.
composer.json: