Friday, February 17, 2012

How does PHP perform on IBM i?

Many folks who explore PHP on IBM i are very excited about a solution that works quickly, easily and efficiently. When you grow up from hello world to data inquiry to full blown CRUD you begin to pull a bit harder on the resources that the IBM i has to offer. And it happily accommodates you.

So there are many “myths” about the IBM i. Some will insist that Linux servers are “faster” than the IBM i. In part that may be true and false but for a variety of reasons. However, most of my customers do not have an IBM i because it is the “fastest” computer in the house even though these new Power 7 servers are pretty zippy. Most of my customers have IBM i because of the fact that they lived through the reality of TCO and they have legacy system investments that span decades that they simply do not wish to walk away from. Others will have you believe that the IBM i is not modern. To that I say you have not been to an IBM i event, lately. There are more advanced features in an IBM i today than ever before. With Virtualized everything, PHP, Java, MySQL and all the power of RPG Open Access the IBM i competes quite effectively. But I will spend a few minutes here speaking about the primary value prop of the IBM i: Consolidation.

All the eggs
Consolidation is all about many different workloads happily coexisting on a single platform. It reminds me of growing up on the Southwest side of Chicago in a 2 bedroom bungalow where my parents and three siblings “peaceably” coexisted for many years. Sure there was some tension when we were all packed into a small space. But it also brought about an intimacy that today seems impossible to duplicate no matter how often we “get together”. As we have scattered to the 4 winds we still maintain a closeness, but not nearly as strong as the days we were all together. So one would argue that at times having 6 people in line for the bathroom could slow us down. But at other times, when we wanted to install a new pool, many hands made for light work and would or could do things in a day that could never be accomplished by a single person. I see significant similarities between this life growing up and the data center that blasts apart applications by platform.

Getting back to PHP, when you have all these applications happily humming along on your IBM i there are bound to be conflicts, just like between me and my brother and sisters and so on. So what should we look for? The first thing to do is “don’t just throw hardware at the problem”. Even if you completely believe that hardware is your issue, you should still capture some metrics. There are several tool vendors that can gather these metrics as well as IBM. One partner I worked with had a relationship where they were able to “rent” the tools to create reports. These reports proved we need the hardware, but also confirmed exactly what hardware was needed, where and when we were i/o or memory bound, etc. So let’s pretend that you have resolved the hardware issues, where do you go next?

Working through the “work management” features of IBM can sometimes seem like a dark art. So do the right thing and get a little help. Maybe you go to COMMON and follow the iDevCloud guys, Larry Bolhuis and Jim Oberholtzer like groupies! Another good call is to call your business partner and they offer some services. It’s OK to Google the issue and lurk around for solutions too. But the worst thing you can do is throw hardware at the problem and assume it is fixed or suffer in silence.

PHP workload can be very diverse. One of the things I always tell my users in a demo is that DB2 performance improvements made in PHP applications help not only the PHP script response time, but it also reduces the load on DB2! And, just like the rising tide that raises all boats, every reduction in resources made by building better indexes in DB2 leaves more CPW for the rest of the server. CPW that drives RPG, PHP, Domino and all other kinds of workload. I have a customer who was planning a hardware upgrade. We recommended that they turn on some key features in Zend Server and then upgrade from V5R4 to i7.1. Once they did, new tools became available to indicate where there were performance bottlenecks in their server. No, the upgrade was for the right reasons Disk and RAM rather than “let’s just go to the latest hardware…” Please do not misunderstand me, if you need new hardware, processors, etc. then the investment should be made. But it should be made intelligently. Newer prices on Power7 hardware and maintenance can, in many cases, make the case for upgrading. Get your IBM BP involved and if you do not have an IBM BP or it is time for a change reach out to someone you trust. We have had good luck with the iDevCloud folks and you can too.

This was just a nugget of what we will talk about in the next IBM i webinar at Tune in for more so you too can benefit from the performance possibilities of Zend Server and IBM i.


  1. My boss was working with a PHP app on our IBM i the other day and it was working so fast he asked, "Is it doing anything?" It was, in fact, working and that app runs on Zend Framework (which has a reputation of being slow).

    You are very right about bottlenecks. Here are my personal tips:

    I have written several classes and use singletons to do things like SQL calls. This allows me to create one connection that I use for all database calls and it can DRAMATICALLY improve performance when apps run multiple queries.

    Also, changing this class to use db2_pconnect gave me MUCH better performance.

    Don't be afraid to use the APC functions to cache data. I use them all the time for data that is frequently accessed but rarely changed.

    Finally, writing to the IFS can be surprisingly slow. Once I even discovered my writes for tracking performance were the very thing killing performance. So if your app seems to be running slow for an unknown reason, check the logs and make sure you're not filling up those logs with deprecation warnings and notices. If you are, fix your code or turn those off.

    1. Thanks Matt, all valid points and worthy of consideration! The Zend Data cache API's are available in the Community Edition, as well. We will have a few of these tips and a few more in the upcoming webcast!


  2. Hi,

    I would like to know whether we can run php in shell. If yes, then could any please let me know the procedure.

    1. Sure, assuming i am understanding your question correctly. I think you'll find some assistance here: .




Note: Only a member of this blog may post a comment.