Chapter 9. Deploying Your Web Application to the Cloud

In this chapter, we'll take a tour of the different cloud providers, understand the challenges and benefits of a distributed architecture, and see how to deploy your web application to Pivotal Web Services and to Heroku.

Choosing your host

There are many forms of cloud hosting. For developers, the choice will be mainly between a Platform as a Service (PaaS) and an Infrastructure as a Service (IaaS).

Using the latest, you will often have a bare metal machine that you can manage and on which you can install all the services required by your application.

If we leave aside technologies such as Docker (which is absolutely amazing, you should absolutely give it a try), this is really similar to traditional hosting where your operation team will have to set up and maintain an environment in which the application can run.

On the other hand, PaaS makes it easy to deploy your application as you develop it with a simple push-to-deploy workflow.

The most well known providers are:

  • Cloud Foundry backed by Pivotal
  • OpenShift by Red Hat
  • Heroku acquired by Salesforce in 2010

Each of these three providers come with different pros and cons. I will try to give you an overview of these.

Cloud Foundry

Backed by Pivotal, the company behind Spring, Pivotal Web Service runs on Cloud Foundry, an open source PaaS maintained by a foundation, and comes with an interesting package.

They offer a 60 day free trial and their pricing is a function of the memory allocated for your instances and the number of instances you own.

Their prices range from $2.70 per month for the smallest (128 Mb) instance to $43.20 per month for the 2 GB instance.

If you want to give it a try, no credit card is required for the free trial. They have a market place to easily install services, such as Redis or Postgre SQL, with rather limited free options. They have a good command-line utility to manage your application from your console. You can either use buildpacks or push a JAR directly for deployment.

Tip

Build packs will try to guess the stack that you are using and build your application in the most standard way (mvn package for Maven, ./gradlew stage for Gradle, and so on).

Note

Refer to the tutorial available at the following URL to deploy your application to Cloud Foundry:

http://docs.cloudfoundry.org/buildpacks/java/gsg-spring.html

OpenShift

OpenShift is maintained by Red Hat and powered by OpenShift Origin, an open source facility running Docker containers on top of Google's Kubernetes.

It is priced well and offers a lot of freedom, as it is both a PaaS and an IaaS. Its pricing is based on gears, containers running an application, or a service such as Jenkins, or a database.

OpenShift has a free plan offering three small gears. Your application must be idle for 24 hours per month unless you enter your billing information.

Additional or bigger gears are billed at approximately $15 a month for the smallest, and $72 for the biggest.

To deploy a Spring Boot application on OpenShift, you will have to use the Do It Yourself cartridge. It is a bit more work than other buildpack-based PaaS but it is also easier to configure.

Take a look at the blog post for a Spring Boot tutorial with OpenShift, which is available at http://blog.codeleak.pl/2015/02/openshift-diy-build-spring-boot.html.

Heroku

Heroku is a well known PaaS with extensive documentation and a code-centric approach based on build packs. It can connect to a lot of services called add-ons, but using them requires your billing information.

It is really interesting for a free project and is very fast to get started with. The downside is that it directly costs more than $25 per month if you want to scale up. Free instances will go into the sleep mode after 30 minutes of inactivity, which means free Heroku apps will always take as much as 30 seconds to load.

Heroku has a great administration dashboard and command-line tools. For this chapter, I chose Heroku because it is very straightforward. The concepts you will grasp here are applicable to most PaaS.

You can follow most of the chapter and deploy your application without providing your credit card information as long as you do not use the Redis add-on. You won't be charged if you select the free plan.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.82.4