Cloud refers to hosted services over the Internet. For example, Google Drive and GoogleDocs are cloud services. Google Drive allows you to save your files on their hardware. GoogleDocs is a collection of software (word processor, spreadsheet, etc.) hosted on Google’s servers. The software resided on Google’s hardware and uses their memory and CPU. You access it through the Internet. The are three category of cloud services:

  • IaaS: Infrastructure as a Service
  • PaaS: Platform as a Service
  • SaaS: Software as a Service

IaaS providers provide highly automated and scalable computing resources accessible through an API and/or dashboard over the Internet. It allows users to build their own virtual data centre.

PaaS facilitate building highly scalable and applications. Examples include Heroku, Google App Engine, and OpenShift.

Hosting software on your servers require reliable hardware, network, and skilled technical staff. SaaS takes away the need for all this. The cloud will take care of all these technical problems and all you have to do is access the software through the Internet.

Elasticity

Before the cloud, companies built their infrastructure to be able to handle their peak requirements. This meant that significant portion of the hardware was left unused during off-peak hours. Cloud allows users to add more resources (scale out) during peak hours and reduce resources (scale in) during off-peak hours. This allows the business to use only the resources they need and only pay for the resources they consume. This is called elasticity.

Elasticity means the ability to increase or decrease resources and services as your needs change. Suppose you are using 5 CPUs and 24 Gig or RAM and your virtual servers cannot cope with the load, you would want to add more CPUs and memory. This can easily be done in the cloud with a few clicks in the dashboard in real time. When you add more CPU or RAM to your virtual machines, it is called scaling up. When you reduce CPU or RAM, it is called scaling down Collectively, this is called vertical scaling. When you add more nodes or components, it is called scaling out. When you reduce nodes, it is called scaling in. Collectively, this is called horizontal scaling.

Apps must be designed to take advantage of elasticity. If an application is designed to use only one CPU at a time, allocating 3 CPUs will not help speed up the execution of your jobs. In the cloud, you have access to infinite CPU and memory. Hardware limitation is no longer a bottleneck. The bottleneck is how much resources you can afford to buy and the ability of your apps to use elastic services.

Agility and Risk Management

IT infrastructure is expensive to setup and maintain. This presents financial risk. If you don’t build enough to handle all your customers, you won’t be able to serve your customers. If you build too much, then your infrastructure is sitting idle and draining your finances. In the cloud, you only build what you need and only pay for what you use. Furthermore, you can scale up, down, in or out quickly. You also delegate many tasks such as security tasks to the cloud.

In IT, agility refers to faster development, ease of experimentation, and fewer hurdles to innovation. Cloud allows users to access resources spin up and terminate instances quickly. Development can be automated and made consistent with templates. This reduces time to develop. You can experiment quick with low cost and low risk.

Key Advantages of Cloud

  1. Elasticity
  2. No need to build your own data center
  3. Resources are disposable – you can spin and terminate new instances anytime
  4. Scalability – you can build one CPU infrastructure to a million CPU infrastructure
  5. Highly available
  6. Strong physical data center security and data security
  7. Fault tolerant
  8. Reliability – able to recover from disruptions

Quick Introduction to Amazon Cloud

