2015.01.09 - principi del cloud computing e migrazione delle applicazioni moderne al cloud e...
Post on 13-Jul-2015
255 Views
Preview:
TRANSCRIPT
Principi del Cloud Computing e
migrazione delle applicazioni
moderne al cloud
Marco Parenzan
ITST Kennedy 2015 Edition
Marco ParenzanFormazione & Divulgazione con 1nn0va
Microsoft MVP 2014 for Microsoft Azure
Formazione & Progettazione con ITS Kennedy
Ricerca e Innovazione con Servizi Cgn
www.slideshare.net/marco.parenzan
marco [dot] parenzan [at] libero [dot] it
www.innovazionefvg.net
Developer e Architect in .NET e Web
Cloud Developer
Loves functional programming
Some videogames for fun
Alcuni termini
Hosting è l’esecuzione di una soluzione applicativa su un server di produzione
Hosting on premise è l’hosting «in casa propria»
Il deployment è l’attività di installazione della soluzione applicativa sull’hosting
Spesa attuale
Alcune cattive abitudini
Non calcolare il ritorno economico della messa in produzione di una soluzione applicativa
Non calcolare il costo operativo di una soluzione applicativa
Pensare che i costi siano fissi
Pensare che decisa una volta (all’inizio) la scelta sia per sempre
Pensare che una soluzione applicativa giri su una sola macchina
Una discussione
Il costo del telefono e della connettività Internet sono fissi
I costi di acqua, luce e gas sono variabili (eppure la manutenzione di una rete acqua,
luce e gas è arbitrariamente straordinaria – se non si rompe...)
Qualsiasi infrastruttura ha bisogno di manutenzione
La manutenzione sulla rete telefonica e dati è sempre straordinaria
La manutenzione di un server è ordinaria
“Computation may someday
be organized as a public utility”
(John Mccarty, 1960s)
Computing: la quinta utility
Acqua
Gas
Elettricità
Telefono
Computing
Introduzione al
Cloud Computing
Nuove abitudini
Obiettvi
Ridurre gli investimenti IT per l’Impresa
Variabilizzare i costi, rendendoli certi
Ridurre la necessità di investire in competenze interne per la gestione dell’infrastruttura e
l’aggiornamento del software
Nuove abitudini
Avere sempre un business plan
I costi sono variabili (ma questo non significa che la spesa non sia predicibile – bisogna
saperlo fare)
Bisogna adattare le scelte fatte in corso d’opera
Una soluzione applicativa deve poter girare su più macchine
Cos’è il Cloud Computing
On-demand, scalable, multi-tenant, self-service compute and storage resources
Cos’è il Cloud Computing
Il Cloud Computing è un modello che consente una convenienza attraverso l’accesso
(on-demand) ad una rete condivisa di un pool di risorse di calcolo configurabili (ad
esempio, network, server, storage, applicazioni e servizi) che possono essere rapidamente
fornite e rilasciate con il minimo sforzo di gestione o con interazione del service provider.
Questo modello di Cloud promuove la disponibilità ed è composto da cinque
caratteristiche fondamentali, tre modelli di servizio, e quattro modelli di distribuzione..
NIST v15 – 07/10/2009
NIST - National Institute of Standards and Technologyhttp://csrc.nist.gov/groups/SNS/cloud-computing/
Cloud Computing appetibile
Disponibilità ovunque
Rapidità di implementazione
Facilità di utilizzo
Aggiornamento costante del software
Scalabilità della soluzione con la
crescita e la variabilità della
domanda
Riduzione dei costi
Fortune 500 using Azure
>57% >300kActive websites
More than
1,000,000SQL Databases in Azure
>30TRILLIONstorage objects >300 MILLION
AAD users
>13 BILLIONauthentication/wk>3
MILLIONrequests/sec
>1.65MILLIONDevelopers registered
with Visual Studio Online
.NET Support2014Offline Sync
Mobile Services
Networking Visual Studio & .NET
Virtual MachinesMemory Optimized Disk Optimized
Resource Manager
Portal
VSO GA
XamarinPoint-to-site VPN
Web Sites
SMB File SystemIBIZA
Remote Debug
VM Management
SQL Database
Puppet Chef DockerPowershell and DSC
Capture / Deploy
AutoscaleDynamic Routing
Subnet Routing
Static IP
Storage
Autoscale
Traffic Mgr
Web Jobs
Backup
Java Support
ASP.NET MVC 5.1
ASP.NET Web API 2.1
AD support
Powershell Automation
Node.JS project support
Remote DebuggingKindle Support
BD’s up to 500GB
99.95% SLA
Self Service Site RecoveryActive GEO replication
HDInsight
Hadoop 2.2
YARN support
.NET 4.5
.NET Foundation
Azure Redis Cache
API Management
Site Recovery
Remote Apps
Cordova
VSO Open Api’s
Event Hub
Compliance: aka.ms/AzureCompliance
Visual Studio Online
Full Portal Integration
Not just for Microsoft shops
Agile
Build Test
Deploy
InsightsCode
Key Scenarios to get started with Microsoft
Azure
Dev / Test
Full test and dev environments in minutes
VSO integration
Lift and Shift
Take existing work loads and run then in a certified instance
Storage
Archive key data in inexpensive cloud storage
Big Data
Process key data into business intelligence using Hadoop or Machine Learning
Identity
Synchronize all your identities through Azure AD to control access to Apps, Data and Services
Web Apps
Take your web apps to the cloud using inexpensive Web Sites
Service Models in Cloud
Modello di distribuzione
La cloud infrastructure è di
proprietà di una
organizzazione che vende i
servizi cloud al pubblico o
ad un gruppo di grandi
imprese
L’infrastruttura è una
composizione di due o più
cloud (private, community, o
public) in una entità unica,
tenute insieme da
tecnologie proprietarie tali
da permettere la portabilità
dei dati e delle applicazioni
(ad esempio, cloud
bursting).
La cloud infrastructure è di
proprietà o in leasing di una sola
organizzazione ed è utilizzata
esclusivamente
dall'organizzazione
La cloud infrastructure
è condivisa da diverse
organizzazioni e sostiene
una comunità specifica
che ne condivide degli ambiti
(ad esempio, la mission, i
requisiti di sicurezza, la policy, e
le considerazioni di conformità).
Percorso attraverso i modelli di distribuzione
On Premises
Yo
u s
cale
, m
ake r
esi
lien
t an
d m
an
ag
e
Infrastructure(as a Service)
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
Man
ag
ed
by v
en
do
r
Yo
u s
cale
, m
ake
resi
lien
t &
man
ag
e
Platform (as a Service)
Sca
le, re
silien
ce a
nd
man
ag
em
en
t b
y v
en
do
r
Yo
u m
an
ag
eStorage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
Hosting models
Software(as a Service)
Storage
Servers
Networking
O/S
Middleware
Virtualization
Applications
Runtime
Data
Business model
Storage
Servers
Networking
O/S
Middleware
Virtualization
Data
Applications
Runtime
Sca
le, re
silien
ce a
nd
man
ag
em
en
t b
y v
en
do
r
Why the cloud?
Iaas, Paas, Saas Comparison
Modello di servizio
(SaaS). Fornisce al consumatore la possibilità di usare le applicazioni in esecuzione
su una Cloud infrastructure accessibile da vari dispositivi client attraverso una
interfaccia come un browser Web (ad esempio, una web-based e-mail). Il
consumatore non riesce a controllare l’ infrastruttura base della Cloud, rete, server,
sistemi operativi, storage, con la possibile eccezione di limitate specifiche
impostazione per l'utente delle impostazioni di configurazione dell’applicazione.Application
Platform
(PaaS). Fornisce al consumatore la possibilità di distribuire nella Cloud infrastructure
applicazioni create dal consumatore che utilizzano linguaggi di programmazione
supportati dal fornitore (ad esempio, Java, Python,. Net). Il consumatore non ha il
controllo della base della Cloud infrastructure, rete, server, sistemi operativi, storage,
ma ha il controllo sulle applicazioni distribuite ed eventualmente sulle configurazioni
dell’ ambiente.
(IaaS). Fornisce al consumatore il poter noleggiare capacità di CPU, storage,
network, e altre risorse fondamentali che il consumatore è in grado di implementare
e gestire, che possono includere i sistemi operativi e le applicazioni. Il consumatore
non ha il controllo delle infrastruttura di base della Cloud, ma ha il controllo su
sistemi operativi, storage, la distribuzione delle applicazioni, ed eventualmente
selezionare componenti di rete (ad esempio, firewall, load balancer).Infrastructure
Service Models in Microsoft Azure
Virtual Machines
Getting started
>_
REST API
Management portal
Scripting (Windows, Linux and Mac)
Select image and VM size
Extra Small
Small
Medium
Large
X-Large
New disk persisted in storage
Cloud
BlobStorage
Comprehensive Networking
Windows Server
Linux
Boot VM from new disk
Microsoft Azure Web Sites
Create new sites in seconds
Easily manage and scale your sites
Automatic load balancing and shared
storage across instances
Scale out or up to reserved instances
for improved performance and scale
Built-in web jobs support
Use ASP.NET, ASP, PHP, Java or
Node.js
SQL Azure or MySQL databases
Start with open source apps and
frameworks
Develop with VS and WebMatrix
Supports any Web development
tool on any platform (Windows,
OSX, Linux)
Rapid deployment for quick
iteration
Integrated source control with
Team Foundation Server (TFS) and
Git
Built-in monitoring of perf and
usage data
Quick access to request logs, failed
requests diagnostics and
diagnostics
Mobile Services
Storage
Authentication
Logic
Push
Scheduler
• Provides essential services to support client development
• Client Support• iOS
• Android
• HTML5/Web
• Xamarin
• Windows
• Windows Phone
• PhoneGap
• Sencha
Services for Applications in Cloud
On-demand self-service
Broad network access
Resource pooling
Measured Service
Rapid elasticity
On Demand Self Service
Il Consumatore può disporre di capacità di calcolo (es. server time, network storage) se
necessario senza richiedere l’interazione umana con alcun fornitore del servizio.
Il servizio è completamente automatizzato e permette di modificare la richiesta a
seconda delle volontà del consumatore.
Broad Network Access
Le capacità sono disponibili in rete ed accessibili in qualsiasi momento tramite Pc, Laptop
ma anche altri strumenti che possono accedere ad Internet come Cellulari, Palmari ecc…
Broad network access
Resource pooling
Measured Service
Rapid elasticity
On-demand self-service
Resource Pooling
Le risorse di calcolo sono messe al servizio di tutti i consumatori utilizzando un modello
MULTITENANT, che permette ad un’istanza Software di servire più Client, con diverse risorse
fisiche e virtuali dinamicamente riassegnate in base alla domanda dei consumatori.
L’Utente in genere non ha controllo/conoscenza dell’esatta posizione delle risorse (in
alcuni casi può essere un problema).
Broad network access
Resource pooling
Measured Service
Rapid elasticity
On-demand self-service
Measured Service
I Sistemi Cloud automaticamente controllano e ottimizzano le risorse misurandole
adeguatamente.
L’utilizzo è misurato per offrire un servizio “Pay-per-Use”. L’utente paga per il servizio che
realmente utilizza.
Broad network access
Resource pooling
Measured Service
Rapid elasticity
On-demand self-service
Rapid Elasticity
Le Risorse possono essere rapidamente ed elasticamente incrementate per scalare la
potenza ed essere allo stesso modo rilasciate.
Per il consumatore le capacità delle risorse disponibili spesso sembrano “infinite” e può
acquistarne qualsiasi quantità in qualsiasi momento.
Broad network access
Resource pooling
Measured Service
Rapid elasticity
On-demand self-service
Services for Applications in Azure
Support for Open Source
Languages
CMS
Devices
Databases / Apps
Operatingsystems
Management
Scalability Scenario
Scalability
From Wikipedia
Scalability is the ability of a system, network, or process to handle a growing amount of work in a
capable manner or its ability to be enlarged to accommodate that growth
In another way
Scalability describes the ability to keep constant the handling time of a request as amount of
work growth.
Ways to manage scalability
Scaling Up
Get it bigger
Be carefull about single points of failure
Scaling Out
Get it more that one
Be careful about state
Async
Give it the right time
Decoupling in time
Queuing
Decoupling in tiers
Scaling
Scale up by choosing different VM sizes
Scale out by adding more instances
Scale-out automatically with Elastic scaling
Scale out static content with CDN to distribute user traffic
Scale out low-variable data with caching to offset server workloads
Managing demand
Don’t forget you are also paying for unnecessary software licencing while you are over capacity
TIME
IT C
AP
AC
ITY
Actual Load
Allocated
IT-capacities
Too Much
Power
Load Forecast
Potential business loss
Wasted capacity
Not Enough Power
Predictable Bursting
Services with no seasonality trends
No particular peaks
IT complexity, no wasted capacity
Uso «sostanzialmente» costante
Applicazioni interne
Unpredictable Bursting
Marketing On-Time Offer
Aperiodical Dues
Special Event
Unexpected/unplanned peak in demand
Sudden spike impacts performance
Can’t over provision for extreme cases
Average Usage
Periodical Bursting
Marketing Periodical Offer
Periodical Dues
Special Repeatable Events
Services with micro seasonality trends
Peaks due to periodic increased demand
IT complexity and wasted capacity
On/Off Bursting
Digital media rendering and encoding
Financial and insurance risk calculation
Engineering modeling and simulation
Computational life sciences
Earth sciences
Data analytics
On & off workloads (e.g. batch job)
Over provisioned capacity is wasted
Time to market can be cumbersome
Growing Fast
Social Media
Web Games
Successful services needs to grow/scale
Keeping up w/ growth is big IT challenge
Cannot provision hardware fast enough
Average Usage
Async to scale?
It depends…
(A)Syncronous
Syncronous (relation) between a client and a server is when server MUST respond to client
request and client have to wait ACTIVELY for server response.
Asyncronous, in a web context has two situations
Client SideAsyncronous is for responsiveness
Server SideAsyncronous is for scalability
Responsiveness
Don’t block UI thread so user can continue interacting with app while request is currently running
Scalability
Increase the usage of the thread pool while a request is blocked for I/O
“Async” scale-up
Sync cause “scaling up”
You can only increase resources because “sync” scenario tends to “lock” resources
Async lower the need of scaling up
Resources are better used
Async is not useful to scale out
A queue to scale
Let command be executed to whom is
really responsible
Async client
Responsive
Async server (MVC action)
Scalable
‘Still synchronous when executed by MVC role
MVC is “front end” role to the client
Syncronous implies “give a response”
Really?
It’s really needed
Response vs. “acknowledge”
Syncronization is needed to obtain an answer
What’s in the answer?
Result
Acknowledge
Result
What you expected from execution of the request
Acknowledge
Response about “taking responsibility” on request, but not the result
Why not the result
Typically because it take too long to obtain response
Async (client/server) is always “pretend an answer” inside a timeout ….in seconds on average
Many scenarios cannot have this
Order management
Interop with legacy systems
…
Command as a serializable request
Command is the metaphor for the request
Useful to be serializable
Serializable is useful to store/persist/”suspend”
Why “suspend”?
Because a long time to execute
Executor is overloaded
Executor is doing something else
Executor need it’s time to execute
Where serializing?
Somewhere where “taking out” is a principle
For example “FIFO” structures: queues
Using Queues
Queue are useful to receive commands
MVP frontend role just acquire commands
Commands are syntactically validated
Commands are just queued
(a)sync response from frontend is quick
Just acknowledge the insertion of command into
queue
MVC
Frontend
Role
Controller
ActionCommand Command
Co
mm
an
d
Co
mm
an
d
Co
mm
an
d
Co
mm
an
d
Co
mm
an
d
Co
mm
an
d
Command Queue
A worker to scale
Commands in a queue
When Commands are in queue, who take commands out?
Command Handler is the generic concept
A CH handle a command
Many commandsmany command handlers
Domain in the CH
Command Handlers execute command
Act on the domain
Call aggregate entity methods
Mapping command parameters
Typically Commands are not domain objects
Workers
A command handler must be hosted in a process
Process are typically NON-UI processes
simple, Light
end-less (infinite loop)
Sleepy (suspend themselves each loop)
Stateless (no global variables, just loop function)
Horizontally scalable (execute many in parallel, in the same machine, in many machines)
Typically Console.exe apps (in .NET)
Estract message from queue and execute it
Support
Retry logic
Priority logic
An event to scale
Don’t take more responsibility: inform
about what you have done
A worker is the identity that implements CH and act on then domain
A worker knows the domain through aggregates
Aggregate know only its domain
What about impacts about acting on the domain?
Copies of data somewhere else
Perform other actions into other domain
Have the aggregate knowledge about effected?
No
Aggregate must declare that Something has happened
An event
An event is the knowledge of something happened in the history
An event must be shared with anyone
…interested about event
Event queue
Events generated by aggregate must be
collected in a structure that shares event
to many
Publisher/subscriber pattern
Many listener “subscriibe” to the event
queue
A subscriber declare which messages are
interesting
Aggregate
Method
1 Event
Ev
en
t
Ev
en
t
Ev
en
t
Ev
en
t
Ev
en
t
Ev
en
t
Event Queue
Listener
Listener
Listener
Listener
Push data on the web
Responses: where are they
Client have done a request/a command
Client have received an acknowledge
Domain has executed the command
A result have happened…yes….?!?!?!?
A result is the execution of the command
A result is found
When? When event is notified
Where? Event give all and enough information to RETRIEVE the result, not the result itself
Client knows following the event which is the result to be retrieved
Pull/Push communication with client
How client knows about events?
Pull way
Client request from an event queue if it have and event
Events must be stored
Client have to query events queue to check if there are some new events
Push way
Server will reach client and send it an event message
Modern way with Web Sockets (in a Web scenario)
SignalR in ASP.NET
Retrieve the result
Event contains information to retrieve the result, not the result itself
Some keys, ids
Some display data
Event is a DTO
Event is enough to get other DTOs, for example
Event can be used to trigger other actions
top related