2012: The year of PHP cloud hosting

Posted: 2012-01-02
Category: PHP

Cloud hosting is nothing new. Seeing as "cloud" is such a loosely used term some will consider their VPS solutions on Slicehost or Rackspace to be "cloud hosting". That is partially true, but this article covers how PHP is getting some serious attention in the PaaS (Platform as a Service) field. This year you will almost certainly find yourself making the decision wether or not to move some of your applications and services across to the cloud, and this article can hopefully help you work out why and how.

The two PaaS solutions in my toolkit right now are PHP Fog and Pagoda Box. I've been using the two systems for the last year since they were kind enough to let me into their private BETA. Currently in my mind there are no clear victors as they both work a little differently, but they both achieve the same goal: get your code running online quickly and securely.

That sounds quite a lot like Heroku?

Precisely. The Ruby community has had Heroku since 2007 and they've been offering the same thing for quite some time. Heroku is a very simple service that is basically a Git repository that will deploy your code once you push to it and automatically handle any dependencies you might have such as Gems (think PEAR or PECL for the PHP's closest equivalent, but less clunky).

Ruby didn't just get one PaaS though, there are quite a few smaller companies and one large competitor Engine Yard which was founded even earlier in 2006.

So why is this new?

Well this has not existed at a decent level in PHP for very long. The main reason for this is that for a long time PHP didn't really need it. If you look at Ruby it is much more low-level than PHP and it needs a little kick in the right direction to become a web-ready language. It needs WeBrick/Thin/Shotgun web-servers running to get it accepting HTTP requests and is in general designed more for long-life processes while PHP has always been more about distributed .php files running once on fire-and-forget mode using CGI or mod_php. In general Ruby systems take a bit more work to get running on the web, Heroku helps speed that all up.

That is still true, so why do we need PHP PaaS now?

Speedy Deployments

If you are still using FTP as your main method of deployment you really need to go and sit on the naughty step and have a think about your life. FTP is slow as balls, insecure and did I mention it was slow as balls? Version Control has come a long way in the last few years and adoption of Git in the CodeIgniter community has meant that all my projects now use it.

Now what happens when we want to deploy all of our well managed, feature branched, Git tracked code? Open FTP and drag files around? Pfft. Hit FTP Sync and hope I don't randomly delete content from the live site? No thank you.

There are some tools around such as DeployHQ which will take your Git repo and deploy changed files over FTP/SSH for you. Over the previous option this is at least a step in the right direction, but recently I've had a few nightmares. If you upgrade a site using DeployHQ and you for example upgrade a CMS which has renamed a integral folder, it will go and delete all those important files before it starts uploading the "new" files. Sure that might not that common, but definitely a potential concern.

Another option is to spend some time faffing about with the Ruby-based Capistrano? If you have been using Capistrano a while you'll probably have it down to a art form, but this is an extra thing to learn which is often beyond the means of some new users. Go back to the first time you tried to set it up. I've got to be honest, I've had less stressful experiences.

PaaS services such as PHP Fog and Pagoda Box take care of all of this for you. Create your application and they give you a Git remote to push to.

Deploying my sites has become as simple as running one command:

$ git push production master

I migrated pyrocms.com away from a VPS to Pagoda Box in about 10 minutes thanks to that simplicity. Yummy.

Security

Hosting code can be a dangerous game, with even companies like Facebook screwing up at times. Anyone can get a basic LAMP stack up but if you want it to be really secure what do you do? Teach yourself a whole bunch of sysadmin stuff and take on that role as well as being the developer? That's two jobs. If you're anything like me and already stuck with project management, book keeping and even event management now the last thing you need is another hat to wear.

If you are running a company you'll probably end up hiring a guy (or a team of guys) just to look after your servers. Shoving it in the cloud takes care of that for you, and if you have any security leaks... hell you have somebody to sue for it.

Scaling

No more "Slashdot-effect" for you. You can easily control how much traffic your system is ready to handle, with some systems offering "auto-scaling with daily budgets", meaning you can pay for your average traffic then if you suddenly get a massive spike your instant instantly adapts to handle the new load.

On the whole with Pagoda Box I find that one instance can handle 1,000 users a day just fine. Once or twice I've dragged the slider to two instances just so I don't get that Pingdom email while I'm out with the girlfriend, just for safety of mind. Scaling of that ease is POWERFUL stuff.

Future

A few months ago it seems pretty much every PaaS provider decided that they all had to do everything. While I'm still not sure if that is for the best, Heroku now handle Java, Python, Scala, Grails, Python/Django and I hear they have a PHP in private BETA - but don't quote me on that.

Engine Yard made a similar move and snapped up Orchestra.io which is another PHP platform that's been around for a while. I had a Skype preview of that one back in its early days and it's another great contender.

PHP Fog are going the other way and starting to offer other services, under their rebranded service App Fog.

If you're interesting in hearing more about how Cloud Hosting works, I've managed to get Pagoda Box to send their Chief Architect, Tyler Flint over to CICONF 2012 in London this February.

The future is looking more and more like it's going to be cloud based and I am happy with that. The less time I have to spend working to achieve the same goals means more time and money can be spent doing something fun.

Comments

Gravatar
Jerel Unruh

2012-01-03

I must say that I've really enjoyed working with Pagoda Box. Especially the quick app deploys, database snapshots and deployment rollbacks. Even if you aren't a Git user now it's quite trivial to learn the basics of Git just for your deployments. And once you learn it you'll be glad you did. :)

