Performance Analysis with Z-ray in Zend Server 7

ray-gunZend Server 7 was released last week which includes Z-ray, a performance analysis tool. (Think X-ray vision.) I have done my fair share of performance analysis over the years in C/C++ and Java, so was curious to see how good the tools around are for PHP. So here are my experiences after a few days of kicking the tires.

Zend Server 7 has a few editions with 30 day evaluation periods. I grabbed the Enterprise version for Windows and put it on my laptop. I don’t remember the exact installation sequence, but I made sure I enabled Z-ray by default. Configuration all up was pretty simple.

(Later, I tried to turn the server off. Since I was on Windows, I went to Control Panel and found Services. Sure enough, there was Apache2.2-Zend plus 5 other services starting with “Zend” at the bottom of the list. Fairly easy to shut down.)

I had not used Zend Server before in earnest, so after installation I started looking to work out the easiest way to get my existing local source tree working with Zend Server. There was lots of talk about how to create deployment packages, but I was hoping for faster edit/test cycles than having to build a package and deploy it each time. I noticed something about “defining applications” which talked about adding an already deployed application. I remembered also someone saying how easy it was to achieve, so I persisted and finally found the page Deploying Code with Zend Server. For Windows, there is an Apache2\htdocs directory under which you can drop your applications directly – no need to package and deploy. (Yay!)

Rather than copy my code, I cheated further by creating a symlink using MKLINK /D. My local source code then appeared under the Zend Apache web server directory and it all started working. (For Linux, you may need to change some configuration file to allow following of symbolic links – not sure.) So I did not have to mess with my normal development practices to get it going.

Next I pointed my web browser at my application and watched what happened. At the bottom of the page the Z-ray bar appeared. I immediately went to read the documentation started clicking buttons to see what would happen. (OK, truth be told I had been given a demo beforehand so I had a pretty good idea what was going to happen.)

  • First button showed a summary of HTTP requests, elapse time, number of database queries for the page. I think this will be more important with pages doing AJAX calls.
  • Second button was a pause tracking button.
  • Third button was a ‘clear’ button – wiped recorded results.
  • Fourth showed a summary of how much time in PHP, Database, IO, and network. Also showed peak memory usage.
  • Fifth had a “slow page” and “lots of memory” warning.  I assume the admin interface would let me change the alerts.
  • Sixth was errors and warnings. The demo I saw showed uncaught exceptions or similar here.
  • Seventh button is where it starts getting really interesting. It shows all the database queries issued for that page load with elapse time per query. Very nice! I mean this information is available in logs, but doing a page load and seeing it right there on the page – nice!
  • Eighth button shows the PHP profile for the last page load. Shows inclusive and exclusive time (function call including duration of child function calls, and without child function calls), number of calls, etc. You could exclude groups of functions you were not interested in.
  • Nineth button shows the $_ variables (like $_SESSION and $_COOKIE). A cute feature is to be able to show only values that were changed by the page request.

I spent most of my time looking at the function profile. The database query list is something I can imagine getting to next, but just knowing how many database accesses were performed to bring up a single page was rather sobering. (Also impressive – MySQL is pretty fast!) I did notice a few of the figures did not seem to add up. When I asked the folks at Zend it was explained that some of the numbers include start up times for the PHP interpreter, some figures included the performance collecting overheads and others didn’t, etc. Not a big deal.

So is Z-ray useful? The thing I really like is how easy it is to get a performance profile. I can change code in my IDE, save it, and reload the web page in a browser to get a new results. The elapse time figures did jump around a bit between runs without code change, but it definitely accelerated the experimentation cycle. I think the main value will be because it is so easy to see your performance profile (and queries and memory usage) you will look at it more often. If you care about performance, definitely worth checking out the free trial period. It would not replace having a formal load and performance test framework, but kinda cool for ad-hoc experimentation.

Did I identify performance problems in the code base I was playing with using the tool? Yes. Known problems in my case, but it made it really clear how significant the problem was, and importantly how effective different quick experiments were to solve the problem.

Oh, if you want some screen shots or demos, try here.

Disclaimer: These opinions are my own and not that of my employer.


  1. Hi Alan,

    thanks for this blog post! I was also curious about the Z-Ray feature of ZendServer and tried that this evening (before I discovered this post). Installing was super easy, but for a development environment I also prefer my usual development setup instead of dealing with deployment packages.
    One the one hand I really like sticking to the the classic stack and using tool like xdebug and NewRelic (and Aoe_Profiler for Magento,…) on the other hand I like the simplicity of the tool, although I don’t see us using this in production, so my dev environment wouldn’t be a perfect clone.
    What’s your conclusion? Are you planning on sticking to ZendServer?
    Btw, as ZCE you’ll get a free developer license…

    Have a great day,


    1. I don’t have a conclusion yet to be honest. I saw it as a useful tool for the toolbox. We having been building up the internal team dedicated to building a robust load and performance environment – Z-ray would not replace that effort for example.
      Regarding license, we also develop commercial software so I don’t think ZCE would apply to me… and I don’t mind programmers getting paid for good work!

    2. Hi Fabrizio,

      You don’t have to use the Deployment mechanism of Zend Server in order to enjoy Z-Ray advantages (among other Zend Server advantages). Your PHP files, that probably reside on your document root, will automatically be located by Zend Server and Z-Ray will work for you out of the box, without any configuration or setup!

      Regarding production: Z-Ray can be used in production very efficiently and securely. Please read more here about Secured Mode:

      We will be happy to address more questions and concerns regarding Zend Server any time at:


      Zend Server PM

  2. Test the Z-Ray today.. and i see it works on some project and others don’ simply only loads “Loading Z-Ray”..

    1. Hi Doxadigital, thanks for testing the Z-Ray.
      My name is Amit from the Z-Ray development team, i would like to get some details about the projects where Z-Ray didn’t work on. Please contact me at amit.d at

  3. One question – is z-ray supported also when doing requests to a page with JSON content? I mean content-type = application/json

    1. I have not tried myself, but I saw a demo showing the main page request plus a series of AJAX calls with timing info for each. It grouped them in the one report and I think you could then pick which request to analyze.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: