views:

242

answers:

5

I am working on a Facebook game which is developed using Zend framework. Right now I don't have lots of traffic and already seen quite a large # of data usage / CPU time.

Actually, I'm not good at Zend. I good at coding from scratch for both PHP & JS.

so, I am curious about the performance of Zend framework. becuase I'm thinking about rebuilding the applciation using Zend as the backend to manage the data / session / logic. and use JS (native code or JQuery) for the front-end rendering UI and handle user action in the client side.

In between, use aJax to get data from Zend backend.. most likely REST.
Anyone has suggestion about this kind of structure? I want to cut down the server load by that and also easier to manage code, plus better user experience.

Appreciate if anyone has good idea. :)

(POST few days later)

so, baseline PHP should be faster and use less data transfer (if code correctly) then Zend (or any) framework, right? Code reusablility is not a big concern here. :)

+2  A: 

Here's what you're looking for: PHP framework comparison benchmarks

o_O Tync
+1  A: 

In my opinion, benchmarks of frameworks are useless. They say something about an abstract situation, but performance is very situational. You should measure your application and optimise that. Yes, there's probably a limit to how far you can make your application go if you use lots of components from Zend Framework, but then there's also a limit for how fast your application can go before you need to drop PHP and write it in C. It's possible to make Zend Framework perform just fine on a high load site, but you have to put an effort in to it. Just like you have to if you don't use it.

troelskn
+2  A: 

One thing many php developers fall victim of is sacrificing good architecture and sound principles for what they perceive as performance.

You may decide to cut corners in your code, but remember, "premature optimization is the root of all evil". So if you need to optimize early make sure that you're actually doing something useful.

The Zend libraries are engineered with best practice in mind, not necessarily performance. The rationale is that there are many ways to speed things up later without sacrificing code maintenance and readability (caching, load balancing, hardware, queue management, etc).

That been said, I don't think what you're looking for are statistics on ZF's performance, but rather advice on how to setup your application with it. Specifically, I'd advise you to create a dedicated, very light bootstrap for ajax requests. In ajax, you would normally only need some minimal prerequisites before dropping inside your controller. For the non ajax requests, set them up normally using the recommended architecture (bootstrap, front controller+plugins, controller+helpers, model+views+helpers).

My personal rule of thumb is that if I only am going to serve about 100 requests throughout the day, then there's very little reason to optimize anything. When the application starts feeling sluggish, if it generates enough revenue, maybe I can get a dedicated server, if not, there are always solutions such as apc, memcached, beanstalkd, etc.

mike
"We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." Donald Knuth.
Alister Bulman
thanks. Our game was already out for beta. and performance is really an issue. especially when we r in cloud. every byte counts for $. and daily requet is more than 100,000.
Murvinlai
+1  A: 

There is only one thing to do first if you think that a ZF-based app is slow. Measure it. Various tools exist that will take the profiling output of Xdebug to show you which parts are slowing down the process, then you can make some moves towards optimising those parts (such as a lighter weight initialisation, and/or some caching). One good resource is the the Zend Framework book at survivethedeepend.com, "performance optimisation for ZF Apps".

Alister Bulman
+1  A: 

Zend Framework vs raw PHP code tends to be close to a 1:500 requests per second ratio.

If you have a lot of time and not a lot of money, develop in raw PHP. If you have little time and enough money, develop in whatever is fastest without regard for performance...you can always add hardware later. If you fall in between the two, balance it as you see fit.

As much as I dislike it, CakePHP is faster to develop in than ZF, so it's great for time crunches. CodeIgniter is faster than either, but doesn't have as much built-in, so it's closer to the performance end of things without going to raw PHP.

coreyward