Cloudcomputing for mobile apps - uniroma1.itberaldi/MACC/CloudComputing_OK_19.pdf– Mobile...

Preview:

Citation preview

Cloud computing for mobile apps

Roberto Beraldi

Factors enabling cloud computingHardwareHW virtualizationMulti-core chips

Internet Technologies

DistributedCom

puting

Web 2.0Web ServicesMashupsSoA

Utility computingGrid Computing..

System Management

Autonomic ComputingData Center Automation

Cloud computing

Cloud actors

• Dropbox is a free (base 2GB, up to 18GB), web-based cloud storage mechanism– file backup service – data sharing– Data sync among different clients– Mobile applications

iPhone

iPad

Windows

Linux

MAC

.mp3

.avi.jpg

Freemium business model

Web-API: REST / JSON calls

Example: dropbox

Security (SSL, AES-256 bit), scalabity (load balancer, server notification, data/metadata..)

.

.

.

Dropbox usage

• Two access «channels»• For users:–Web based access– Proxy applications

• For developers:– Endpoint for web-api calls • Wire protocol• Data representation

–Different development technologies• Java, .NET, Python, etc.

Main characteristics of CC

• Pay-per-use– no ongoing commitment, utility prices

• Elastic capacity and the illusion of infinite resources– Scale up/down, vertical/horizontal

• Self-service Interface: Users can manage the service

• ..

Classic Delivery models

(IaaS) Infrastructure as a Service

(SaaS)Software as a Service

XaaS (PaaS) Platform as a Service

SaaS

SaaS

Entire SW

Web-API

…..

Example of SaaS (Application)

SaaS (Web-API)

Web-API

CRUD

OBJECTS

READ-ONLY

.

.

.

OTHER..m

ore advancedData m

odel

Provide API accessto an already available web site..

Programmable web

Other deliver models

• Backend as a Service (BaaS), • Mobile Backend as a Service (MBaaS)• Function as a Service (FaaS)• Storage as a Service (SaaS)– NoSQL data models (performance reason)– CAP theorem

BaaS

• Provides support to app in terms of– Real time DB – Push notification– Crash reporting– Authentication– ..

• Specific support to domains– IoT (e.g., AWS’s greengrass)– Cloud robotics– ..

MBaaS

Main cloud service provides

• Amazon Web Service• MS Azure• IBM Cloud• Google Cloud

https://www.youtube.com/watch?v=lpFDFK44pX8

https://www.znetlive.com/blog/comparing-top-4-public-cloud-providers-in-2018-microsoft-azure-vs-aws-

vs-ibm-vs-google/

Example

Connecting to web-api cloud

?HTTP

TCP

Wire protocol

Web API • How to authenticate the app?

• How to authenticate the user?

• Which application protocol to use?

• How to represent data?

Workflow

• To use a cloud service the following steps are required

• Register to the console• Register the application– Get API-KEY

• Use the service from the registered app– App authentication

• Often, an SDK is available to access the service from the most used languages

How to authenticate the app?

• Cloud providers offer a web console to register the app that will use the service

• Eventually the provider generates an API KEY– Limit the usage according to the subscribed plan– Authenticate the app– Provide a report about the use

How to authorize data access?

• Some Web-API allows to get access to sensible data (e.g., FB)

• Access Token (Oauth 2)– The application is registered on the data provider– The application specifies a scope representing the

kind of data it wants to access– User is required to grant the permission

• API KEY

Abstract authorization flow

How to authenticate the user?• Implement a “user name-password” scheme• Use some Identity Provider– Google – Facebook – Twitter

Two factors scheme

How to represent data?

xml json

Useful tool

• cURL• Postman

Platform as a Service• A cloud platform offering an environment on

which developers create and deploy applications– E.g., decide the size of the VM, where they are

located, etc.• Many Programming Languages• Frameworks• Web based console to create application (with

dashboard) • See https://paasfinder.org/ for a complete list

(70+)

pasfinder

PaaS enabling technology

Containers

Containers include the application and all of its dependencies, but share the kernel with other containers. They run as an isolated process in userspace on the host operating system. Same OS!Runs only on LinuxMuch faster

Example: Openshift

Example: OpenshiftRed Hat's container application platform automates the provisioning, management and scaling of applications

Versions:-Origin (open source)-Enterprise-online (running on AWS)

Based on ‘container’ (Docker) and POD (unit that can be replicated)

OpenShift’s architecture

