Solved

Zend framework slow performance

Posted on 2009-03-30
4
1,320 Views
Last Modified: 2013-11-11
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
0
Comment
Question by:sree01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 49

Expert Comment

by:Roonaan
ID: 24032779
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
0
 

Author Comment

by:sree01
ID: 24036921
Arnoud,
thanks for your reply.
can you give me an example of the use a custom loader
0
 
LVL 49

Accepted Solution

by:
Roonaan earned 125 total points
ID: 24048401
Sure, no problem, sorry for the long wait,

The code expected two defines to be made:

define('DIR_ZF', '/absolute/path/to/zendframework/library');
define('DIR_LIB','/absolute/path/to/application/classes/folder');

Note that you can just define the __autoload function, and php will pick it up.

An additional note to this is that the 'else' clause is doing an include once rather than doing an is_file. Depending on your application, you need to decide if you want to include an is_file clause, or just want to use it this way.

Kind regards

Arnoud
function __autoload($class_name) {
  if(strpos($class_name,'Zend') === 0) {
    require_once DIR_ZF . DIRECTORY_SEPARATOR .  str_replace('_', DIRECTORY_SEPARATOR , $class_name . '.php');
  } else if(strpos($class_name, 'My_Application') === 0) {
    require_once DIR_LIB . DIRECTORY_SEPARATOR .  str_replace('_', DIRECTORY_SEPARATOR , $class_name . '.php');
  } else {
    include_once str_replace('_', DIRECTORY_SEPARATOR , $class_name . '.php');
  }
}

Open in new window

0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question