smorhaim
smorhaim

Reputation: 798

Please explaining this Symfony2 vs ZendFramework 2 performance results

We are benchmarking Symfony2 with Doctrine2 vs. ZendFramework2 with Doctrine2.

The test consisted in a bare ZF2 and SF2 Hello World for baseline Vs. the same but with Doctrine2 loading a simple object. We used ab and measured only the requests per second and time per request.

During the bare framework test Hello World ZF2 performed much better than SF2 almost 2x as better.

However when we did the same test but adding Doctrine2 into the mix the results were inverted. SF2+D2 behaved 2x fast as ZF2+D2.

We have skills in-house for both Symfony2 and for ZendFramework so we could go for either or, and we are not concerner about RAM usage as we can always get more RAM. But we do care about performance and we need helping the best tool.

Some ideas: - We believe S2 is doing some sort of caching - We believe ZF2 Doctrine2 ORM Module might be the cause - We are unsure as to what type of caching to use in production? APC?Xcache? etc.

Framework + Doctrine loading an object      
Concurrent:100 / Connections: 1000      
    Resp. T ms  Req. Sec
ZF2        60   16
S2         31   32

Framework + Doctrine loading an object      
Concurrent: 25 / Connections: 150       
    Resp. T ms  Req. Sec
ZF2         57  17
S2          30  32


======================

Framework Bare      
Concurrent: 100 / Connections: 1000     
    Resp. T ms  Req. Sec
ZF2         10.5    94
S2          15.3    65.36       

Framework Bare      
Concurrent: 25 / Connections: 150       
    Resp. T ms  Req. Sec
ZF2         10  98
S2          15.4    64

Upvotes: 5

Views: 3906

Answers (2)

FarWest
FarWest

Reputation: 461

With proper caching of opcode (APC) and of DB requests (for example with Memcache), I would say that the difference between Synmfony and Zend will be peanuts.

Never choose a framework because of such a small perf difference. You'll gain much more perfs with caching and DB improvements that on the framework.

Unless you are building a finance real time app, or kinda, 10 or 20ms difference in response time is nothing. The average response time for a web page is usually in 100s of ms !

Also, converting a response time to a "number of requests per second" makes no sense, although I know this is common in PHP benchmarks. Because your Apache is not going to treat requests sequentially (one requests does not consume 100% CPU), 5 requests arriving at the same time will be served in less time than 5x the time for one request.

As Ocramius said, you should activate metadata cache:

    $frontendOptions = array(
       'lifetime' => 7200, // seconds
       'automatic_serialization' => true
    );

    $backendOptions = array(
        'cache_dir' => APPLICATION_PATH_CACHE
    );

    $this->cache = Zend_Cache::factory('Core',
                                 'File',//Memcache is better
                                 $frontendOptions,
                                 $backendOptions);

    //ADD a metadata cache for DB, important for perf
    Zend_Db_Table_Abstract::setDefaultMetadataCache($this->cache);

Upvotes: 0

Ocramius
Ocramius

Reputation: 25431

By default, the DoctrineORMModule integration has no kind of caching active.

You have to set caching for your mappings in the configuration:

'doctrine' => [
    'driver' => [
        'orm_default' => [
            'class' => 'Doctrine\ORM\Mapping\Driver\DriverChain',
            'drivers' => [],
            'cache' => 'apc',
        ],
    ],
],

The default cache is array. Otherwise, parsing of annotations and any other kind of mappings will happen at each request.

Since I'm also maintainer of the ZF2-Doctrine2 integration, I may also be interested in finding out more about this topic. Do you have a test environment to show?

Upvotes: 7

Related Questions