Symfony2 website with +100 users = 100% CPU charge Symfony2 website with +100 users = 100% CPU charge symfony symfony

Symfony2 website with +100 users = 100% CPU charge


After one week with new settings, here is what I do to improve the performance of my server.

First, I used Nginx fastcgi cache. This clearly improve performance !! The cached pages are very very fast.I followed something like http://www.digitalocean.com/community/articles/how-to-setup-fastcgi-caching-with-nginx-on-your-vps or http://techminded.net/blog/transparent-cache-in-nginx.html It's easy to understand how it works with these. My cache is setted up with 5 minutes. It's too much for some pages, not enough for others. I must work on that point. But as this was PHP-FPM taking all resources, not executing php code has clearly lower the CPU charge.

Second, I set the APC cache size up to 128M And I think that was the biggest problem of my server config. Symfony use APC a lot and the APC cache was 100% fragmented ! I saw this with the apc stat page (got it from here as it was not present on my server : http://jesin.tk/apc-php-download/ ). Now the APC cache is 0.76% fragmented, 95% full, 100% cache hit !The settings I changed : apc.shm_size 128M and apc.max_file_size 3M.

BTW, on the APC stats page, I can see 1728.50 cache requests/second. Of course, if your cache is bad, the performance will be bad. It's all clear now ! This should be explain somewhere in Symfony's documentation as it's a very important point.

The server is now really stable, CPU load about 2. I think I solved it !


Seems like it is normal situation. Server not so powerful, and there is a lot of requests per second. To make sure that all ok, please provide page generation time, when site is not under load, and how many request does site gets per second (from access logs for example).

One of solutions to this high load problem is to enable Nginx cache. If you have a few pages, even 1 seconds page cache will be huge improvement. Nginx can serve thousands pages per second from cache.


  1. nginx configuration - you can limit number of connections from one ip address

    limit_zone one $binary_remote_addr 4m;limit_conn one 4;

  2. you can try to enable symfony 2 file cache or use something like varnish. If you are going to use symfony 2 cache you get more hard drive loading
  3. you can try to use Doctrine Array Hydration