Heroku

Heroku architecture

• At a high level, a deployed sw is organized in terms of dyno (containers)

• Front end (Web dyno)• Backend (Worker dyno)• On shot (One-off dyno)

Why dyno?

Why dynos?

Why dynos: scalability

Example of Heroku commands

Platform as a Service• A complete environment to build, manage and

deploy app

• One key feature of PaaS is scaling– Horizontal, vertical, automatic– ….

Vertical scaling

• The response time of typical application depends on the (normalized) rate of requests received (load)

• After a given load, the app becomes congested, i.e., it doesn’trespond quickly .. Or even worst it dosen’t respond at all

• Scalabity means the capacity to react to a congestion

Example

Vertical scaling

• A straightforward way to implement scalability is to upgrade the physical machine

• More RAM, CPU cores, etc…• Of course, at some point the new machine

becomes congested again..

Horizontal scaling

• A different approach is to modify the architecture of the app

• With horizontal scaling the app is divided in different components can be replicated on different physical machines so that more requests can be server in parallel

• The simplest solution is follow a three tier architecture and replicate the business tier

Horizontal scaling (replication)

Dispatcher

App App App

DATA

….

HTTP requests

Scheduler (e.g., Round Robin)

Assumptions:Requests are statelessThey are of the same typeThe data tier is harder to scalemay become the bottleneck

Horizontal scaling (web-queue-worker)

• Another solution is to dived the application in separate modules with different roles that can be replicated

• For example, a module can be a web responder and the other a worker (performing long running tasks) and queue that connects the two modules

Horizontal scaling

Horizontal scaling(web/queue/worker)

Dispatcher

Web Web Web

DATA

….

HTTP requests

Scheduler (e.g., Round Robin)

Worker Worker Worker

Webmodule(replies quicklyeven with ‘in progress’)

Worker(perform computeintesive tasks, or long latency)

External requests

Dispacther: light computation

Replicated DB: àconsistencyMaster/SlaveUse no-SQL DB (memcached)

Queue

Microservice Architecture for scaling

• Implement the app as a set of (micro)services• Again, each service exposes public API• Service to service synchronus communication

When/how to scale• Manually scaling (via commands or config file)• Automatically done (by some algorithm)• How many copies of each module?• Elastic scaling: increase/decrease the number of copies according

to the measured delay (feedback based system)• Elastic scaling is a key feature of cloud computing. Scale up and

scale down. Still pay-per-use• Autonomic systems (adapt to external changes):

– Self-configuration – Automatic configuration of components– Self optimization– …

• Optimum scaling protocol (minimizes resource usage while still guarantee SLA)..

Automatic scaling (auto-scaling)

• Automatic resource provisioning and releasing• Threshold based solution

– A VM may take 10 min to start– If too conservative violation of SLA à cost– If too proactive, add VM when unnecessary àcost

• Predict when to scale – Hard in case of flash- crowd workload

• Several proposed algorithm (it is a research topic)– Machine Learning technique– Neural Networks– …

INFRASTRUCTURE AS A SERVICE

CC: Virtual computing power

CPU cycles

Storage

Memory

Provider Utilization

Virtual machine

control panel

User decides the size on the VM…

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, main idea• Memory:

– Virtual Memory (>=Physical memory)• Multitasking:

– Several processes concurrently on the same HW, see the same ISA. HW is shared thanks to an OS than manages critical instructions.

• Virtual Machine:– ‘60 from IBM on mainframes– Abandoned with the advent of PCs, now again used for cloud

computing– Even different ISA on the same CPU– Used to run different OS– Achieved through a Virtual Machine Monitor

Interface of a computing system

3: privileged instructions4: user instructions

Virtual Machine

• Virtual Machine is a logic machine (ML) whose ISA is implemented exploiting software running on a physical machine (MF)

• Two main types:– Native. ML=MF

• Same ISA. Indeed instructions of the MF are in large part executed on the real CPU. Sensitive instruction are trapped.

– Emulation ML≠MF (different ISA)• HW emulation • Language level emulation (java)

Emulation (process level virtualization)

• HW emulation:– ISA is different from real CPU

• Sparc emulates IA32

– Installation of different OS• Language specific VM– JVM– CLR

Native VM (System level virtualization)• Same machine as the physical machine

“Efficient, isolated duplicate of a real machine”)

• Virtualization is realized by a Virtual Machine Monitor (VMM) o hypervisor

