Page 1
Designing Resource-Aware Applicationsfor the Cloud with ABS
Einar Broch Johnsen
University of Oslo, [email protected]
1st Intl. Workshop on Formal Methods for and on the Cloud (iFMCloud)Reykjavik, Iceland, 04 June 2016
http://www.envisage-project.eu
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 0 / 22
Page 2
We want to make e↵ective use of cloud computingto meet service requirements
Cloud API
ApplicationService
IVirtualization makes elasticamounts of resources available toapplication-level services
IMetered resources: Resources onthe Cloud are pay-on-demand
I Services need to share and scale
resources
IDigitalization: new services needto share resources with old services
Discovering bad resource management after deploymenton the Cloud can be a very costly (wasting both time and money!)
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 1 / 22
Page 3
Services deployed on the cloud:Predicting behavior from models
ApplicationServer
DC4DC3
CalcServerDC2
CalcServer
DC1
CalcServer
AppWorkflow
CloudProvider
Invoke task
# of VMTotal Cost
Application Server =
Application Workflow +
Application Resource Management(load balancing, scalability)
CalcServer =
Independent tasks(can be parallelized)
AppRM
IResource-aware design:Build software that candynamically modifyits own deploymentto improve perfor-mance and/orreduce cost
IModel-based deployment decisions at design time using service models
IFormal semantics: Architects and developers can simulate and analyze atdesign time how an application runs on the cloud
Hahnle, Johnsen. Designing Resource-Aware Cloud Applications. IEEE Computer 48(6), 2015
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 2 / 22
Page 4
What kind of questions can we answer using models?
Berndnaut Smilde: Nimbus II, 2012
Model-based analysis ofperformance vs. cost
1 How will the response time and cost of running my system changeif I double the number of servers?
2 Can I meet my performance requirements with my currentdeployment strategy? What about fluctuations in client tra�c?
3 Can I control the performance of my system better by using acustom resource manager?
Use the model topredict behavior
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 3 / 22
Page 5
Conceptual Parts of a Deployed Cloud Service
Provisioning Layer
Legal Contract Layer
Formal Service Contract
Executable Model of Client Layer
Cloud API
Simulation
“early modeling”
Formal Methods
“early analysis”
Provisioning
“runtime monitoring”
Combine techniques based on abstract executable models
I Formal modeling using Abstract Behavioral Specifications (ABS)
I Formal methods: Verification, Performance Analysis, Cost Analysis,Advanced Type Systems, Code Generation, Test-Case Generation
I Monitoring: Framework to generate monitors for SLA-compliance
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 4 / 22
Page 6
Example: Phone Services - Abstract Behavioral Model
Telephone Service
interface TelephoneService {Unit call(Int calltime);
}class TelephoneServer implements TelephoneService {Int callcount = 0;Unit call(Int calltime){while (calltime > 0) { [Cost: 1] calltime = calltime � 1;
await duration(1, 1); }callcount = callcount + 1;
}}
SMS Service
interface SMSService {Unit sendSMS();
}class SMSServer implements SMSService {Int smscount = 0;Unit sendSMS() {[Cost: 1] smscount = smscount + 1;}
}
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 5 / 22
Page 7
Example: The New Year’s Eve Client Behavior
50 70
Alternate sms and call
Huge number ofsms per time interval
time
Alternate sms and call
Midnight Window
class NYEclient(Int frequency,TelephoneService ts,SMSService smss){Time created=now(); Bool call=false;Unit normalBehavior(){ ... }Unit midnightWindow(){ ... } // Switch at appropriate time...
}{// Main block:
DC smscomp = new DeploymentComponent(”smscomp”, Speed(50));DC telcomp = new DeploymentComponent(”telcomp”, Speed(50));[DC: smscomp] SMSService sms = new SMSServer();[DC: telcomp] TelephoneService tel = new TelephoneServer();Client c = new NYEbehavior(1,tel,sms); ... // Clients
}
How to deploythe services?
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 6 / 22
Page 8
Example: Simulation Results
Einar Broch Johnsen, Olaf Owe, Rudolf Schlatte, Silvia Lizeth Tapia Tarifa:Dynamic Resource Reallocation between Deployment Components. ICFEM 2010: 646-661
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 7 / 22
Page 9
Load Balancing in Deployment Scenarios
smscomp
telcomp
Client
Client
sms()
call(n)
sms()
call(n)
tel
sms
telb
smsb
request()
Resource awareness: resource reallocation, object mobility, job distribution
I dc.load(e): average load on dc during the last e time intervals
I dc.total(): currently allocated resources on dc
I dc.transfer(dc2, r): transfer r resources to dc2
Load Balancing Strategy for the Phone Services
Example: Reallocate 1/2⇥total resources upon request from partner
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 8 / 22
Page 10
Example: Simulation Results
Johnsen, Owe, Schlatte, Tapia Tarifa:Dynamic Resource Reallocation between Deployment Components. Proc. ICFEM 2010
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 9 / 22
Page 11
ABS: Abstract Behavioral Specification
ABS: Between design-oriented and implementation-oriented specification
I State-of-the-art modeling language: actors + OO
I Models follow the execution flow of OO programs,but abstract from implementation details using ADTs
I ABS allows time modeling and deployment modeling
I Java-like syntax: intuitive to the programmer
ABS is a formal, tool-supported modelling language
I Operational semantics allows advanced analysis techniques
I Simulation tool for rapid prototyping
I Automated worst-case resource and deadlock analysis
I Automated optimization of static deployment
I Semi-automated scalable verification of functional correctness (KeY)
I Code generation into Java and Haskell (preserves cost bounds)
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 10 / 22
Page 12
Deployment Components
Deployment components are abstract execution locations
I Each deploymentcomponent has a givenresource capacity
I Objects execute in thecontext of a deploymentcomponent
Server ...
...objectEnv
[cost] Task1[cost] Task2object 1
[cost] Task1[cost] Task2
object n[cost] Task1[cost] Task2
I The resources are shared between the component’s objects
I Object execution uses resources in a deployment component(via Cost annotations)
I How resources are assigned and consumed,depends on the kind of resource
Johnsen, Schlatte, Tapia Tarifa. Integrating deployment architectures and resource consumptionin timed object-oriented models. J. Log. Algebr. Meth. Program. 84(1), 2015
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 11 / 22
Page 13
A Resource-Aware Application in ABS
interface CalcServer {Unit process(Int cost);DC getDC();
}class Server implements CalcServer {Unit process(Int cost) { [Cost: cost] skip; }DC getDC() { return thisDC(); }
}interface ApplicationServer {Bool request(Int cost);
}
ApplicationServer
DC4DC3
CalcServerDC2
CalcServer
DC1
CalcServer
AppWorkflow
CloudProvider
Invoke task
# of VMTotal Cost
Application Server =
Application Workflow +
Application Resource Management(load balancing, scalability)
CalcServer =
Independent tasks(can be parallelized)
AppRM
class ConstantBalancer(CloudProvider provider, Int serverSize) implements ApplicationServer {Server server; DC dc; Bool initialized = False;
Unit run() {Fut<DC> f = provider!createMachine(serverSize); await f?; dc = f.get;[DC: dc] server = new Server(); initialized = True;
}
Bool request (Int cost) {await initialized;Fut<Unit> r = server!process(cost); await r?; return (durationValue(deadline()) > 0);
}}
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 12 / 22
Page 14
A Resource-Aware Application in ABS
interface CalcServer {Unit process(Int cost);DC getDC();
}class Server implements CalcServer {Unit process(Int cost) { [Cost: cost] skip; }DC getDC() { return thisDC(); }
}interface ApplicationServer {Bool request(Int cost);
}
ApplicationServer
DC4DC3
CalcServerDC2
CalcServer
DC1
CalcServer
AppWorkflow
CloudProvider
Invoke task
# of VMTotal Cost
Application Server =
Application Workflow +
Application Resource Management(load balancing, scalability)
CalcServer =
Independent tasks(can be parallelized)
AppRM
class DynamicBalancer(CloudProvider provider) implements ApplicationServer {Map<Int, Set<Server>> sleepingMachines = EmptyMap;Int machineStartTime = ... // a constant representing the time it takes to start a machine;
Bool request (Int cost) {Int requiredResources = (cost / durationValue(deadline())) + 1 + machineStartTime;Server server = this.getMachine(requiredResources);Fut<Unit> r = server!process(cost); await r?;this.dropMachine(server); return durationValue(deadline()) > 0;
}
Server getMachine(Int size) { ... } // take machine of size if it exists, otherwise create one
Unit dropMachine(Server server) { ...}}
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 12 / 22
Page 15
Rapid Prototyping: Simulation Results
I Define client behaviorto model a load spike
timeIncrease the # of requests
I Simulate the di↵erent scenarios with ABS simulator
User scenario
Load spikeStrategy QoS Total CostConstant balancer 53% 200As-needed balancer 100% 128
I QoS: measure the successful requests (i.e., requests completed withinthe deadline) divided by the total number of requests
I Total Cost: measures the accumulated sum of CPU resources madeavailable by the cloud provider.
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 13 / 22
Page 16
Case Study: Montage (1)
Montage is a toolkit for assembling astronomicalimages into customized mosaics
mProject
mProjExec
mImgtbl mOverlaps
mDiffExec
mDiff
mFitExec
mFitplane
mBgModel
mBackground
mBgExec
mAdd
Re-project Image
Background modeling
Backgroundmatching
Final mosaic
Partly ordered workflow and highly parallelizable tasks.
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 14 / 22
Page 17
Case Study: Montage (2)
DC4DC3
CalcServerDC2
CalcServer
DC1
CalcServer
CloudProvider
Invoke task
ApplicationServer =
AppWorkflow + AppRM
CalcServer =
Independent tasks
# of VMTotal Cost
ApplicationServer
AppWorkflow
AppRM
Model the Montage toolkit using the Cloud Provider API, run simulationsvarying the di↵erent deployment scenario and compare the results.
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 15 / 22
Page 18
Case Study: Montage (3)
Cost vs. Time Tradeo↵: can we reproduce the resultsof other informal cloud simulation tools (GridSim)?
!"
!#"
!##"
!###"
!####"
!" $" %" &" !'" ($" '%" !$&"
!"
#$"
$!"
%$"
&!!"
&" #" '" (" &)" *#" )'" &#("Lo
garit
hmic
sca
le
60 cents for 1 processor
Loga
rithm
ic s
cale
approx 4 $ for 128 processors
approx 5.5 hrs for 1 processor
approx 18 min for 128 processors
432270
1152
CPU
Cos
t
89
28
Tim
e
The cost of doing science on the cloud: The Montage example.E. Deelman, G. Singh, M. Livny, G. B. Berriman, and J. Good. (SC’08), pages 1–12. IEEE/ACM, 2008.
Johnsen, Schlatte, Tapia Tarifa. Modeling Resource-Aware Virtualized Applications for the
Cloud in Real-Time ABS. Proc. ICFEM 2012
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 16 / 22
Page 19
Case Study: Fredhopper Replication Server (1)
The Fredhopper Access Server (FAS) is a distributed, concurrent OOsystem providing search and merchandising services to e-Commercecompanies. The Replication Server is one part of FAS.
Acceptor
Cloud Provider
ClientJob
ClientJob
ClientJob
SyncClient
job(schedule)
SyncClient
SyncClient
... ...
LIVE STAGING
SyncServer create()
CLOUD
DC4
ConnectionThread
getConnection(schedule)
getConnection(schedule)
getConnection(schedule)
job(schedule)
job(schedule)
DC3
ConnectionThread
replication
DC2
ConnectionThread
replication
DC1
ConnectionThread
replication
I Very detailed model: consists of 5000 lines of ABS
Albert, de Boer, Hahnle, Johnsen, Schlatte, Tapia Tarifa, Wong.
Formal modeling and analysis of resource management for cloud architectures: an industrial
case study using Real-Time ABS. Service Oriented Computing and Applications 8(4), 2014
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 17 / 22
Page 20
Case Study: Fredhopper Replication Server (2)
How does the accumulated cost in our modelcompare to the actual Java implementation?
0
17.5
35
52.5
70
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 200
7500
15000
22500
30000
Runn
ing
time
[s]
Environments
Sim
ulat
ion
cost
Model simulation cost Implementation running time
Measured execution time of the implementation (left scale)
Accumulated cost of the simulation (right scale)
The deviation roughly seems to correspond to the start-up time of JVM
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 18 / 22
Page 21
Case Study: Hadoop YARN Clusters (1)
Open-source software framework thatimplements a cluster managementtechnology for distributed processing.
Popular cloud frameworkfor big data processing:
I Resource allocation
I Code distribution
I Distributed data processing
Lin, Yu, Johnsen, Lee. ABS-YARN: A Formal Frameworkfor Modeling Hadoop YARN Clusters. Proc. FASE 2016
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 19 / 22
Page 22
Case Study: Hadoop YARN Clusters (2)
How does the ABS YARN compare to the actual YARN implementation?
(a) The normalized starting time (b) The normalized finish time
(c) Cumulative completed jobs (d) Total number of completed jobs
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 20 / 22
Page 23
The ABS Collaboratory
I ABS as a web service, with documentation and examplesunder development at http://www.abs-models.org
I Tools are open source: https://github.com/abstoolsI ABS API available for orchestration of Java codeI Eclipse plug-in for ABS
Get involved!
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 21 / 22
Page 24
Summary
Virtualization requires novel modeling abstractionsExecutable models, deployment components, reflection
ABS: Abstract Behavioral Specification
I Model deployed services with dynamic resource management
I High-level abstractions of low-level platform-specific concerns
I Analysis methods: performance, cost analysis, deadlock analysis, . . .
I More info and open source tools:www.abs-models.org
Make your deployment decisions at design time!ABS permits concise modeling and accurate prediction
Engineering Virtualized Services[www.envisage-project.eu]
Einar Broch Johnsen (UiO) Designing Resource-Aware Applications iFMCloud, 04.06.2016 22 / 22