Posts Tagged ‘zend framework’

When Did Performance Stop Being Important?

Posted in IT, Programming on September 21st, 2009 by Eric Lamb – 9 Comments

Now that I’m finally starting to “get” the Zend Framework I’m starting to have some serious doubts on whether I made the right choice; not in choosing Zend over another framework but in choosing any framework at all. The memory usage is just abysmal across the board and after working with the Zend Framework for about a month or so it’s not entirely clear if it’s going to scale as I need it to.

When Did Performance Stop Mattering?

When Did Performance Stop Mattering?

Which lead to the question of why.  At the moment it seems like a question of speed of development versus performance (which is ironic because Zend Framework is not easy or speedy to develop with).

<disclaimer>
To be fair, it’s not just frameworks that have an uncomfortable overhead. Just take a look at Joomla and Drupal; 2 popular content management systems with an absurd overhead. It’s just easier to focus on my current interest rather than the CMS’es.
</disclaimer>

One thing I’m having a hard time getting comfortable with is how much memory is required when using a php web framework. Out of the box both Zend and Symfony (for example) use around 5MB per request. Understand, this is without any custom code. Just setting up the MVC and Autoloader for the default views and models. Nothing impressive or useful and 5 fucking MB to run that?

After having been on the wrong end of this issue on my own code I’m pretty sensitive to how my code performs; I’ve written some nasty algorithms and watching them crumble in real time has a tendency to turn you around ;)

Researching the issue doesn’t really help. There’s a lot of advice on how to improve the performance but it seems to always center around common sense improvements you should be using anyway.

The most touted improvement I’ve heard is that you have to use a PHP accelerator and opcode cache. I just find that response flawed but not because it’s bad advice but because it’s common sense. Yes, it’s true, but not using a framework in combination with a PHP accelerator and opcode cache is still better in my experience. All relying on those tools does is move the baseline for performance, which you’re supposed to do already, and a framework still consumes a good amount of resources on it’s own.

In my experience you get about a 50% reduction in memory usage when using something like x-cache but using the Zend Framework  still leaves a total of 2.5MB of memory usage to accomplish the bare minimum setup.

One saving grace is that hardware is cheap. Scaling with hardware is usually the go-to escape when the bottleneck is the code but it’s not without it’s own set of issues. For one thing while it’s true that hardware is cheap the labor to maintain that hardware is not. Especially if you want to maintain the server in a proper and responsible manner.

Another option, that’s really only available when using the Zend Framework, is decoupling the project from a direct dependence and not use the MVC components. In anticipation of doing this I’ve been writing a lot my recent code and projects in a style that’ll allow easy(ish) separation when the time comes.

At this point I haven’t used a framework in a production environment so all of this consternation might be for nothing. I just have a hard time accepting the performance hit of half a MB for using something trivial like a content management system (drupal) or, for example, a component like Zend_Navigation compared to the benefit. What are they actually doing to make the cost worth while?

Still another option is to just walk away from this whole OOP thing and head back to the familiar touch of procedural php and using functions and classes as more of decorators to apply than core components.  From my personal experience, and only my experience, using OOP is way more expensive than procedural. At the end of the day I need my programs to work fast, be easy to operate for my users and have a low impact on the server. How does using OOP help that?

At the moment I’m not sure how this is going to work out. I am confident it’ll be an adventure though. Hopefully, I find out how Zend will scale before a project of mine goes viral or gets popular. Hopefully.

Bookmark and Share

The Framework is the Language

Posted in Programming on September 18th, 2009 by Eric Lamb – 6 Comments

As I’ve mentioned I’m trying to move all my programming to a web framework. It was tough going though because of the sheer complexity and my naivete about the  undertaking.

The Framework is the Language

The Framework is the Language

After about a month of working with the Zend Framework I’m a little… bored with it. If this is what working with a framework is like I don’t want it (thank you very much). I, naively, thought using a framework would increase my productivity and highlight some of the joy I feel when developing and learning but, so far, all I have is frustration and a pretty heavy headache.

