Heroku: Ruby Cloud Platform as a Service

Heroku is a cloud platform for several Ruby web frameworks that eliminates the burden of system administration for developers. Imagine a black box that accepts your application source code and deploys it to an array of highly-optimized servers. Resource allocation, load balancing, and syncing files between servers are no longer concerns. Increase application resources with a slider and watch it take effect within seconds. Database, reverse proxy cache, full-text search, e-mail, and background/scheduled job functionality are all included.

Background

I came into the world of research development with knowledge in several programming languages. At the time, I felt most comfortable developing for the web in PHP. I made the mistake of developing atop a small self-designed PHP framework, which got the job done, but was becoming noticeably harder to maintain as demand grew. I knew I’d have to improve on framework flexibility and maintainability in order to continue performing at a high-level.

After passing on PHP and a handful of its well-established web frameworks, I evaluated Python’s Django and Ruby on Rails. Although Python and Ruby have similar syntax, Ruby came with several significant advantages:

  • RubyGems – System for publishing and managing third-party libraries
  • Rails (Migrations, ActiveRecord) – Web framework for Ruby that adheres to the MVC design pattern
  • Community – The embrace of cutting-edge advances enables me to integrate the newest innovations with reduced overhead

After reading a book on Ruby, and another on Rails, I felt comfortable enough to use them for my next project. I haven’t looked back since. In fact, most of my non-web applications are now developed in Ruby as well.

Heroku

As described above, Heroku is a cloud platform for Ruby web frameworks. Despite advances in local Rails application deployment, Heroku comes with several advantages that are difficult to ignore.

Fully Managed

Heroku consists of a large server pool transparently managed by Ruby professionals. The platform’s foundation is Amazon’s virtual computing environment, EC2. Components on top of EC2 are well-known pieces of open source software (Linux, PostgreSQL, Varnish, Nginx, Memcached). Everything is kept glued together by middleware developed internally at Heroku using a highly-concurrent programming language, Erlang. Additionally, the environment is actively curated, ensuring that users consistently have the latest stable software.

Heroku Platform

Deployment

Heroku uses Git as the primary method of application deployment. Without going too far into details, Git is a distributed version control system. It’s distributed because Git allows for multiple remote code repositories. Deploying to Heroku is as simple as creating an application, adding a new remote repository, and executing the following command:

git push heroku master

In this case heroku is an alias for the remote destination and master refers to the primary branch of that repository.

HTTP Cache

Heroku places an HTTP accelerator, Varnish, in front of all of the applications it hosts. Varnish caches application output according to standard HTTP caching headers. Modern browsers interpret these headers as well, so strategically placing them throughout your application increases the percentage of cache hits through Varnish, and again at the user’s browser.

Background Jobs

If you ever run into a situation where a slower running process needs to be fired off from a web application, Heroku provides a clean interface to execute them asynchronously. Using the Rails standard Delayed Job, tasks can be delegated to a pool of workers that pull from a database queue. Just like application worker threads, background job workers can be increased using a slider that takes effect within seconds.

Database

Heroku provides several database options. Applications are automatically provided a full-featured PostgreSQL database. The level of your service plan determines if the database is dedicated or shared. As an alternative, you can take advantage of the fact that Heroku is built on Amazon’s cloud and configure Amazon Relational Database Service.

Amazon RDS is a web service that makes it easy to set up, operate, and scale a relational database in the cloud. Basically, it’s an instance of MySQL with automated backups, point-in-time recovery, and seamless vertical scaling between instance types. Amazon takes care of all configuration and software updates.

Constraints

Heroku is not a magic pill. As with any technology, it has advantages and disadvantages. Because Heroku was designed for the cloud, it is subject to constraints that are foreign to most traditional hosting environments.

Read-only Filesystem

Not much else that can be said about this. You cannot depend on the file-system to persist data or state at any time. If you want to handle file uploads, Amazon S3 is the suggested alternative. Luckily, most Rails file upload plugins abstract the destination enough that a switch between the local file-system and S3 is a configuration option away.

Large Static Assets

Heroku was not designed to serve larger files like high resolution images, PDFs, video, and audio. It is suggested that you offload the work to a service like Amazon S3 or Rackspace Cloud Files. In fact, requests are automatically terminated after 30 seconds.

Conclusion

For research applications, I think Heroku is a very attractive solution. They have automated many pain points in system administration and positioned them behind a clean RESTful web API. Heroku is well on its way to reducing my system administration tasks to near zero — I could get used to this.

My name is Hector Castro and I am a developer located in Philadelphia, PA. You can see what I'm working on at GitHub. I have a profile on Stack Overflow Careers, and if you're old-fashioned, a resume.

You can get in contact with me via Twitter or E-mail.