Amazon Cloud or AWS Cloud offers many services and tools which facilitate development of IT services. Following is a brief overview.

  • EC2 is a web service that provides resizeable compute capacity (servers resources)
  • Autoscaling refers to application scaling (increasing and decreasing resources allocated to applications) to optimize performance and costs
  • Amazon VPC (http://aws.amazon.com/vpc) : Allows you to provision virtual private clouds within AWS cloud
  • CloudWatch gathers statistics
  • RDS is Amazon’s relation database service

Storage:

  • EFS (http://aws.amazon.com/efs) : scaleable and elastic file system for Linux
  • EBS : offers persistent block storage
  • S3 : is a fully managed object storage service with a simple API

Configuring Application Infrastructure

  • Elastic Beanstalk deploys, manages, and scale web application services
  • OpsWorks is a configuration management service that provides instances of Chef and Puppet
  • CloudFormation provisions and manages stacks of AWS resources based on user-created templates to model their infrastructure architecture

Handling Traffic

To handle traffic, AWS offers the following services:

  • Route53 is DNS service
  • ELB handles and distributes traffic to different nodes

Cloud is different from traditional hosting environments. Different in the sense of what it offers and how the services should be constructed. Following articles explain the services in greater detail.

How to access AWS Cloud

There are 3 ways to use AWS:

  • AWS Management Console (GUI Interface)
  • Command Line Interface (CLI)
  • Software Development Kits (SDKs) – enables access using other tools

To access the console, go to http://aws.amazon.com/console. Login and you will see a list of resources and services you can setup and configure.

CLI interface allows you to access AWS through your terminal window. See AWS CLI to learn how to use it. Example command:

aws ec2 describe-instances

With AWS SDK, you can use tools of your choice or your own applications to access AWS. Currently SDKs are available in JavaScript, Python, PHP, .NET, Ruby, Go, Node.js, C++, and Java.

Autoscaling

Autoscaling ensures that you have the sufficient AWS EC2 instances available to handle the load and it also ensures that you don’t have more instances allocated than you require.

The load on a server fluctuates over time. Autoscaling allows you to allocate more EC2 resources when you need them and retire them when you no longer need them. You can either manually define peak and low-peak times or you can define rules based on CloudWatch alarm that automatically allocate and retire resources as needed.

When you add more CPU or RAM to your virtual machines, it is called scaling up. When you reduce CPU or RAM, it is called scaling down Collectively, this is called vertical scaling. When you add more nodes or components, it is called scaling out. When you reduce nodes, it is called scaling in. Collectively, this is called horizontal scaling.

To setup scaling, you need to answer what, where, and when:

  1. Define launch configuration (What?). What will be launched by autoscaling; AMI, instance types, security group, roles?
  2. Define autoscaling group (Where?). Where will you deploy; VPC, subnet, load balancer, minimum instances required, maximum instances allowed, desired capacity?
  3. Define autoscaling policy (When?). When to launch autoscaling. It could be scheduled or on-demand.

For dynamic autoscaling, you need to create CloudWatch alarm which will trigger autoscaling.

To setup autoscaling:

  1. Login to console
  2. Click on Create Autoscaling group under Autoscaling
  3. Choose AMI
  4. Create launch configuration
  5. Create autoscaling group
  6. Create autoscaling policy

Configuring Application Architecture

There are three category of services provided by AWS to assist with implementing elasticity, deployment, and configuration management of applications. Generally, the more convenience you ask for, the less control you will get. You need to decide which service best suits your needs and matches your skill set:

  1. AWS Elastic Beanstalk: Most convenient, least control
  2. AWS OpsWorks: Mid level convenience and control
  3. AWS CloudFormation: Least convenient but you have the most control

Elastic Beanstalk

Elastic Beanstalk offers easy-to-use pre-packaged services for scaling and deploying web applications and services using Java, .NET, PHP, Python, Ruby, Docker, Node.js on Apache, Nginx, and IIS. You upload your code, and Beanstalk takes care of the rest; deployment, provisioning, load balancing, auto-scaling, monitoring and other elastic issues.

A common workflow for using beanstalk is the following:

  1. Write code, save name, and version. Then upload to S3. You can import your code from GIT, AWS management console, or use AWS toolkits for Visual Studio or Eclipse.
  2. When code is in S3, beanstalk can deploy it. It handles all everything else.

Beanstalk is not a blackbox. You can see what it is doing and you can reconfigure it. For example, you can change EC2 instance types, database services, switch to https, adjust auto-scaling settings, etc. To change settings, update the .config files inside the .ebextensions folder. .config files are in JSON or YAML format.

Opsworks

OpsWorks offers a good balance between convenience and control. You should consider using it if your application is more complex than what can be supported by Beanstalk. Basically, if you need more granular control of your application setup and deployment, then you need OpsWorks.

Infrastructure is conceptually divided into stacks and layers. A stack is a group of servers that server a purpose together. For example, you application needs an application server, database server, and a caching server. Together, these servers constitute a stack. Applications often have development stacks, staging stacks, and production stacks. Layers conceptually describes the servers by their function. For example, there is a database layer, application layer, etc. In OpsWorks Stacks, all servers can be configured using Chef recipes. Following is an example workflow or OpsWorks usage:

  1. create stack
  2. create layer
  3. define applications
  4. write chef recipes
  5. launch instance
  6. deploy application

OpsWorks will help you with architecture complexities such as configuration management, deployment management, and other elastic issues.

CloudFormation

CloudFormation provides easy way to create and manage a collection of AWS resources. It allows you to define and entire application stack. You do this by writing descriptive text files in JSON format. These files can then be used to rebuild identical stacks. Needless to say, CloudFormation is very powerful but you need the technical skills to take full advantage of it and continue maintaining and upgrading it. If you decide to go this route, I would highly recommend that you study CloudFormer first. It will save you a lot of time and effort.