Migrating from VPS or Cloud servers to OpenShift PaaS

Hackability means never having to say "it can't be done".

Amazon currently dominates the cloud computing industry it created by allowing for easily scalable and granularly billed computing time. Microsoft's Azure platform and Google's Cloud Engine (not their App Engine) are welcome competition. But then there is RedHat, a server giant which has been merely lurking, and is now trying to attract people to their own platform (or platform offerings), like the PaaS they host called OpenShift Online.

OpenShift itself is free software (which is at openshift.org). What we're talking about is the OpenShift Online hosted platform which RedHat runs at openshift.com. They offer free "gears" on their PaaS (think of "dynos" on Heroku) so I am checking it out now. This blog is currently hosted on OpenShift for free.

1. OpenShift is not a VPS. It's not your own virtual machine. You get a shell but you don't get root access. It's like a small Docker container, although it might not be Docker. If you're used to the control and flexibility of having your own VPS then you will struggle against the constraints in OpenShift. "sudo make me a sandwich" gets you nowhere here.

2. You get 3 free gears, which can each host a single "app". For example, one website with one domain would be an app, but it could include a MySQL database and even some web admin software. The key is you don't get to host lots of sites on one gear, and you don't manage the configuration of the web server.

3. Instead of installing packages or compiling and installing RedHat software yourself, the platform offers "cartridges" (think Nintendo game cartridges) which are built according to the OpenShift API and can be used to add services to your gear. Unfortunately, many of these cartridges were built over a year ago and are now out of date. There are limited official cartridges available from RedHat covering the basic languages, but only PHP 5.4 and 5.3 are available when I would expect PHP 5.6 to be default. Some existing cartridges seem to not be compatible with each other (e.g. PHPMyAdmin and MySQL). On GitHub you'll find contributed cartridges but the quality (and testing) of these is rather hit-and-miss. There's not much in the way of help or a feedback system either.

On the plus side, you can easily install cartridges by finding the proper url for it (they go through "reflectors"). It'll either work or not. If the cartridge fails, your site will be broken as the gear tries to boot back up and fails. Fortunately, RedHat provides a CLI command called "rhc" to bring up and reconfigure new apps and add and remove cartridges. You'll need this tool as you can't remove cartridges from the web UI.

The first few hours of playing with RedHat OpenShift (Online) you will conclude that it's a broken piece of shit.


The ecosystem of OpenShift cartridges is simply not sufficient to cover any slightly non-mainstream configurations. And developing cartridges on your own will require non-trivial investment in learning the OpenShift api. RedHat recently acquired Ansible, the popular server orchestration tool. Ansible Galaxy is a much larger ecosystem of packaged up services (not to mention the available Docker container images out there) which can be used to setup servers, and writing your own roles (in YAML) does take some effort at first but is something non-programmers can do. But I don't see RedHat's acquisition of Ansible helping OpenShift Online at this moment, although I'm hopeful they can be integrated.

4. OpenShift itself is hosted on Amazon AWS. However, you don't have access to all the regions that AWS provides and for the free gears you're limited to East Coast USA, a long haul 300 ms ping from where I am.

5. OpenShift gears are meant for developers to develop a single app (most likely a web app or even a blog). And so they provide git access to your gear, and that should basically only include your web code, not any server configuration. The web code itself should be somewhat independent of what gear it's running on. Caveat: if your gear doesn't receive any web requests after a certain number of hours, the gear will be automatically suspended until it receives hits again. So there would be a minute or so where the gear is spinning up but still not handling http requests. You can get around this by having an external cron ping your server with http requests - like Drupal's cron runner.

BTW, cron itself (as in Vixie cron) is a cartridge that needs to be installed, but what you need is an external crontab.


In Summary, I was able to get around OpenShift's quirks and stand up a decent and free web host running Drupal. It's not the fastest machine, and I don't have the ability to see behind the curtains to know where the bottlenecks are, and sometimes I get 50X errors on the web server. So even though they are building on top of AWS's infrastructure, they still have some of their own problems managing scale and are most likely oversubscribed. After some initial glitches, I think my gear is stable enough to continue this experiment. At the same time, RedHat really need to step up their game if they want to be considered a viable cloud computing platform.

PROTIP: OpenShift gears don't let you ssh and idle for more than a few minutes (and even running tmux doesn't help as those will get killed after minutes of idle). But ssh like this and you'll be able to stay connected for hours:

ssh -t YOUR-APP-NAME-HERE.rhcloud.com 'cd app-root/repo; exec bash -l'