Symfony 2 performance optimisations Symfony 2 performance optimisations symfony symfony

Symfony 2 performance optimisations


These points can optimise your application performance:

  1. Upgrade PHP. The performance gain between PHP 5.3 and PHP 5.4 is very high. PHP 5.5 would be even better, but it's not supported by all distributions, like Debian 7.

  2. NGINX is faster than Apache and the configuration is easier.

  3. Using PHP-FPM with NGINX is a good combination. You can also run your PHP with HHVM which is in average 2x faster than PHP-FPM, provided you replace Symfony/Assetic with Grunt. Caution: HHVM requires more precaution and testing before deploying safely. You can follow these two articles (in French): JoliCode and Big Brains Company

  4. PHP APC extension is deprecated. I think that XCache, Memcached or Redis are better, and they're also most supported at the moment. For PHP >= 5.5, APCu can be used as a replacement for APC.

Additionally, you can read a few articles which talk about Symfony2 optimisation and provide Twig benchmarks.

PHP articles:

Symfony2 and Twig articles:

Others optimisations:

  • Maybe you can use an updated version of Ubuntu.
  • Personally, I prefer using Debian which is also popular for servers because it's very stable.
  • Using a cache proxy like Varnish can be a finishing touch.
  • Varnish requires a developer's implication and maybe a formation. Using NGINX FastCGI Cache to limit FastCGI requests to HHVM, FPM or PHP-NG can resolve speed response.


Did you look this blog post ? http://symfony.com/blog/push-it-to-the-limits-symfony2-for-high-performance-needs

According to your information, i can advise you to try php 5.5 or 5.6 and NGINX with PHP-FPM, it can 40% faster or more.


You can try approach suggested in this article: http://stfalcon.com/en/blog/post/performance-symfony2-doctrine2-orm

The author suggests to:

  • Download all necessary connections
  • Update multiple entities by request
  • Get data as an associative array
  • Use reference proxies
  • Don't forget to use Symfony profiler toolbar

The code described is availiable on github: https://github.com/lensky84/performance