vicmarq
vicmarq

Reputation: 197

Symfony2: How can "Initialization time" be reduced?

I'm experiencing some problems with Symfony in a production environment. When I check the Symfony profiler's timeline I can see that the request is taking roughly 1000 ms on average. The request itself (since kernel.request event fires) is taking less than half of that time. Initialization time is between 500-700 ms in every Request and I don't know how to reduce it to a normal level. In my local machine initialization time is about 100 ms. In the production server Symfony is running in a VPS (Ubuntu Server 12.04, 2GB memory). I interpret that "Initialization time" is the time since front controller starts running until kernel.request event is fired in HttpKernel::handleRaw. Correct me if I'm wrong

Being specific my question would be: What Can I do to reduce initialization time?

I googled about this problem and I found people that solved it by disabling xDebug (disabled on my server). I tried some other "improve performance" things I found like setting realpath_cache_size to 1024k (it was 16k) or apc.stat to 0 with no luck. Any help would be really appreciated as I need the app to perform better to meet the requirements. I leave here my PHP configuration from Symfony profiler. Thanks

PHP configuration:
PHP version 5.4.25-1+sury.org~precise+2
Xdebug  disabled
PHP acceleration    enabled
XCache  disabled
APC enabled
Zend OPcache    disabled
EAccelerator    disabled

EDIT: I installed xhprof and it seems I'm having problems with APC. When APC works the problem solves (initialization time reduces to about 50 ms), but sometimes it doesn't work and the entire request takes 1 sec. I've set apc.ttl to 3600 but If I wait for some seconds and request the same URL ther's a cache miss for the first time. apc.stat=0 apc.ttl=3600 apc.shm_size=128M apc.user_ttl=3600

Upvotes: 3

Views: 4914

Answers (1)

Darragh Enright
Darragh Enright

Reputation: 14136

there are a few similar questions in SO - here's one that I found useful before:

Symfony2 Slow Initialization Time

Additionally, here's an interesting set of slides discussing SF2 performance tweaks:

http://slides.seld.be/?file=2011-10-20+High+Performance+Websites+with+Symfony2.html#24

Hope this helps :)

Upvotes: 3

Related Questions