Simplifying Deployment on the Cloud with Heroku

0
5068

Cloud-Computing

Many developers assume cloud deployment to be tedious, costly, insecure and even sometimes unreliable. However, with the advent of platforms like Heroku, deployment on the cloud is being widely adopted and it is empowering a large number of developers. Let us dive into Heroku and its offerings.

Heroku is a PaaS (Platform as a Service) cloud infrastructure service. Wikipedia defines the Platform as a Service (PaaS) model as a “…category of service models that provide a computing platform (http://en.wikipedia.org/wiki/Computing_platform) and a solution stack (http://en.wikipedia.org/wiki/Solution_stack) as a service.” Simply put, a PaaS offering facilitates application deployment without the need to administer the underlying software and hardware stack. Developers can focus their energies on building applications, which matters most.

There are tons of cloud players competing for developer attention, yet Heroku stands out from the herd. Instead of users purchasing virtualised server instances and managing software installations on them, the Heroku approach is different and innovative—code is pushed into a Git (a distributed version control system) repository, which is then instantly deployed.

With Heroku, hackers get the flexibility of writing applications in the language of their choice, while using the most appropriate database back-end, and flexibly adding the software and hardware infrastructure resources they require. Heroku also subtly pushes developers to follow recommended software development practices such as using version control, isolating dependencies, storing application configurations in environment variables and scaling via concurrency (parallel utilisation of multiple hardware instances). Personally, as a developer, Heroku is my first choice for work or hobby projects; here are some of the reasons why.

Ease and simplicity: For a stable, robust and scalable deployment, Heroku requires just a basic acquaintance with the platform’s terminologies, and a combination of core development and command-line skills.
Trust: Heroku is built on Amazon Web Services, which is known for its excellent uptime and scalability. Also, Heroku’s parent company, Salesforce.com, is a trusted enterprise across the world.
Community support and documentation: With an excellent community backing the platform, and rich detailed documentation for beginners, lots of developers are introduced to Heroku early in their career, and stay loyal to the platform.
Its polyglot nature: Heroku supports a wide number of programming languages—the popular ones are Ruby, Python, Java, PHP and JavaScript. The comfort of sharing a single deployment platform for a variety of languages is much appreciated by many developers.
Free basic usage: Every user-deployed application in the Heroku ecosystem has access to a free plan. We will discuss the pricing model soon.

A brief history lesson
Heroku had a humble beginning, graduating from the famous American start-up accelerator, Y Combinator’s batch of 2008. Back then, the Ruby on Rails Web framework had started to gain traction, but lacked an easy-to-deploy platform. Heroku established itself as a popular choice among the Rails developer niche. Salesforce.com later acquired Heroku in December 2010. Slowly, support for a large number of languages and databases was added. Major tie-ups with Facebook to promote using Heroku for deploying applications and games further strengthened the platform. Heroku also enjoyed the limelight for employing respected developers such as Yukihiro Matsumoto, the creator of the Ruby programming language.

Dynos, stacks and add-ons
A dyno is a single instance of an application running on Heroku. Under the hood, a dyno is an Ubuntu server with a Quad Core Processor and 512 MB of RAM. Each dyno has an isolated chroot jail environment (implying restriction to a single directory, with no system files access). A dyno can run any type of service such as Web (serving HTTP requests), worker (asynchronous jobs) and scheduler (for scheduling capabilities like cron).

The flexibility of Heroku lies in scaling the number of dynos active at a certain point in time. All incoming HTTP requests are passed through a load balancer that routes them to multiple dynos, allowing an application to serve more users concurrently. Heroku’s architecture is sure to fascinate any scalability geek. Visit http://www.heroku.com/how to delve deeper into the architecture.
The OS, along with language runtime and libraries, makes up a ‘Heroku stack’ that provides a software environment for the applications. Heroku currently uses an Ubuntu 10.04-based ‘Cedar’ stack, and an older Debian Lenny 5-based ‘Badious Bamboo’ stack. However, you cannot use the ‘Badious Bamboo’ for a new application. You can read more about the Heroku stacks at https://devcenter.heroku.com/articles/stack.

Heroku add-ons are great infrastructure services that simplify deployment. To name a few benefits, add-ons provide data stores, caching servers, searching infrastructure, media management and payment gateways. Like dynos, add-ons can be dynamically attached or removed. For the complete add-on list, visit: https://addons.heroku.com/.

Pricing
The Heroku pricing model takes a while to get used to. The cost is calculated on ‘wall-clock’ usage rather than CPU time, implying usage regardless of the traffic an application receives. Each application receives 750 free dyno-hours per month. Beyond that, a charge of $ 0.05 per hour is incurred per dyno.

To use an add-on, you need to verify your account first with credit card information. Every add-on has a different pricing model, and many come bundled with a limited free plan as well. To get a more concrete understanding of pricing, visit: https://devcenter.heroku.com/articles/usage-and-billing.

The Heroku workflow
Let us walk through the process of creating a Heroku account and deploying a project. Before you can proceed any further, you need to create an account at: https://api.heroku.com/signup. After signing up, install the Heroku toolbelt command-line utility available for all major platforms—visit https://toolbelt.heroku.com/ and follow those instructions. Next, log in with the heroku command-line utility. You will be asked to enter the email address and password for the account:

mythlabs:testapp myth$ heroku login
Enter your Heroku credentials.
Email: nitishupreti@gmail.com
Password (typing will be hidden):
Authentication successful.

The next step is to create an application on Heroku, as follows:

mythlabs:testapp myth$ heroku create
Creating infinite-reef-6034... done, stack is cedar
http://infinite-reef-6034.herokuapp.com/ | git@heroku.com:infinite-reef-6034.git

If you do not specify a name for the application (as in the example above), Heroku comes up with a name for you. You may, however, want to specify a name when executing the create command. Finally, in the directory where the project’s Git repository resides, issue git push heroku master to deploy your application. This is all you need to deploy your application on Heroku. As advertised earlier, Heroku does truly simplify deployment.

Final thoughts
Heroku is an amazing platform for hackers to quickly deploy scalable Web applications. I hope you have been intrigued by it. It is now time to build something cool and have some fun! Happy hacking!

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here