Phalcon PHP on Jelastic
Every developer knows that frameworks are a great help to implement a lot of application features in a very short time. Frameworks provide impressive development speed, but all of that power and functionality usually comes at a high cost – performance!
Writing your own code, line by line, can lead to a more efficient solution – but it’s so much slower to develop. What if you could enjoy the benefits of a powerful framework to do more in less time, but still end up with a high performance application instead of something you have to time with a calendar?
Frameworks intentionally do a lot of heavy lifting for you, but that means your “simple” one-line code is actually a lot more complex than you probably realise! It’s not their fault things run slowly – all of those abstraction layers and modules running as PHP code – expecting it to perform well is a big ask.
Let me introduce a real gem of a framework here to solve that problem for you – Phalcon. It borrows from the ideas of PHP: running as compiled C code (just like the PHP engine itself does). By removing that extra layer (PHP) and running the framework at a lower level it performs much faster. It’s a more lightweight and nimble creature.
Don’t worry, you don’t need to learn a new language to use it: all of your code is still written in PHP!
Why Application Speed Matters
It sounds obvious – everyone likes to use a responsive website or web application, so of course the faster you can make yours run, the better? Yes! Not just to make your users a little happier – various studies by Internet giants have shown this has a real impact on the number of users using your service and customers buying your products:
It costs to be slow
Amazon: 0.1 second delay => 1% drop in revenue
Google: 2% slower page => 2% drop in searches per user
Google Maps: 30% smaller file size => 30% increase in requests
Bing: 2 second delay => 4.3% drop in revenue per user
Aberdeen Group survey: performance issues cost up to $117 million lost revenue per year
Speed up rewards
Mozilla: download page 2.2 seconds faster => 15.4% downloads growth
AOL: faster page load time => 50% increase in pages per visit
Shopzilla: 5 second speed up => 25% increase in page views, 10% revenue increase
Google now use site speed in their search ranking algorithms, so speed is not only important to user experience, but also determines whether you can attract traffic to your site from the search engines. (Shopzilla gained 120% growth in search traffic after boosting site speed).
Making your web application or website as fast as possible has a direct revenue impact. Even apparently imperceptibly small delays (100ms or less) offer % revenue opportunity.
How Phalcon PHP works
The business case for using the fastest PHP framework you can find is extremely clear. Phalcon aims to be that framework, so let’s take a closer look at how it gains speed compared to the alternatives.
The big one: PHP is an interpreted language (not compiled), so it has to be (re)interpreted at every single page request. Since most PHP frameworks are (naturally) written in PHP, all of that complex code has to be interpreted each time. The PHP engine translates the interpreted code into machine code so that it can execute.
Phalcon is written in C (a compiled language), ready for immediate execution (the C code is translated to machine code ahead of time, and is saved that way on the server so it can be executed without any extra work).
Although there are various JIT (Just In Time) compiler projects for PHP (one of the most prominent and well known examples being Facebook’s HipHop project), they are extremely alpha at this stage and all have limitations which make them generally unsuitable for any environment except the one they’re created to address (e.g. HipHop only addresses a limited subset of PHP rather than the full language, so your code may not run).
Fewer filesystem calls
Take a look through the source code of any major PHP framework and you’ll find hundreds of separate files. Each request that comes in has to “include” the right combinations of those files to process it, and that means each request has a lot of filesystem I/O overhead – filesystem accesses are about the slowest thing you can do in computing.
Phalcon is heavily optimised to eliminate filesystem overheads on the framework side. The graph below shows how various popular frameworks compare in a simple benchmark test:
As you can see in the graph above, Phalcon PHP is significantly more efficient (in terms of file includes) than all of these alternative PHP frameworks.
As mentioned above, Phalcon works at a lower level (in C, instead of in PHP), and therefore can be more heavily optimised. For example, with Phalcon you can interact with databases via a C-language ORM, and Phalcon directly accesses internal PHP structures to optimise execution.
Phalcon’s efficiency enables it to run faster, which as shown leads you to higher revenues, but there’s a side effect. This is the one that stops (other) hosting companies wanting to talk about it – Phalcon uses less resources; you need less CPU and RAM to handle the same amount of traffic for a website using Phalcon (so less money for the hosting company – you need fewer / smaller servers).
That’s logical: if the requests are handled more quickly, the server is already free to handle the next request much sooner as well. Also if the framework is efficient, it doesn’t need as more resources in the first place.
So Phalcon helps to grow your revenue (you get more traffic, and higher conversion rates), and it saves you money on hosting costs at the same time! If these things are important for you, I guess you should probably start using this framework for your projects…
How to install Phalcon PHP on Jelastic
Phalcon is a compiled PHP module, so it needs to be installed at server level and isn’t suitable for a typical shared hosting service. Even on a VPS, it’s a bit of a pain to have to compile things just to run a PHP framework!
Thankfully our Jelastic PaaS gives you your own servers, so you have complete control to choose which PHP modules are installed and enabled – but we already did the hard part for you: we’ve compiled the Phalcon modules, so you just need to upload it to your Jelastic environment via the dashboard.
Start using the Phalcon PHP framework in your projects today. Read our handy knowledge base article explaining the 3 simple steps to install Phalcon PHP on Jelastic.