Gravatar
Jw Chan

2012-01-03

I think developers really need to be mindful when choosing to use cloud hosting. One cannot approach it expecting the same service that would typically be available via traditional web hosting methods. On the surface, it seems like a great idea but there are quite a few tradeoffs that could potentially make things more complicated for a developer. These include not having access to such basic services such as email or SSH access or customizing your PHP environment. There are definitely workarounds for these inconveniences but it's not as easy as signing up for cloud hosting and copying all your files over. Cloud hosting is definitely becoming better as time goes on and should be in any developer's toolbox. Thanks for the article!

Gravatar

2012-01-03

Jw Chan: Yes and no. While of course the limitation of what you can install on the servers is indeed something to think about some platforms are less restrictive than others. If you use Pagoda Box you can list PECL extensions to be bundled with it:

php_version: 5.3.8
php_extensions: [mysqli, curl, gd, mbstring]

That's pretty nifty control. You can use a pagoda gem to create a SSH tunnel to your MySQL and you can enable SSH access to certain folders, so realistically you have all the control you need. They have scalable Memcache and MySQL instances available with a click of a button and Mongo is on the way.

PaaS is not as restrictive as you might think.

Gravatar
John

2012-01-03

These services are coming along. My concern is about the DB though. They talk up the web scaling end pretty well but never mention the DB side of things. The DB is on a simple shared instance. There's no talk of how that scales from any of them. I worry of having 6-7 web instances bottle-necking at the DB.

Anyway, Pagodabox is slick. No dedicated DB offering yet though and no automated db backups. They also run on Soft Layer rather than Amazon so you can't leverage other Amazon services if you wanted without network latency. PHPFog runs on Amazon (East region) but doesn't allow multiple domains per app. That may be a problem for some. CloudControl looks pretty good but they are a German company and only run on Amazon (Europe zone - Ireland). Orchestra looked least appealing to me.

Gravatar
Scott

2012-01-03

John: Pagoda Box announced dedicate MySQL databases on December 28th http://bit.ly/uSLJR1.

When it comes to scaling cloud and dedicated databases on Pagoda Box, a replacement db is spun up and configured parallel to the currently running db, your data is then migrated to the new db and network connections are rerouted. Once that process of complete, the old db is decommissioned. Scaling is done on the fly without any downtime. The only caveat is that you can't scale from a cloud database to a dedicated database automatically. You have to provision a dedicated db and then manually migrate the data over. Scaling from cloud to dedicated is on their roadmap though.

Gravatar
Shawn Mccool

2012-01-04

I have an application that would be perfect for Pagoda Box. Unfortunately, it absolutely requires support for stored procedures.

Gravatar
John

2012-01-04

@scott, thanks for the update on the dedicated DB rollout. Ideally, i'd use pagodabox for the web app and amazon rds or xeround for the scalable db. Cuz, I also need automated nightly db backups and easy rollbacks. I can do this with phpfog but they don't do multiple domains per app which i also need. i'm testing out dotcloud right now. on paper they support all my requirements.

@shawn, check with pagoda support. I think by default the db permissions don't allow SPs but if you ask they might be able to change that for you. I think i had put this same question to them a while back.

Gravatar
Matt Scoble

2012-01-15

Phil:

Thanks for your post, very interesting. Many of the issues you speak to (in terms of complexity of deploying, need for sysadmin skills, etc.), are precisely why our managed application hosting model at Blue Box is seeing a great deal of success and significant growth. We know that our model isn't for everyone but those customers working with us speak to how passionate they are about our success in supporting them. Would love to connect some time, if you are interested, to share more about what we do and how.

Cheers!

Matt Scoble
Blue Box

Gravatar
Chris Blackwell

2012-02-24

Thanks for the post Phil.

I did have a followup question regarding your workflow and these apps. With something like CodeIgniter, how would you go about working with it as a dev setup, then when pushing it live, having it automatically switch to production settings?

Gravatar

2012-02-24

CodeIgniter has a constant in index.php which can be changed using Environment Vars in Pagoda Box's interface. Try this:

define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'environment');

Gravatar
David

2012-05-26

I'm starting to think pagodabox has a one-man team.

Gravatar
Pc

2012-05-27

Pagodabix seems to have the best dashboard around , offering the most control , Thier tunnel feature
Lets you do a lot more , the actual deploy process has a few more steps compared to orchestra

Orchestra is actually just 2 clicks and a 5 field form to get your app up .. It's amazing to the point that I feel something's not right ! Till I see my login page in 7 seconds

But orchestra free tier gives you NOTHING ... Compared to a fully loaded free teir from pagoda , including multiple domains per app
plus pagoda gives u a repo per app , which can take care of your repo hosting

Though call , these 2 are my finalist !

Gravatar
Frank Lämmer

2012-07-10

About halfway through the year: The PHP PaaS scene is definitely on the rise. We (•fortrabbit) are building yet another PHP Platform ourselves. So we know about the others and have even written a little comparison – 11 PHP PaaS providers:

http://blog.fortrabbit.com/comparing-cloud-hosting-platforms/

Gravatar
Ali

2012-12-01

Excellent conversation.
but I m a bit shaky about the performance of these cloud based solutions, as what if some one had a big SaaS based PHP application and there are thousands of customers attending application each day.
is this an excellent choice to put application on these PaaS or get a host on separate servers??.

Posting comments after three months has been disabled.