Phalcon MVC Framework and Website Speed

Previously, this blog was written atop the excellent Kohana HMVC framework, and worked perfectly well. Recently, a colleague directed me to Phalcon, which states it is “The fastest PHP Framework”. Bold claims indeed! Since I didn't have any new projects on the horizon, I decided to rewrite my (admittedly very simplistic) blog using Phalcon to see how fast it would run, and also to see how easy Phalcon was to pick up.

The trick to Phalcon's speed is that it's implemented as a PHP extension, so is always loaded in memory with PHP itself, and its code will run at native speed instead of interpreted PHP code. A very clever approach, I thought.

Now, Kohana is no slouch. I was getting around 60ms latency from the blog previously for the page to be rendered and begin sending to the browser on my modest dedicated hosting box. I didn't expect to see much improvement from that. By comparison, a large Zend-based project hosted on a load-balanced cluster lags for up to 500ms before sending anything to the browser. Eurgh.

So, I found myself a free evening and got to work. There's an official IRC channel and quite-good documentation available, although sometimes the docs are a little lacking. Unlike other frameworks that are written directly in PHP, you can't just open up the source and read PHP to see how components work, so the docs are really your primary source of information.

So, having got my head around the Dependency Injection system, Phalcon's models (and model relationships), Volt template engine (again written in C), how did it affect the speed of my site?

Load time of http://blog.drarok.com w. Pingdom Tools: 105 ms from Amsterdam, Netherlands. Size: 73.2 kB. Rqsts: 3. http://tools.pingdom.com/fpt/eGCqRq/http://blog.drarok.com

13ms latency, 28ms to receive the front page! (The rest of the time making up the 105ms it time spent fetching and parsing the CSS, and downloading the background image. I excluded these in both the before and after, since the framework has no bearing on that side of things).

Additionally, even though I didn't test the old site this way, I've run ab against the Phalcon version, and just on my modest hosting box I'm achieving the oft-touted 1300 requests per second, with zero errors! Seriously good stuff.

So in conclustion, I have found Phalcon really easy to get started with. I'm hoping the documentation will improve, but even with that said, I'd recommend anyone looking for an excellent-performing framework give it a try.