Slide 1 - Electronics and Computer Science

cabbagepatchtapeInternet and Web Development

Feb 5, 2013 (4 years and 7 months ago)

137 views

Introduction to Cloud
Computing, IaaS, PaaS
and SaaS

Steve Crouch

s.crouch@software.ac.uk

Contents


Problem


What is Cloud Computing?


IaaS, PaaS, SaaS with examples


Cloud standards


The Problem


Basically, want to run compute/data
intensive task


Don’t have enough resources to run job
locally


At least, to return results within sensible
timeframe


Would like to use another, more capable
resource

Distributed Computing in Olden
Times


Small number of ‘fast’ computers


Very expensive


Centralised


Used nearly all the time


Time allocations for users


Not updated often

brewbooks

Cray X
-
MP

(Cray
-
1 successor)

Univac 1710

Michael L.
Umbricht

and Carl R.
Friend


Punched cards


Wait time huge


MailNet, SneakerNet,
TyperNet, etc…


Mainframes


Cray
-
1 1976
-

$8.8 million, 160
megaflops, 8MB memory

‘Cloud’ & ‘Grid’


Utility
Computing?

The Grid…

The Cloud…

Is it really like the grid?

Is it more like a fog?

But… they’re both about providing access to
compute and data resources

j.o.h.n

walker

charles.frith

It’s About Scaling Up…


Compute
and

data


you need more, you
go somewhere else to get it

Local

Institutional



National

International


Then… the march towards localisation of computation,
the Personal Computer


Computational Science develops in laboratories


Is this changing again?



Images: nasaimages, Extra Ketchup, Google Maps, Dave Page


What is Cloud Computing?


Many ways to define it i.e. one for every
supplier of ‘cloud’


Key characteristics:


On demand, dynamic allocation of resources


‘elasticity’


Abstraction


Self
-
service based provisioning


Self
-
managed


Billed for
what you use

e.g. in terms of CPU,
storage


Standardised interfaces e.g. OCCI


… it’s more like an electricity grid than the
Grid

How Does it Deliver?

1
-

IaaS

-

Infrastructure as a Service

Hardware

OS

2
-

PaaS

-

Platform as a Service

Framework

Middleware

3
-

SaaS

-

Software as a Service

Hosted Applications

Infrastructure


Cloud computing can deliver at any of these levels


These levels are often blurred and routinely disputed!


Resources provided on demand

Internet

End user/

Customer

Developer/
Service Provider

IaaS


Infrastructure as a Service


You get access to (usually) virtualised
hardware


Servers, storage, networking


Operating system


Responsible for managing OS, middleware,
runtime, data, application (development)


e.g. Amazon EC2

Amazon EC2


The Idea


‘Elastic Computing’


Sign up


Select & configure virtualised resources


Emulated OS: RHEL, OEL, Windows Server, OpenSolaris, Fedora,
Ubuntu, Debian, SUSE, Gentoo, Amazon Linux AMI


Infrastructure:


Data: IBM DB2, IBM Informix, Microsoft SQL, MySQL, Oracle


Web Hosting: Apache HTTP, IIS/Asp.NET, IBM WebSphere


Batch Processing: Hadoop, Condor, Open MPI


Newer addition
-

development environments:


IBM sMash, Ruby on Rails, Jboss Enterprise Application Platform


Moving towards PaaS! (Already there?)


Additional web services


S3: Simple Storage Solution


transfer data in/out, 1 byte to 5
TB


SQS: Simple Queue Service

Amazon EC2: The Idea


Directly: Launch instance
-
>
Connect to instance
-
>
Terminate instance


Manually


Programmatically


… multiply by
n


e.g. in your web application


Indirectly via SQS:


Post request messages into
queue from client


EC2 instances handled
automagically per request


Status messages posted
back to client through
queue

Amazon EC2: Pricing


Free (at the start!):


Run single Amazon Micro Instance for a year


750 hours of EC2, 750 hours of Elastic Load Balancing plus 15
GB data processing


15 GB bandwidth in/out across all services


On demand instances:


Pay per hour, no long
-
term commitment


From $0.025/hour
-
> $0.76/hour


Reserved instances:


Upfront payment, with discount per hour


From $227/year + $0.01/hour
-
> $1820/year + $0.32/hour


Spot instances:


Bid for unused EC2 capacity:


Spot Price fluctuates with supply/demand, if bid over Spot
Price, you get it


From $0.007/hour
-
> $0.68/hour



EC2 in Use: Dctp.tv Video Workflow

Webapp


Editor adds incoming storage folder


Selects
transcoding

actions (profiles) for videos


Editor uploads video

Amazon


‘Encoding cloud’ detects new video, creates SQS job per action


Cloud workers ‘pull’ jobs from queue
-
> process
-
> result stored on S3


Message posted to SQS

Webapp


Editor adds missing metadata


Eventually, video is exposed to users

User


User navigates through new content and requests video

Amazon


Streaming cloud caches video upon request and delivers it to user


1 dedicated
EC2 instance
monitors
incoming
queue


