I'm working on an application which uses 6 database, one per language, and
I'm using multidb configuration to maintain different configurations. By
doing that the application.ini file grows a lot, so I was thinking that is
not so smart to reload the entire application.ini for each request.

I wrote a Zend_Application replacement which caches the content of the
configuration file, code and unit tests available here:
https://github.com/fabn/zle/ the class is Zle_Application

I ran some benchmark profiling the following snippet of code and also with
ab tool in the app mentioned above and these are the results

Profiling this code using in turn both Zend_Application and Zle_Application

for ($i = 0; $i < 30; $i++) {
    // Create application, bootstrap, and run
    $application = new Zle_Application(APPLICATION_ENV,
            APPLICATION_PATH . '/configs/application.ini');
    $application->bootstrap();
    unset($application);
}

I obtain these results

http://img841.imageshack.us/i/zle.png/
http://img33.imageshack.us/i/zend.png/

Using apache benchmark tool on the home page of the test application gives
me the following

With Zle:

Concurrency Level:      30
Time taken for tests:   22.006 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      3231500 bytes
HTML transferred:       3108000 bytes
Requests per second:    22.72 [#/sec] (mean)
Time per request:       1320.338 [ms] (mean)
Time per request:       44.011 [ms] (mean, across all concurrent requests)
Transfer rate:          143.41 [Kbytes/sec] received

With Zend

Concurrency Level:      30
Time taken for tests:   25.989 seconds
Complete requests:      500
Failed requests:        0
Write errors:           0
Total transferred:      3231500 bytes
HTML transferred:       3108000 bytes
Requests per second:    19.24 [#/sec] (mean)
Time per request:       1559.311 [ms] (mean)
Time per request:       51.977 [ms] (mean, across all concurrent requests)
Transfer rate:          121.43 [Kbytes/sec] received

Tests shows that my class is about 16% faster than Zend_Application.

I've also ran some test with memcached with the same snippet as above and
it's even better here are the results

dev:/tmp/zle# time php bench-zle.php 

real    0m1.422s
user    0m1.224s
sys     0m0.148s
dev:/tmp/zle# time php bench-zend.php 

real    0m1.849s
user    0m1.776s
sys     0m0.072s

Used code is the same as before, this time with 300 iteration,
Zle_Application constructor is 24% faster than Zend one

I don't see any drawback in doing this.

Any thoughts?

I was thinking that a similar approach could be implemented directly in the
Zend_Config class in a transparent way, by replacing code in Zend_Config_Ini
and Zend_Config_Xml constructor. What do you think about that?


--
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/Using-cache-for-application-config-file-tp3421394p3421394.html
Sent from the Zend Framework mailing list archive at Nabble.com.

-- 
List: [email protected]
Info: http://framework.zend.com/archives
Unsubscribe: [email protected]


Reply via email to