Heroku

Heroku

Tudip

08 June 2018

What is Heroku?

Heroku is a cloud platform as a service (PaaS) that is used for the deployment of the web application and RESTful API application. It supports deployment for multiple programming languages. It is a free platform as a server (PaaS) which is a good option for deploying and managing the small applications.

Its architectural components:

Dyno:

All its application runs on the dyno. What is dyno? Dynos are the collection of Linux container which is a core part of its cloud. There are different types of dynos.

Stacks:

Stacks are nothing but the operating system which maintained by it. Currently, it provides three stacks: Cedar-14 (Ubuntu 14.04), Heroku-16(Ubuntu 16.04) and Heroku-18(Ubuntu 18.04).

Why to use it?

Saves a ton of time because you don’t have to manage servers and infrastructures. All you need to do is push your app in a git repository and it’ll run it for you. You don’t have to set up and manage servers, OS, networking, firewalls, etc. You can scale your app up and down by just moving the knob or a slider.

How to use?

Getting started: Follow the steps below to create your app. Or follow the URL by choosing the programming language/frameworks that you are using. (https://devcenter.heroku.com/articles)

cmd> heroku login

  • In your project directory, create your app.

cmd> heroku create YOUR_APP_NAME

(Note- App name is optional. If you didn’t provide the application name it will create one for you). This command will add its git repository URL.

  • If you already have its app and need to create a new application in the existing one. This will add new git URL for the application.

cmd> heroku git:remote -a YOUR_APP_NAME

  • To ensure that remote named it has been set for your application.

cmd> git remote -v

Deployment:

It’s pretty easy to deploy on it as it uses GIT (version control system) for application deployments.

cmd> git add

cmd> git commit -m “Initial commit”

cmd> git push origin master (If you have a git repository.)

cmd> git push heroku master

It automatically detects and installs newly added dependencies for you. To migrate and seed the tables of your application you need run command explicitly. Remember, migration and seeding commands depends upon the frameworks that you have been using for the building your application. For example in rails application:

cmd> heroku run rake db:migrate

cmd> heroku run rake db:seed

Debugging:

It provides logs that are a real-time stream of application events.

cmd> heroku logs –tail

Also, you can visit the URL to know more about debugging in it. (https://devcenter.heroku.com/articles/logging) Additional things in it:

  • Procfile: Suppose we have some kind of commands and need to be executed on the server so its application has a specific file called Procfile. Then these commands should be defined in the procfile. To know more about the naming convention and how exactly these commands are defined in the file visit this URL (https://devcenter.heroku.com/articles/procfile).

Few things need to keep in mind when using it:

  • It has a strict 30 seconds request timeout which is not configurable. Any request which takes more than 30 seconds receives application error. So if you are having any bulky request such as uploading file/image or sending emails it’s better to switch to background jobs/worker. Although there are different types of application error in it you can know from the following URL https://devcenter.heroku.com/articles/error-pages.
  • Its file system is read-only so cannot create files on it. Well, there are multiple ways to do this

1. You can use AWS s3 service to store the file and access it from the cloud.

2. You can store the file in the database.

3. You can also use some document store, such as CouchDB or MongoDB

  • Its free account has a limit of 10,000 rows in the database. This plan can be upgraded according to the size and requirement of applications.
  • Its free account can create up to 5 applications and 2 databases backups per database.
  • As we all know that it runs on dynos. A free dyno has 550 running hours in a month. You may get additional 450 hours after verifying your credit card. (https://devcenter.heroku.com/articles/free-dyno-hours)

search

Blog Categories

Request a quote