Monitors
number of
queue
messages


Dynamically
adjusts
number of
transcoding
EC2 instances


EC2 In Practice: HTTP Query


Query


HTTP(S) GET or POST

https://ec2.amazonaws.com/?Action=RunInstances

&ImageId=ami
-
60a54009

&MaxCount=3

&MinCount=1

&Placement.AvailabilityZone=us
-
east
-
1b

&Monitoring.Enabled=true

&AWSAccessKeyId=0GS7553JW74RRM612K02EXAMPLE

&Version=2010
-
11
-
15

&Expires=2010
-
10
-
10T12:00:00Z

&Signature=lBP67vCvGlDMBQ1dofZxg8E8SUEXAMPLE

&SignatureVersion=2

&SignatureMethod=HmacSHA256

EC2 In Practice: SOAP


Just use a SOAP library e.g. in C++, Java, C#, Perl, Python, Ruby against
exposed WSDL methods e.g.
RunInstances


Basic payload:










Over HTTPS, have a preceding, secure SOAP header


BinarySecurityToken
, Signature, Timestamp

<RunInstances xmlns="http://ec2.amazonaws.com/doc/2010
-
11
-
15/">


<instancesSet>




<item>




<imageId>ami
-
60a54009</imageId>




<minCount>1</minCount>




<maxCount>3</maxCount>




</item>


</instancesSet>


<groupSet/>

</RunInstances>

EC2 In Practice: Responses


Example response:

<DescribeKeyPairsResponse xmlns="http://ec2.amazonaws.com/doc/2010
-
11
-
15/">


<requestId>7a62c49f
-
347e
-
4fc4
-
9331
-
6e8eEXAMPLE</requestId>


<keySet>



<item>




<keyName>gsg
-
keypair</keyName>




<keyFingerprint>




1f:51:ae:28:bf:89:e9:d8:1f:25:5d:37:2d:7d:b8:ca:9f:f5:f1:6f




</keyFingerprint>



</item>


</keySet>

</DescribeKeyPairsResponse>

PaaS


Platform as a Service


You get integrated development environment


e.g. application design, testing, deployment, hosting,
frameworks for database integration, storage, app
versioning, etc.


Develop applications on top


Provided either:


On top of IaaS, e.g. Amazon EC2


As OS abstraction, e.g. MS Azure, Google App Engine


MS Azure evolving into IaaS + PaaS


Responsible for managing data, application
(development)


e.g. Google App Engine




Google App Engine: The Idea


Sign up via Google Accounts


Develop App Engine web applications locally using SDK


emulates all services


Includes tool to upload application code, static files and config
files


Can ‘version’ your web application instances


Apps run in a Java/Python ‘sandbox’


Autoscaling schemaless datastore


App Engine Services (via APIs):


URL Fetch e.g. for web services


Mail


Memcache


Image Manipulation


Automatic scaling and load balancing


abstract across
underlying resources


Google App Engine: The Idea


App Engine framework built on:


Jetty, Java Servlet 2.4, Java Data Objects (JDO) &
Java Persistence API (JPA) + Google Bigtable


Google Eclipse plugin (App Engine & GWT)


Basic Example (bottom up):

1.
Create model (e.g. a Java Class) for data

2.
Set up JPA & DAO

3.
Create servlets

4.
Create JSP, css, web.xml


Next: a truncated example to give you an
idea…



Google App Engine: Create Model in
Java Class

package de.vogella.gae.java.todo.model; import javax.persistence.Entity;

import javax.persistence.GeneratedValue;

import javax.persistence.GenerationType; import javax.persistence.Id;


@Entity

