cloud computing 014 - uniroma1.it · cloud computing • cloud computing, like other technologies,...
TRANSCRIPT
Introduction to Cloud Computing
Roberto Beraldi
CC in a nutshell
• Cloud computing is a way to use Information
Technology infrastructures without the need to
install specific HW related to the infrastructures
being used.
• IT infrastructure can be as simple as a single raw
virtual machine, …
… more abstract as a sw platform used to develop
and running applications on several machines,
…or a sw application
Cloud computing in a nutshell
(by an analogy)
• Electricity is “virtual” entity – (many sources, we do not care from where we receive it,…)
• “Pay-as-you-go” – Elastic
Production Distribution Utilization
CC: Virtual computing power
CPU
cycles
Storage
Memory
Provider Utilization
Virtual machine
control panel
User decides the size on the VM…
Cloud computing
• Cloud computing, like other technologies, such as cluster, grid, aims at allowing access to large amounts of computing power in a fully virtualized manner, by aggregating resources and offering a single system view.
• Cloud computing has been coined as an umbrella term to describe a category of sophisticated on-demand computing services initially offered by commercial providers, such as Amazon, Google, and Microsoft.
What CC can provide?
• Infrastructure
• Platform
• Software
• API
• STorage
• Desktop
• X
as a service (IaaS)
as a service (PaaS)
as a service (SaaS)
as a service (APIaaS)
as a service (STaaS)
as a service (DaaS)
as a service (XaaS)
Main characteristics of CC
• Pay-per-use
– no ongoing commitment, utility prices;
• Elastic capacity and the illusion of infinite resources;
• Resources that are abstracted or virtualized.
• Resources provided as a Service and with a self-service Interface
– provides users the ability to upload, build, deploy, schedule, manage, and report on their business services on demand.
Factors enabling cloud computingHardware
HW virtualization
Multi-core chipsIn
tern
et
Tech
no
log
ies
Distrib
ute
d
Co
mp
utin
g
Web 2.0
Web Services
Mashups
SoA
Utility computing
Grid Computing
..
System Management
Autonomic Computing
Data Center Automation
Cloud
computing
Cloud actors
From mainframes to clouds
• Providers of CC can operate their
infrastructures at very high utilization rate
• Something similar to what happened with
Mainframes.
– They had to operate at very high utilization rates
simply because they were very expensive and
costs should be justified by efficient usage
Provisioning
Provisioning for peak load
Underprovisioning, case 1
Underprovisioning case 2
Types of Cloud Computing
(IaaS) Infrastructure as a Service
(SaaS)Software as a Service
XaaS (PaaS) Platform as a Service
INFRASTRUCTURE AS A SERVICE
IaaS
• A cloud infrastructure enables on-demand provisioning of servers running several choices of operating systems and a customized software stack.
• Cloud computing services are usually backed by large-scale data centers composed of thousands of computers.
• Such data centers are built to serve many users and host many disparate applications.
• Offers virtualized resources (computation, storage, and communication) on demand
Virtualization - isolation
• Through virtualization, workload isolation is achieved since all program instructions are fully confined inside a VM, which leads to improvements in security.
• Better reliability is also achieved because software failures inside one VM do not affect others.
• Moreover, better performance control is attained since execution of one VM should not affect the performance of another VM.
Virtualization - isolation
Virtualization – application mobility
• Workload migration, also referred to as application mobility, targets at facilitating hardware maintenance, load balancing, fault tolerance and disaster recovery.
• It is done by encapsulating a guest OS state within a VM and allowing it to be suspended, fully serialized, migrated to a different platform, and resumedimmediately or preserved to be restored at a later date.
• A VM’s state includes a full disk or partition image, configuration files, and an image of its RAM.
Virtualization – application mobility
Virtualization - consolidation
• Virtualization makes it possible to consolidate
individual workloads onto a single physical
platform, reducing the total cost of ownership.
Virtual machines
• Virtual machine is a logic machine implemented via
software (ML) running on a physical machine (MF)
• Two main types
• No native emulation ML≠MF
• Native emulation. ML=MF
Process virtual machine
• Runs a SW process
• Examples Java Virtual Machine
• Common Language Runtime (CLR)/.NET
Virtual machine and interoperabiity
• Java Virtual Machine (JVM)
– ISA: Macchina a stack (zero-register)
JVM
MF1 MF2 MFn
Java
• “write once run
everywhere”
System virtual machine
• Same machine as the physical machine
“Efficient, isolated duplicate of a real
machine”*)
• Virtualization is realized by a Virtual Machine
Monitor (VMM) o hypervisor
• Process : SO = Supervisor : Hypervisor
System virtual machine
• Full virtualization
– OS without modification (VMWare)
– OS legacy
• Paravirtualization
– OS must be modified
– Higher effciency
Resources
• Xen and the Art of Virtualization, Pratt et al. SOSP
2003.
• The Architecture of Virtual Machines, Smith, J.E.; R.
Nair, IEEE Computer, May 2005, Volume: 38 , Issue: 5
• A Comparison of Software and Hardware Techniques
for x86 Virtualization, K. Adams, O. Agesen. ASPLOS
2006.
Classical virtualization
• “A classical VMM executes guest operating system directly, but at a reduced privilegedlevel. The VMM intercepts traps from the de-privileged guest, and emulates the trapping instruction against a virtual machine state”[*]
[*]”A camparison of Software and Hardware Techniques for x86 Virtualization”, K.Adams, O.Agesen, ASPLOS 2006
Classical virtualization, esempio
1
3
4
5
Guest OS Istruzione non privilegiata
verde = User Mode
rosso = System Mode
Istruzione privilegiata
p.e. CLI, Clear Interrupts
2trap
VMM
time
2’
Livello User Livello Kernela. CPU executes a kernel
instruction of the Guest OS
while being in user mode
b. CPU generates a trap
c. Control passes to the VMM
that emulates the instruction
d. 2’ is different of 2, but is
produces the same effect (
(for example,
CLI�VCPU.IF=0)
Hw virtualizazion
Hardware virtualization allows running multiple operating systems and software
stacks on a single physical platform.
The virtual machine monitor (VMM), also called a hypervisor, mediates access to the
physical hardware presenting to each guest operating system a virtual machine
(VM), which is a set of virtual platform interfaces
Type-1 hypervisor (bare metal)
• Guest OS runs unchanged
• Used to build a “Hardware Server” (cloud computing)
• Hyper-V(Microsoft) , VMWare ESX
Type-2 hypervisor (hosted)
• Runs on top of a Hosting OS
• Guest OS unchanged (full virtualization)
• Often used on clients
Example of VMM: Virtual Box
• It usually runs on Desktop computers
• VMM runs as an application hosted by an OS
• Software-based virtualization
• Lower performance, easy to install VM (demo)
IaaS provider’s point of view
• A key challenge IaaS providers face when
building a cloud infrastructure is managing
physical and virtual resources, namely servers,
storage, and networks, in a holistic fashion.
• The orchestration of resources must be
performed in a way to rapidly and dynamically
provision resources to applications.
IaaS provider’s point of view
• The software toolkit responsible for this orchestration is called a virtual infrastructure
manager (VIM).
• This type of software resembles a traditional operating system (“cloud operating system”)—but instead of dealing with a single computer, it aggregates resources from multiple computers, presenting a uniform view to user and applications.
Example: OpenNebula
• Interface to Public Clouds: it offers a driver to
manage the life cycle of virtualized resources
obtained from external cloud providers.
• In case of spikes in demand, extra load can be
offloaded to rented resources. To the
applications, the use of leased resources must
ideally be transparent
IaaS: deployment model
Example of IaaS
• Windows azure
• Different machine with different size and OS
• Different geographical region where the
machine is located
• Free trial (requires registration with VISA)
Platform as a Service
• A cloud platform offering an environment on which developers create and deploy applications
• Developers do have access to a SDK that allows to develop a new application and to deploy it in the cloud
• Impact on the programming model
• Google’s app engine, Windows Azure, and many more…
PaaS – example: GAE
• Cloud service for running web applications on the
Google data center
• Do one thing well
– Simple configuration
– Transparent scalability
• “infinite” number of applications, req/sec storage
– Security
• All applications run inside a sandbox, do not have direct access to
file system, cannot open other connections
GAE architecture
• Google App Engine speaks with web applications through the Web Server Gateway Interface (WSGI) standard protocol
• App Engine and SDK includes the webapp2 framework that implements WSGI
– Advanced frameworks can be used, e.g., Django
WEB AppHTTP Requests
WEB Server
WSGI Protocol
GAE: supported language
• Java
– JVM, Java servlet, …
– SDK Eclipse extension
• Python
– Standard library (without ‘unsecure’ calls)
• Go
LAB: Hello Word in GAE
• What we need:
– Google account
– GAE registration
• Plafond free (10 app)
– Register a new application
• The application ID will be used to deploy the
application
– SDK
– Python 2.7 (no support for 3.x)
Hello Word in GAE
helloworld.py
app.yaml
Code
ConfSimulator
“Google Cloud”Deploy
Web-based Admin console
Step 1
Step 3
Step 2
Step 4
Hello Word in GAE
• Define a handler for the HTTP requests as a class that extends webapp2.RequestHandler class (MainPage)– Attributes : response, request (instance of class Request, Response)
– Methods: get,post, etc.. (to override)
• Map HTTP get request to get method (also post, put, etc..)
• Write data to HTTP response through self.response
• app is a global name that must assigned to the application
helloworld.py
Code
Step 1
app.yaml
Conf
“Google Cloud”Deploy
Web-based Admin console
Step 3
Step 4
• An application name helloword must be registered with the google engine– helloworld.appspot.com
appcfg.py update .
GAE architecture (simplified view)
App Eng
Front End
App Eng
Front End
App Eng
Front End
App Server
Loa
d
Ba
lan
cer
App Server App Server
API layer
APP APP APP
Other
Service
HTTP Requests
Python GAE architecture
Python
VM
Standard
Lib
App
Read-only
File system
Source: Google App Engine – Guido van Rossum
REQ/REP
DATASTOREMEMCACHE
BigTable
URLfetch
images
ServicesSandbox
CGI
Python GAE architecture (scaling)
Python
VM
Standard
Lib
App
Read-only
File system
Source: Google App Engine – Guido van Rossum
REQ/REP
DATASTOREMEMCACHE
BigTable
URLfetch
images
ServicesSandbox
CGI
PaaS example2: Windows Azure
• It is a set of integrated cloud technologies each
providing a specific set of services to application
developers
• Windows Azure provides developer-accessible
services for creating applications
• Strongly integrated with Visual studio
– Development fabric simulator
– Development storage simulator
Windows azure
• Two execution models for applications – Web hosting: Web Site
– PaaS: Cloud Service
• IaaS: Virtual Machines
http://www.windowsazure.com/en-us/develop/net/fundamentals/intro-to-windows-azure/
DeployementWeb Portal
1. Register (Live-id)
Conf(n.inst. =3)
Fabric
Controller
Service
.cspkg
Service
Service
Service
2. Create Hosted-Service
http://xxxx.cloudapp.net
3. Package upload
.csconf + .cspkg
SOFTWARE AS A SERVICE
Types of Cloud Computing
(IaaS) Infrastructure as a Service
(SaaS)Software as a Service
XaaS (PaaS) Platform as a Service
Access to Cloud computing
• A service is delivered through two access points:
• Standard web browsing (HTTP) and
• Programmatic access (Rest,XML-RPC,SOAP, etc. over HTTP)
Programmatic Service Access
(many methods)
Web URL
(standard HTTP methods)
web browerHTTP
Application
HTTP
Rest,XML-RPC,etc
Service
PaaS
IaaS
SaaS
What is a service?
SERVICE
INT
ER
FAC
E
--------
--------
--------
--------
Interface definition (e.g., WSDL)
Technology A
Technology B
Technology C
Web API (aka API as a Service)
• Delivering basic building blocks as ‘services’
for other programs
• Services can be offered via simpler protocols
– JSON, JSON-RPC, REST, JSONP,…
Web API (aka API as a Service)
Web-API
• Based of RPC/HTTP
• Two main data representations
– JSON
– XML
• Protocols
– XML-RPC
– JSON-RPC
– SOAP
– REST
Web API: RPC over Internet• RPC calls mapped onto HTTP (GET or POST)
• Synchronous call
• Asynchronous call– with callbacks
• External data representation– JSON (Java Simple Object Notation)
• http://www.json.org/json-it.html
– XML
• Protocols– REST, SOAP, JSONP, JSON-RPC, XML-RPC,…
JSON
JSON
• Two fundamental structures:
See JSON Lint
XML in a nutshell
• XML (eXtensible Markup Language) is a language derived fromSGML (Standard Generalized Markup Language), from whichHTML also derives.
• The key notion in the markup language familty is a markup,something that describes some aspect of the data
• In HTML markups define the appearance of the document,whereas in XML they define the meaning of the data
XML in a nutshell
• An XML document is a tree
• Data appear inside elements
• An element not only contains the data itself but alsoinformation describing the meaning of the data
Example
Il Signore degli Anelli, di John Ronald Reuel Tolkien,
Bompiani.
Title
Author
Editor
Example
<book>
<title>
Il Signore degli Anelli
</title>
<author>
John R. R. Tolkien
</author>
<editore>
Bompiani
</editor>
</book>
Title
Author
Editor
Book Elements
Tips : Browser allows to see the structure of the document
Elements and attribute
<title>
Il Signore degli Anelli
</title>
Data
Tag
<title pages=“345”>
Il Signore degli Anelli
</title>
Attribute (key/value pair)
Well formed document
Valid document
• Document that follows composition rules
about the its structure
• Two solutions
• Document Type Definition
– Easier, less ‘powerfull’
• XML Schema
– More complex, more powerfull
WFD and validation
XML
DocumentSyntax check
Semantic
checkGrammar
XML-RPC
Overview of XML-RPC
• Data Model
– Scalar
– Struct
– Array
• Messages
– Request message
– Response message
– Error message
Scalar types
Tag Type Example
<i4> or <int> four-byte signed integer -12
<boolean> 0 (false) or 1 (true) 1
<string> string hello world
<double> double-precision signed floating point
number
-12.214
<dateTime.iso8601> date/time 20101504T09:30:00
<base64> base64-encoded binary eW91IGNhbid0IHJlYWQgdGhpcyE=
Struct type
<struct>
<member>
<name>lowerBound</name>
<value><i4>18</i4></value>
</member>
<member>
<name>upperBound</name>
<value><i4>139</i4></value>
</member>
</struct>
Array type
<array>
<data>
<value><i4>12</i4></value>
<value><string>Egypt</string></value>
<value><boolean>0</boolean></value>
<value><i4>-31</i4></value>
</data>
</array>
Request message
• Root element: methodCall
• contains a MethodName element and a params
element
• MethodName contains the name of the procedure
being called
• Params is a list of values for the parameters
Example
<?xml version="1.0"?>
<methodCall>
<methodName>XXX</methodName>
<params>
<param>
<value><i4>123</i4></value>
</param>
<param>
<value><double>12.3</double></value>
</param>
</params>
</methodCall>
Example<?xml version="1.0"?>
<methodCall>
<methodName> XXX</methodName>
<params>
<param>
<value><i4>123</i4></value>
</param>
<param>
<value><double>12.3</double></value>
</param>
</params>
</methodCall>
methodCall
XXX
methodName
params
param valuei4
param valuedouble
123
12.3
Example<?xml version="1.0"?>
<methodCall>
<methodName>Scuola XXX</methodName>
<params>
<param>
<value><i4>123</i4></value>
</param>
<param>
<value><double>12.3</double></value>
</param>
</params>
</methodCall>
methodCall
XXX
methodName
params
param valuei4
param valuedouble
123
12.3
methodName
params
paramparam
doublei4
methodCall
Complete request message
POST /xmlrpc HTTP 1.0
User-Agent: …
Host: …
Content-type: text/xml
Content-length: ..
<?xml version=“1.0”?>
<methodCall>
<methodName>Circle_Area</methodName>
<params><param><value><double>12.2</double></value><param><params>
</methodCall>
Reply message
<?xml version="1.0"?>
<methodResponse>
<params>
<param>
<value><i4>1</i4></value>
</param>
</params>
</methodResponse>
Fault message<?xml version="1.0"?>
<methodResponse>
<fault>
<value>
<struct>
<member>
<name>faultCode</name>
<value><int>4</int></value>
</member>
<member>
<name>faultString</name>
<value><string>Too many parameters.</string></value>
</member>
</struct>
</value>
</fault>
</methodResponse>
JSON-RPC 2.0
• JSON-RPC is a stateless, transport agnostic,
light-weight remote procedure call (RPC)
protocol
• Much like XML-RPC
– No formal grammar
– Definition of request object and reply object
• New feature: batch requests, notification
Some example
--> {"jsonrpc": "2.0", "method": "subtract", "params": [42, 23], "id": 1}
<-- {"jsonrpc": "2.0", "result": 19, "id": 1}
-->{"jsonrpc": "2.0", "method": "subtract", "params": [23, 42], "id": 2}
<-- {"jsonrpc": "2.0", "result": -19, "id": 2}
-->{"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 23, "minuend": 42}, "id": 3}
<-- {"jsonrpc": "2.0", "result": 19, "id": 3}
--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 4}
<-- {"jsonrpc": "2.0", "result": 19, "id": 4}
JSON-RPC call batch
--> [{"jsonrpc": "2.0", "method": "sum", "params": [1,2,4], "id": "1"},{"jsonrpc": "2.0", "method": "notify_hello", "params": [7]},{"jsonrpc": "2.0", "method": "subtract", "params": [42,23], "id": "2"},{"foo": "boo"},{"jsonrpc": "2.0", "method": "foo.get", "params": {"name": "myself"}, "id": "5"},{"jsonrpc": "2.0", "method": "get_data", "id": "9"} ]<-- [{"jsonrpc": "2.0", "result": 7, "id": "1"},{"jsonrpc": "2.0", "result": 19, "id": "2"},{"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request."}, "id": null},{"jsonrpc": "2.0", "error": {"code": -32601, "message": "Method notfound."}, "id": "5"},{"jsonrpc": "2.0", "result": ["hello", 5], "id": "9"}]
JSONP (JSON with Padding)
GET
….
<javasxcript scr=xxx&callback=f>
….
f(JSON data)
Used in JavaScript
Allows to overcome the cross-
domain problem
Uses a callback function
REST
• Method calls are mapped to HTTP request
(Get, Post)
• Method name is a parameter of the call
• Reply is usually formatted as JSON or XML
SOAP
• It’s by far the most verbose protocol
• Service is described in WSDL file
• Messages as XML documents formatted
according to a specific schema
Tool utili per il debugging
RPC over Internet: example
…
http://api.wunderground.com/api/http://api.wunderground.com/api/http://api.wunderground.com/api/http://api.wunderground.com/api/KEYKEYKEYKEY////FEATUREFEATUREFEATUREFEATURE/[/[/[/[FEATUREFEATUREFEATUREFEATURE…]/q/…]/q/…]/q/…]/q/QUERYQUERYQUERYQUERY....FORMATFORMATFORMATFORMAT
Features
geolookupconditions forecast
types= JSON, XML
Example
http://api.wunderground.com/api/[API_KEY]/conditions/q/rome.json
….
location ID
http://api.wunderground.com/api/[API_KEY]/conditions/q/rome.json?callback=f
JSONP
Example of XML reply
http://api.wunderground.com/api/[APIKEY]/conditions/q/zmw:00000.1.16240.xml
Interoperability
Chrome Developer tool
Static call
• Using JS src you can “make a call” and display
results on the screen
•
Static call
Dynamic Call
Dynamic call
1. Dynamically create a HTML element and append in
the head section
2. Call the URL with callback function
Dynamic call
• Show the current temperature on the screen
Using jQuery
Additional example
Additional example
Example: Geocoding API
Example: Geocoding API (json)
Example: Geocoding API (xml)
Example: reverse Geocoding (json)
Example: Reverse geocoding (xml)
Google’s JavaScript API (vers. 3)
Example
Example:
Geolocation in HTML5
Example: Flickr ®
Flickr: request, reply message format
http://api.flickr.com/services/xmlrpc/
http://api.flickr.com/services/soap/
WEB-API
http://api.flickr.com/services/rest/
Example: rest call
Example
• Reply is wrapped through jsonFlickrApi
callback name
• To avoid this, set nojsoncallback=1 option
json format
Asynchronous RPC: AJAX
Sicurezza:
Cross domain non è
consentito
Example: using AJAX
Example: using AJAX
Example: searching photos
Example: searching photos
Example: searching data
Key photo contains photo details
Example: searching photo
Every photo has a link
[mstzb] defines the size
Example: searching photos
Other example
http://api.wordreference.com/{api_version}/{API_key}/{dictionary}/{term}
http://api.wordreference.com/{api_version}/{API_key}/JSON/{dictionary}/{term}
Example
Example
Example: Twitter API
Exercise
• Write a simple JS program for the TTT game
• Hint:
– use a table for button formatting
– Use a single handler to make modification
Other web API
• http://openweathermap.org/api
• EditGrid
• Dropbox is a free (up to 2GB), web-based cloud storage mechanism– file backup service
– data sharing
– Data sync among different clients
– Mobile applications
Android
iPhone
iPad
Blackberry
Windows
Linux
MAC
.mp3
.avi.jpg
REST / JSON
STorage as a Service
Questions?