Since then, I’ve spent some time looking at Symfony (a fine, but overly complicated, framework), looking at Code Igniter and digging deeper into the Zend Framework. It was while doing all of that, and struggling with the enormity of learning an entire freaking framework, that a thought occurred to me; I need to look at this as learning a new language instead of learning a component.

You can’t approach learning a framework as anything less than you would when learning a new language. Anything less and you’re in for pain. After this realization the framework came together pretty quickly though it still hurt like hell.

So, what does that mean? IMO you should have total absorption; learning a framework can not be done very effectively a couple hours at a time. Frameworks are just too damn big. They have too many parts and all the frameworks I’ve looked at seem to have very different philosophies in the architectural design and structure.

The strategy I took was, and the one I use when learning a new language BTW, is to make the project my world. Everything else is gone and all that’s left is the problem. There is no break, no rest and sleep is used to further solve problems more than it is to recharge. It’s really the only way I can accomplish something as complex and challenging as learning a new programming language.

The good news is that I now feel very comfortable using the Zend Framework though I still have my doubts as to how good of a decision it is to use a framework at all (that’s another discussion though).

Bookmark and Share

Looking For More From Zend Framework

Posted in Programming on August 24th, 2009 by Eric Lamb – 4 Comments

After about a month of working with the Zend Framework I’m a little… bored with it. If this is what working with a framework is like I don’t want it (thank you very much). I, naively, thought using a framework would increase my productivity and highlight some of the joy I feel when developing and learning but, so far, all I have is frustration and a pretty heavy headache.

Looking For More Than Just Zend Framework

Looking For More Than Just Zend Framework

Yup. Zend Framework has made my head hurt.

It’s not like there’s not a lot to love about it; Zend Framework really has the makings of the perfect offering. There’s a really easy sample app walk through for newbies to become familiar with the program. The documentation is suberb and includes code samples of most class methods. Best of all: there’s a bunch of sites out there with examples how to do pretty much everything I could think of with the framework (this was also one of the issues; more on that in a minute).

All that made me feel pretty encouraged and optimistic about Zend Framework when I initially decided on using it. Everything was going along smoothly for a while too; I had gotten past the ZF_Tool issues, introduction to Zend_Application and even developed a couple, basic CRUD, modules which gave me a good grounding in how the layout and structure of Zend Framework… ahem… worked.

Then, I got into the Auth functionality.

First, a few details about what I was trying to build:

This was to be a basic web app with member signup, login, forgot password, contact page (with form). I wanted to build a permission system using Zend_ACL and Zend_Auth and I needed to have complete control over form layouts. (I’m planning on building a full web framework base to help me when building my client sites. This was just to get up to speed with the Zend Framework.)

Anyway, yeah, once I started in on the Auth functionality everything came to a grinding halt. It looks like Zend changed how the Auth functionality works right around the time I got into the framework so all the tutorials and examples I found online were outdated and no longer applicable. The Zend documentation was up to date, which was nice, but I got so turned around from reading the wrong information that the documentation didn’t help. Like, at all.

Let me touch on that point for a minute; Zend changed how the Auth component of the framework worked around version 1.8. There were all sorts of tutorials and example code out online, and some even on Zend itself, but Zend essentially made all of them obsolete through a minor update release.

It’s not like this was a 1.0 to 2.0 release. This was a 1.7 to 1.8 release. It’s always been my understanding and experience that you don’t want to make large, sweeping, changes like that for a minor release.

Fuck, just think of all the code that had to be rewritten so the program would work with the latest version of the framework. Must have pissed off a bunch of people…

I struggled with the Auth functionality for a couple days. A couple full and long days. Understand, I’m not new; it’s been a while since I’ve had any issue with php.

So, I did the only reasonable thing; I walked away. Not from the framework or the project, just the part I was working on. I decided to tackle the issue of form layout. Remember, I needed to have complete control over how the forms were structured. This, too, was an exercise in patience in frustration. This time it was all me just not knowing something; I eventually found my answer on Stack Overflow.

