F
F
Firepro2016-09-19 20:57:53
symfony
Firepro, 2016-09-19 20:57:53

Is Symfony slow?

I'm currently learning Symfony 3 on PHP 7 and wondering about performance.
There is a task of writing a Rest API, I decided to try Symfony 3, wrote a test API and tried to execute the Apache AB test (ab -t 10 -c 10) for a non- existent method, the processing speed is 2062 requests in 10 seconds or 206 requests per second.
I do the same on Phalcon, the speed is 23297 requests per 10 seconds or 2329.69 requests per second. If you run one request, then the speed is the same, about 90 ms.
What's the catch? Maybe I'm doing something wrong and somewhere I need to configure something so that a non-existent request has a higher speed or is it a normal speed? It is clear that Symfony has a high abstraction and therefore performance is less, but here you just need to print a 404 error.
The Phalcon gap becomes smaller if you take and add a search operation to the database and mapping, through the model built into the framework. Phalcon is still faster though, 1600 requests versus Symfony's 900 requests in 10 seconds.
Configuration: PHP 7, Debian, opcache on, Symfony3, Phalcon 3, Symfony cache enabled, Production mode.
Connected bundles in Symfony:


new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
new Symfony\Bundle\MonologBundle\MonologBundle(),
new Symfony\Bundle\SwiftmailerBundle \SwiftmailerBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle(),
new AppBundle\AppBundle(),
new FOS\RestBundle\FOSRestBundle(),
new JMS\SerializerBundle\JMSSerializerBundle( ),
new Nelmio\CorsBundle\NelmioCorsBundle()

----
Okay, let's take measurements of the resources consumed when running a query to the database for search and mapping :
Let's measure Symfony and the existing PHP-FPM configuration while running Apache AB (ab -t 10 -c 10):

20383 www-data 20 0 380884 26040 18020 R 58.3 0.3 0 : 10.35 php- fpm7.0 -data 20 0 380884 25908 17900 R 57.3 0.3 0:02.77 php-fpm7.0 19479 www -data 20 0 380884 26044 18020 R 52.0 0.3 0:09.30 php-fpm7.0





Okay, on average, FPM eats 52 percent of the processor per process, we measure Phalcon:
24110 www-data 20 0 379016 17876 12848 S 13.6 0.2 0:03.57 php - fpm7.0 -data 20 0 378884 17608 12788 S 13.3 0.2 0:01.08 php-fpm7.0 25445 www-data 20 0 378884 17780 12848 S 13.0 0.2 0:02.48 php-fpm7.0 27177 www-data 20 0 378884 17600 12788 R 13.0 0.2 0:00.91 php-fpm7.0





Phalcon does not load the system, with the same actions, the load per process is 13 percent. I can assume that perhaps the speed is lower and the load is higher due to the fact that Symfony pulls the cache from disk every time, and Phalcon writes everything to memory by default. If this is the case, then how to move the entire cache to memory in order to eliminate the load on the disk?

Answer the question

In order to leave comments, you need to log in

7 answer(s)
E
Edward, 2016-09-20
@Firepro

1. When testing a non-existent method in symfony, an exception is thrown, and this is always expensive and slow.
2. When the existing method was tested, the difference showed the real performance of the framework. And the difference in a little less than 2 times is not so big.
3. Symfony is not used for performance gains. Much more important here is the speed of development and the quality of the code.

C
Cat Anton, 2016-09-19
@27cm

2b931180d841428d919aea22658657d8.png
The picture is clickable.

O
OnYourLips, 2016-09-29
@OnYourLips

Your test is about nothing, you need to test a real application, moreover, in a production environment.
And there is no point in testing them: symfony is for the most serious projects that can be done in PHP, and phalcon is rather just a proof of concept that the framework can be a PHP module, I don’t see a single case when it would be the best solution. Because if you need high performance for a microservice, then there are solutions that are much more productive, of an asynchronous type.

X
xmoonlight, 2016-09-20
@xmoonlight

Also, as a confirmation to the answer 27cm :
https://sitecoder.blogspot.ru/2015/07/high-perform...
High%2Bperformance%2BPHP%2BFramework%2B2

C
catanfa, 2016-09-29
@catanfa

From experience I can say that in the future, in real large projects, with a bunch of events, bundles, etc., symphony turns out to be terribly slow. On my project now, my Action is just starting to execute, and 500ms of time has already passed. This is after all attempts to speed up, cache, etc.

S
shagguboy, 2016-09-20
@shagguboy

symfony.com/blog/new-in-symfony-2-8-symfony-as-am...

M
Maksim Kochkin, 2016-09-29
@MaxxArts

  • It's just that nothing is slow or fast. Speed ​​is measured under specific conditions.
  • The question "Is X slow or fast" should only be asked if performance is your only concern (and it shouldn't be).
  • Finding the “fastest solution” is not the best way to solve a problem. Formulate the problem, formulate sufficient conditions under which the solution will be considered acceptable. Then it will be possible to try to pick up really the most suitable tool.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question