Link to home
Start Free TrialLog in
Avatar of sree01
sree01

asked on

Zend framework slow performance

Hi,
I just started using zend framework for a project.But it is very slow in performance.I am using the Zend_Loader::registerAutoload method.Is there any way to improve performance.My Ajax request takes more than 10 seconds to get reponse.

thanks in advance

Sree
Avatar of Roonaan
Roonaan
Flag of Netherlands image

10 seconds is indeed very slow. ZF however is known to be slower than other frameworks, but this is too slow.

There are a multitude of areas you can tweak ZF on, I used I think at least 8 methods involving different approaches on a recent application.

1]
I know that the default Zend_Session is locking its session file during the whole request, instead of closing it when done writing.

Certainly for AJAX based environments where multiple request happen at the same time asynchroneously, this leads to the behavior that still the requests are processed one after another.

Before diving deeper, are you using multiple asynchroneous requests at the same time? (You can use firebug or a IE equivalent to see which HTTP requests are made and their wait/response times)

2]
Implementing caching on your configuration files. This saves a lot of parsing

3]
Instead of using Zend autoload, use a custom loader that does no file_exists check on Zend_* classes, but just includes them. I can show you code later, but have to get some sleep first.

4]
When using any form of autoloading, Make a copy of your ZF install (ZF_Opt for instance) and remove all require_once statements. Include all files using absolute paths instead of relative ones. This saves path resolving by lower level processes.

5]
You can use a controller plugin to track the includes being made within certain modules. Then on consecuetive requests include the files in preDispatch using absolute paths. This causes less lookup.

6]
You can merge different related Zend_* files into single package files.
For example:
1) Copy Zend_Controller.php Zend_Controller_Front.php and other Zend_Controller to a ZendController.package.php.
2) Write an include_once 'ZendController.package.php'; in each original file
This will cause all classes to become available when a single one of them is called

7] Implement full page caching

8] Use more local variable to store $config->something->something->something references. Because in ZF classes with overloaded properties, an array_key_exists is used for each time you access a property, causing you to do unnecessairy processing.

9] Use APD or XDebug to find more bottleneck.

This is just a start of things I could think of for now. I'll get some sleep and we can dive deeper tomorrow.

Kind regards

Arnoud
Avatar of sree01
sree01

ASKER

Arnoud,
thanks for your reply.
can you give me an example of the use a custom loader
ASKER CERTIFIED SOLUTION
Avatar of Roonaan
Roonaan
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial