views:

2385

answers:

11

Hi guys, I'm working on a community based website using zend framework - but its so slow it takes a while for pages to load. I would like to know what aspects of the zend framework should I look into to ensure it runs much faster.

Any tips and help would be greatly appreciated :)


Nice advice - I took upon the database and indexed it from scratch - there werent any indexes to start with :\ but anyway the speed has improved a bit but its still rather slow. Is there anything else that I must be keeping an eye on right here?

Because I'm just assuming its something to do with the framework as when I first ran basic tutorial projects made using the framework - they were a bit slow as well.


Nice tips - had a look at the zend performance guide article. I'm not so sure where to put the code for caching table metadata though :( [sorry for sounding like such a noob here] as mentioned at this link

+3  A: 

The most obvious one would be zend_cache

Rick J
+7  A: 

Install APC on the server. Opcode caches eliminate a lot of the overhead caused by frameworks. You can generally do this by simply running

pecl install apc

on the server.

Emil H
+1 This is absolutely crucial for any PHP site that needs to have good performance. If not APC, then another opcode caching solution.
Bill Karwin
+6  A: 

Definitely install APC as it'll probably give you the biggest performance gain (2-4x) for the least work. I'd also recommend that you take a look at the Performance section of the reference guide.

Zend_Cache can be used with a lot of the ZF components to speed them up, as well as with your own data.

David Caunt
+15  A: 

The only way to know for sure where your bottlenecks are is doing deep profiling.

I use xdebug, combined with kcachegrind (part of kde for windows). It generates full call traces for every PHP script that is executed, which you can then inspect to find out which functions are taking up most of the time. No code changes necessary, so you can easily profile third-party libraries like Zend Framework.

Joeri Sebrechts
This is the best way, and can help with deciding where to use Zend_Cache
David Caunt
I think there's a few tools that are good to look at before breaking out the debugger - Both firebug and Safari (I actually prefer Safari's) a view of all the requests made while loading your page. If you're loading a bazillion CSS and JS files, this will kill perceived performance. Likewise, it might be worth getting a dump of your DB queries - if 80% of your time is taken up by DB queries (or, even worse, half the time is the -same- query) dealing with this level of profiling is premature.
Sean McSomething
+2  A: 
Silfverstrom
+6  A: 

Most performance issues on the web are database issues, always start looking at the database side of things before moving on.

It might be that there are a lot of database calls made where you can suffice with fewer calls, indexes not placed on the correct columns.

These are the things which usually slow things down.

Mischa Kroon
+5  A: 

If you can be on the same LAN as the server (at least for testing), then you can verify your profile (somewhat) from a client.

If it's a single machine, the most likely cause for slowdowns is memory issues (something using too much, or too little main memory), followed by horrible DB queries.

A PHP opcode cache always seems to help, also remember to disable "atime" (noatime mount option on *nix, a registry change on Windows) to avoid expensive disk writes.

A decent article on more Zend specific things is: http://till.vox.com/library/post/zendframework-performance.html

LapTop006
That article is a life saver - thanks for the help!
Ali
+1  A: 

Agreed with the database comment. If your site is slow, it is most likely NOT a Zend framework issue, and most likely a database issue.

+3  A: 

Take a look here:

Performance Guide on Zend

Zend_Log which can log & trace your application

Boris Guéry
A: 

http://www.nabble.com/Caching-of-MVC-and-other-ZF-components-td15576554s16154.html

I guess we'll have to wait for PHP5.3 to be released and then hope we can use it on a production box. :)

+2  A: 

Regarding Zend_Db_Table metadata caching, you should configure the cache in your bootstrap and add it to the Zend_Db_Table_Abstract class as a static property.

(Similar to the way you would open a default database adapter and set it to be the default adapter for all Zend_Db_Table objects.)

There's a code example of configuring a default metadata cache in the section of the manual you linked to. This would go in your bootstrap.

Bill Karwin