If you are working on Web Development you must have read eventually a benchmark. What several times is not that obvious is that the benchmark you read might not be comparing the different tecchnologies fairly, just because of time and knowledge constraints. And Symfony2 is not an exception, as a framework with several files and features it is always at the lower positions of the ranking. Even though, Symfony2 is not slow.
One of the most popular benchmarks on the Internet is the one from TechEmpower that solves a set of problems with more than a hundred of technologies with an awesome detail. Although, it is still impossible to be able to develop each solution fairly for such an amount of technologies, programming languages and frameworks.
Focusing on Symfony2, anybody that has spent more than an evening working with it knows that to put it in a production environment with a good performance some extra tweaks must be done. But this is just having to change some settings in the configuration files, nothing to do with the code you’ve developed. As an example, I will show the optimization that has given me better results, an optimization for the ORM that comes with Symfony2, Doctrine2.
As you can see in the previous example, different sorts of caches can be configured for Doctrine2. The metadata cache (metadata_cache_driver) allows that every mapping file between your entities and your database tables can be reused, without the need to read the file from disk. But the killer setting is query_cache_driver. When this option is enabled, Doctrine2 only has to transform a query from DQL to SQL once and, as this forces a compile process behind the scenes, it avoids this work written in PHP in every request. It will be done once and after that cached. In the real world, when I used this setting for the first time, I noticed that an API endpoint that was taking a second to finish only took about 50 milliseconds. It was 20x times faster only because I changed a line in a configuration file!!! About cache engines, Symfony2 offers other cache engines, not only APC like Redis and Memcache.
And this is just one of the optimizations that can be done. The Internet is full of resources with tutorials and instructions to improve your Symfony2 application performance critically like this one.