Native• Full virtualization– OS without modification (e.g., VMWare’s ESX,

ESXi)– OS legacy

• Para virtualization – OS must be modified (e.g., Open source’s XEN)– Higher efficiency

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 privileged level. 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 Not privileged instruction

green= User Modered= System Mode

Privileged instructione.g.. CLI, Clear Interrupts

2 trap

VMM

time

2’

User level Kernel levela. 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), hypervisor, mediates access to thephysical 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’s ESX

Type-2 hypervisor (hosted)• Runs on top of a Hosting OS• Often used on clients

Example of VMM: Virtual Box

• It usually runs on Desktop computers• VMM runs as an application hosted by an OS• Lower performance, easy to install VM

HW assisted virtualization

• Processors are designed to help virtualization• For example, Intel-VT and AMD-V provide

additional instructions that help virtualization• Hypervisors can use these instructions to

improve the performance – Linux KVM, Microsoft Hyper-V, Microsoft Virtual

PC, Xen, etc. use these features

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.

Isolation

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.

Application mobility

HW consolidation• Virtualization makes it possible to consolidate

individual workloads onto a single physical platform, reducing the total cost of ownership.

IaaS provider’s point of view

• A key challenge IaaS providers face when building a cloud infrastructure is managingphysical 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.

VIM and hypervisor

physicalservers

Hypervisor Hypervisor Hypervisor VIM

Virtualizationplatform

Virtualserver

Automated scaling

VIMhypervisor hypervisor

1)User request a new VMThat joins the existing 3 VMs

1

2

2) VIM allocates the new VM

Usage and administratorportal

Physical server 1 Physical server 2

Automated scalelistener

Automated scaling

VIMhypervisor hypervisor

1)User request a new VMThat joins the existing 3 VMs

1

2

2) VIM allocates the new VM

3

3) User increases the loadrequest

4scale-up!

Usage and administratorportal

Physical server 1 Physical server 2

Automated scalelistener

Example: automated scaling

VIMhypervisor hypervisor

Physical server 1 Physical server 2

Automated scalelistener

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

Example: OpenStack

OpenStack is a cloud operating system that controls large pools of compute, storage, and networking resources throughout a datacenter, all managed through a dashboard that gives administrators control while empowering their users to provision resources through a web interface.

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)

• Amazon EC2• …

Main Amazon Web Service offering• Elastic Cloud Computing (EC2)– Amazon Elastic Compute Cloud (Amazon EC2) is a web

service that provides resizable compute capacity in the cloud.

• Amazon Simple Storage Service (Amazon S3)– Amazon S3 provides a simple web services interface

that can be used to store and retrieve any amount of data, at any time, from anywhere on the web.

• Amazon Simple Queue Service (Amazon SQS)– offers a reliable, highly scalable hosted queue for

storing messages as they travel between computers

Current offer

Amazon Web Services (EC2)• Rich set of VM• General purpose

– baseline level of CPU performance with the ability to burst above the baseline

• Compute Optimized, GPU, etc…• Reserved Instance

– Amazon EC2 Reserved Instances allow to reserve Amazon EC2 computing capacity for 1 or 3 years

• Dedicated Instance– run in a VPC (Virtual Private Cloud) on hardware that's dedicated to a

single customer.• Cluster networking• Spot Instance

– allow to bid on spare Amazon EC2 computing capacity.

Price (depends on the location)

Microsoft Azure vs Amazon AWS

• Short story: AWS is superior to Windows Azure

• Long story: see– http://www.computerworlduk.com/it-

vendors/microsoft-azure-vs-amazon-aws-public-cloud-comparison-which-cloud-is-best-for-enterprise-3624848/

New trends: Containers

Each virtual machine includes the application, the necessary binaries and libraries and an entire guest operating system - all of which may be tens of GBs in size.

Containers

Containers include the application and all of its dependencies, but share the kernel with other containers. They run as an isolated process in userspace on the host operating system. Same OS!Runs only on LinuxMuch faster

Mobile Cloud Computing

• Exploiting ‘cloud’ approach to boost the performance of an application, reduce the energy consumption, increase the computation power

• Example: ‘CloneCloud’– The system is a flexible application partitioner and

execution runtime that enables unmodified mobile applications running in an application-level virtual machine to seamlessly off-load part of their execution from mobile devices onto device clones operating in a computational cloud.

CloneCloud: main idea

Mobile-to-mobile offloading

Questions?