But, as I was working on the form question I noticed I wasn’t having much fun working with the framework. This led me to give serious thought to my choice of Zend Framework. Why was it so popular? What was I missing? Why didn’t I get that “joy!” everyone kept talking about when working with it? Hell, why was I even using it?

I don’t think I did enough research. This is definitely my fault; I should have done more research into my options and try to find something I enjoyed working with instead of the one that was more compelling. Besides, I can still use individual Zend Framework components without using the framework as the core.

Looking at my alternatives I think my best options are going to be either Symphony, CakePHP or even CodeIgniter. I had used CakePHP a couple years ago and wasn’t even a little impressed. This probably had more to do with my reluctance to use a framework than anything else. I hate to say it, because it’s kind of a trite argument, but at the time a framework to me was a directory structure with a couple helper classes. I was not impressed.

The point is that I have to do some serious research and testing now. I have to put a critical eye on all those frameworks (even Cake; 2 years is a long time) and find the one that allows me the most control and gives me the most pleasure to work with. Something I should have done anyway.

Bookmark and Share

Coming Late to the Framework Party

Posted in Programming on July 7th, 2009 by Eric Lamb – 1 Comment

There’s always been all sorts of hype in the php community surrounding the dozens of latest and greatest frameworks sprouting up all over the place. Not that I’m cynical about the framework methodology or anything but, aside from the fun, academic, part, I didn’t really see much use for of them. Over the years, I’ve taken a look at CakePHP, Symphony, CodeIgniter, to name a couple, but I’ve always found the frameworks to be a little… uninspiring.

PHP Frameworks

PHP Frameworks

Plus, like most developers, I’ve developed quite the little tool kit over the years that helps me develop applications far faster than I felt I would using a framework. I know my tool kit inside and out and I’ve spent a great deal of time and love making sure it’s simple, deep, extensible, logical and, most of all functional. My tool kit works very well; to me, this is the killer issue.

How can the developers of all the various frameworks hope to compete for my attention when at best, I’ll have to rewrite tons of code and at worst, I’ll have a horrible time doing it? I have shit to do; unless the quality of my life improves, I’m out.

Well, sad to say, but I’ve since incorporated my tool kit into the StreetWise code base we call CAT. Not to go into too much detail, but we at StreetWise needed to make a tough choice regarding our internal application and absorbing my tool kit made the most sense. I’m actually a little honored that I could provide a solution (though this is tempered by the fact that I wrote the first version of the SW code 4 years earlier and it’s become unmaintainable since).

Cool? Yes, but this leaves me with an empty toolbox.

So, I’ve been looking for a new start and now that I’m starting with nothing I’m all over the whole framework thing. After looking at all of the above I’ve finally decided on Zend Framework. I chose the Zend Framework because it’s a pretty complete, component based system. I like components. I don’t care so much about the MVC architecture, I like Smarty, but I can get over this.

I’ve only been playing with it for a couple weeks and there really are a couple bummers about it;

  1. You can’t use Zend Framework on IIS without a lot of pain. There’s a tutorial on how to do it but it’s complicated and I couldn’t get it working right.
  2. The whole zf.bat thing is a crock; no matter what I did I couldn’t get it to work on either Windows or Linux. Weak.
  3. Configuration is complicated, bothersome and awkward.

I do like that it’s;

  1. zf.bat is extremely useful for generating the base skeleton of your programs. Setting it up is a little painful on Windows, but as long as you avoid the tutorial from Zend, and follow this one from Akra’s Devnotes, you’ll be fine.
  2. As said above, the Zend Framework is component based. I love that there’s a whole library of code available to be exploited and used. Reminds me of what I loved about my tool kit.
  3. Object oriented. I’m ready to accept that OOP is a good thing; the limitations of functions and includes is pretty obvious at this point.
  4. The Zend Framework Manual; this is an awesome resource. Every class in the Zend Framework is documented in the manual.

I’m excited. I’ve already got a couple personal projects in the works using the Zend Framework and I’m sure there’ll be more posts discussing it.

Bookmark and Share