public class Todo {


@Id


@GeneratedValue(strategy = GenerationType.IDENTITY)


private Long id;


private String author;


private String summary;


private String description;


private String url;


boolean finished;



public Todo(String author, String summary, String description, String url)
{



this.author = author;



this.summary = summary;



Google App Engine: JPA
configuration
-

persistence.xml


<?xml version="1.0" encoding="UTF
-
8" ?>


<persistence
xmlns
="http://java.sun.com/xml/ns/persistence"



xmlns:xsi
="http://www.w3.org/2001/XMLSchema
-
instance"



xsi:schemaLocation
="http://java.sun.com/xml/ns/persistence



http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"



version="1.0">


<persistence
-
unit name="transactions
-
optional">



<provider>




org.datanucleus.store.appengine.jpa.DatastorePersistenceProvider



</provider>



<properties>




<property name="
datanucleus.NontransactionalRead
"
value="true"/>




<property name="
datanucleus.NontransactionalWrite
"
value="true"/>




<property name="
datanucleus.ConnectionURL
"
value="
appengine
"/>



</properties>


</persistence
-
unit>

</persistence>

Google App Engine: Methods on
DAO


package de.vogella.gae.java.todo.dao;

import java.util.List;

import javax.persistence.EntityManager;

import javax.persistence.Query;

import de.vogella.gae.java.todo.model.Todo;


public enum Dao {


INSTANCE;



public List<Todo> listTodos() { EntityManager em =



EMFService.get().createEntityManager();



// Read the existing entries



Query q = em.createQuery("select m from Todo m");



List<Todo> todos = q.getResultList();



return todos;


}



public void add(String userId, String summery, String description, String url) {



Google App Engine: Create Servlets


package de.vogella.gae.java.todo;

import java.io.IOException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import com.google.appengine.api.users.User;

import com.google.appengine.api.users.UserService;

import com.google.appengine.api.users.UserServiceFactory;

import de.vogella.gae.java.todo.dao.Dao;

@SuppressWarnings("serial") public class ServletCreateTodo extends HttpServlet {



public void doPost(HttpServletRequest req, HttpServletResponse resp) throws



IOException {



System.out.println("Creating new todo ");



User user = (User) req.getAttribute("user");



if (user == null) {




UserService userService =
UserServiceFactory.getUserService();




user = userService.getCurrentUser(); }




String summary =
checkNull(req.getParameter("summary"));



Google App Engine: Create JSP


<%@ page contentType="text/html;charset=UTF
-
8" language="java" %>

<%@ page import="java.util.List" %>

<%@ page import="com.google.appengine.api.users.User" %>

<%@ page import="com.google.appengine.api.users.UserService" %>

<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<%@ page import="de.vogella.gae.java.todo.model.Todo" %>

<%@ page import="de.vogella.gae.java.todo.dao.Dao" %>


<!DOCTYPE html>


<%@page import="java.util.ArrayList"%>

<html>


<head>



<title>Todos</title>



<link rel="stylesheet" type="text/css" href="css/main.css"/>



<meta charset="utf
-
8">


</head>

<body>

<% Dao dao = Dao.INSTANCE; UserService userService =

UserServiceFactory.getUserService(); …

Google App Engine: Create web.xml


<?xml version="1.0" encoding="utf
-
8"?>

<web
-
app xmlns:xsi="http://www.w3.org/2001/XMLSchema
-
instance"


xmlns="http://java.sun.com/xml/ns/javaee"


xmlns:web="http://java.sun.com/xml/ns/javaee/web
-
app_2_5.xsd"


xsi:schemaLocation="http://java.sun.com/xml/ns/javaee


http://java.sun.com/xml/ns/javaee/web
-
app_2_5.xsd" version="2.5">


<servlet>



<servlet
-
name>CreateNewTodo</servlet
-
name>



<servlet
-
class>de.vogella.gae.java.todo.ServletCreateTodo</servlet
-
class>


</servlet>


<servlet>



<servlet
-
name>RemoveTodo</servlet
-
name>



<servlet
-
class>de.vogella.gae.java.todo.ServletRemoveTodo</servlet
-
class>


</servlet>


<servlet
-
mapping>



<servlet
-
name>RemoveTodo</servlet
-
name>



<url
-
pattern>/done</url
-
pattern>


</servlet
-
mapping>



Google App Engine: Test Locally


Google App Engine: Maintain App
ID in appengine
-
web.xml


<?xml version="1.0" encoding="utf
-
8"?>

<
appengine
-
web
-
app
xmlns
="http://appengine.google.com/ns/1.0">


<application>
vogellatodo
</application>


<version>1</version>


<!
--

Configure
java.util.logging

--
>


<system
-
properties>



<property name="
java.util.logging.config.file
"
value="WEB
-
INF/
logging.properties
"/>


</system
-
properties>

</
appengine
-
web
-
app>

Deploy App


Done!

Google App Engine: Pricing


Free within a quota:


500MB storage, 5 million page views a month (~6.5 CPU hours,
1GB)


10 applications/developer


Billed model:


Each app $8/developer (max $1000) a month


For each app:


Resource

Unit

Unit cost

Outgoing bandwidth

GB

$0.12

Incoming bandwidth

GB

$0.10

CPU Time

CPU hours

$0.10

Stored Data

GB/month

$0.15

High Replication Stg.

GB/month

$0.45

Recipients Emailed

Recipients

$0.0001

Always On

N/A (daily)

$0.30

SaaS


Software as a Service


Top layer consumed directly by end user


the ‘business’
functionality


Application software provided, you configure it (more or
less)


Various levels of maturity:


Level 1:

each customer has own customised version of
application in own instance


Level 2:

all instances use same application code, but
configured individually


Level 3:

single instance of application across all customers


Level 4:

multiple customers served on load
-
balanced ‘farm’
of identical instances


Levels 3 & 4: separate customer data!


e.g. Gmail, Google Sites, Google Docs, Facebook

Summary of Provision

Application Migration


adopt the level you want

Cloud Open Standards


Implementations typically have proprietary
standards and interfaces


Vendors like this


often locked in to one
implementation


Community ‘push’ towards open cloud
standards:


Open Grid Forum (OGF)


Open Cloud Computing
Interface (OCCI)


Distributed Management Task Force (DMTF)


Open Virtualisation Format (OVF)


OCCI:


Supported (or will be) by: OpenNebula,
Eucalyptus, OpenStack, SLA@SOI