Embrace the cloud

basiliskcanoeSoftware and s/w Development

Nov 2, 2013 (4 years and 2 months ago)

96 views

Embrace the cloud


About us


Cloud computing challenges


Current cloud computing practices


M
-
Brace overview


Programming with M
-
Brace


Code examples


Concluding remarks


George
Stavroulakis


Executive consultant at
Nessos

IT S.A.


Ph.D

student at NTUA in HPC and FEM


M
-
Brace testing, quality assurance and project management


Gian

Ntzik


R&D assistant developer at
Nessos

IT S.A.


Ph.D

student at Imperial College in Program Reasoning and
Verification


M
-
Brace development



ISV company active in custom software development


Technology specialization


Microsoft .NET framework and F#


Silverlight


NHibernate


Business specialization


Business process management


GIS


Application framework development

The world then…


Single core


Global memory


Single node


Sequential code


The world then…


Upfront investments in hardware


Scale up



Code performance is irrelevant

to running costs


Programs speed
-
up with increase of CPU clock
speed




The world now…


Multi
-
core


Distributed memory


Multi node


Parallel code


The world now…


Ad
-
hoc elasticity demands
with respect to current needs


Scale out



Code performance directly affects c
osts


“The free lunch is over”





Cloud providers: Microsoft Azure, Amazon EC2, …


Reduces infrastructure costs


Allocate as many machines you need. All you need is a credit
card.


Challenges:


Different programming model


Machine failure


Code maintenance
-

versioning


Performance: The cloud equates performance to money



Different programming model


Distributed
computing


Message Passing


Today’s best practices / patterns


Map


reduce


Distributed agents

Computation

Input Files

Map phase

Intermediate results file

Reduce phase

Map phase

Reduce phase

Output Files


Programming Primitives


Map function


Reduce function


Limited applicability


Concerns beyond the program’s function


Partition function


hashing


Input


output: key
-
values, read/write from (distributed) file system


NOT proper map / reduce function semantics


map/reduce are higher order function with a standard signature


map: (‘T
-
> ‘U)
-
>
seq
<‘T>
-
>
seq
<‘U>


reduce: (‘T
-
> ‘T
-
> ‘T)
-
>
seq
<‘T>
-
> ‘T


Message Passing


Agents accept messages
-
> perform computations
-
>
modify state

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent


Challenges


Express computation workflows => FSM


Deployment, Monitoring


Fault tolerance

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent

Agent


Application logic is broken to many pieces


Considerations beyond application’s function


Messages


Agent granularity


Fault tolerance: reapplication of state


Code noise


Code maintenance


Updating


Debugging

What is M
-
Brace?

Embrace the cloud


Software stack comprised of:


Framework

with libraries, tools and patterns


Runtime

for deploying, running and managing cloud apps


Based on the .NET framework


Leverages the power of the F# language



What is
NOT

M
-
Brace?

Embrace the cloud


Just an API or another library


A new language


A compiler
-
specific language extension (like PG
-
Fortran)


Just a set of tools or in need of 3rd party tools




Building blocks for cloud
-
based distributed
computations


Cloud Monad: cloud { … }


F# computation expressions


Similar to Asynchronous Workflows

(
Async

Monad)

let
getWebResponse

(
url
: string) =


async

{


let request =
WebRequest.Create(url
)


let! response =
req.AsyncGetResponse
()


return
response.GetResponseStream
()


}


WebRequest.AsyncGetResponse
:

unit
-
>
Async
<
WebResponse
>

getWebResponse

: string
-
>
Async
<Stream>


let stream =
getWebResponse

"
http://www.m
-
brace.net
" |>
Async.RunSynchronously


.NET Thread Pool

Thread Pool

Task

Active Thread

SuspendedThread

let
getWebResponse

(
url
: string) =


async

{


let request =
WebRequest.Create(url
)


let! response =
req.AsyncGetResponse
()


return
response.GetResponseStream
()


}


1


getWebResponse
()

is executed
in as a thread pool task


let
getWebResponse

(
url
: string) =


async

{


let request =
WebRequest.Create(url
)


let!

response =
req.AsyncGetResponse
()


return
response.GetResponseStream
()


}


2


async

{ … }

of
getWebResponse
()

is executed
as a thread pool task


async

{ … } of
AsyncGetResponse
()

is executed as a thread pool task.
The outer
async

{ … } is suspended until the result is available.


1

let
getWebResponse

(
url
: string) =


async

{


let request =
WebRequest.Create(url
)


let!

response
=
req.AsyncGetResponse
()


return
response.GetResponseStream
()


}


3


async

{ … }

of
getWebResponse
()

is executed
as a thread pool task


async

{ … } of
AsyncGetResponse
()

is executed as a thread pool task.
The outer
async

{ … } is suspended until the result is available.


The result is bound to
response

and the
async

{ … } continues.


1

2


cloud { … }


Programming primitive


Unit of distribution, execution & scheduling


Anything inside cloud { … } will be executed (somewhere) in
the Cloud


Composition (monadic)


Sequential


Parallel


Somewhere in the cloud, Deep Though will compute the answer


The function does not return a value, but a computation

let
askDeepThought

() = cloud { return “42” }


askDeepThought
: unit
-
>
ICloud
<string>

[<Cloud>]

let
askDeepThought

() = cloud { return “42” }


let answer =
Cloud.RunRemoteSynchronously

<@
askDeepThought
() @>


RunRemoteSynchronously
()
sends the quotation to the runtime for
execution.


askDeepThought

()

will be executed somewhere in the runtime’s
cloud based worker pool.


[<Cloud>]

let
askDeepThought

() = cloud { return “42” }


let answer =
Cloud.RunRemoteSynchronously

<@
askDeepThought
() @>


Cloud storage

M
-
Brace runtime

Workers

Workers

code+state

code+state

[<Cloud>]

let
askDeepThought

() = cloud { return “42” }


[<Cloud>]

let
getUltimateQuestionAnswer

() =


cloud {


let!
firstTime

=
askDeepThought

()


let!
secondTime

=
askDeepThought

()



return
sprintf

“%
s

and %
s

!”
firstTime

secondTime


}


let result =
Cloud.RunRemoteSynchronously

<@
getUltimateQuestionAnswer

() @>

let
askDeepThought

() = cloud { return “42” }


let
getUltimateQuestionAnswer

() =


cloud {


let!
firstTime

=
askDeepThought

()


let!
secondTime

=
askDeepThought

()



return
sprintf

“%
s

and %
s

!”
firstTime

secondTime


}



getUltimateQuestionAnswer
()

begins execution in some worker

1

let
askDeepThought

() =
cloud {

return “42”
}



let
getUltimateQuestionAnswer

() =


cloud {


let!

firstTime

=
askDeepThought

()


let!
secondTime

=
askDeepThought

()



return
sprintf

“%
s

and %
s

!”
firstTime

secondTime


}



on
let!
,

askDeepThought

()
begins execution (in some other worker)


Execution of
getUltimateQuestionAnswer
()
is suspended until the
result is received


1

2

let
askDeepThought

() =
cloud {

return

“42”
}



let
getUltimateQuestionAnswer

() =


cloud {


let!

firstTime

=
askDeepThought

()


let!
secondTime

=
askDeepThought

()



return
sprintf

“%
s

and %
s

!”
firstTime

secondTime


}



The returned result is bound to
firstTime


The rest of computation continues (until the second let!)

1

2

3

let
pDeepThought

() =


cloud {


let! (first, second) =
askDeepThought
()
<||>

askDeepThought
()


return
sprintf

“%
s

and %
s

!” first second


}

(<||>) :
ICloud
<‘T>
-
>
ICloud
<‘U>
-
>
ICloud
<‘T * ‘U>

let
pDeepThought

() =


cloud {


let! results =
Cloud.Parallel

[|
askDeepThought

();
askDeepThought
() |]


return
sprintf

“%
s

and %
s

!” (results.[0]) (results.[1])


}

Cloud.Parallel
:
ICloud
<‘T> []
-
>
ICloud
<‘T[]>


A data mining example: Count word occurrences in
the work of Shakespeare


Use a distributed map


reduce


map: download text and tokenize to words


reduce: count occurrences of each word


Power of cloud { } composition:


We can define a higher order cloud { } map


reduce
combinator


Splits a list in two halves

Cloud
-
parallel
combinator



Mapping:

Download files and count words

Download text from web

string
-
>
ICloud
<(string*
int
) list>

Reduction:

Collapse lists and aggregate

(string*
int
) list
-
> (string*
int
) list
-
>
ICloud
<(string*
int
) list>

The M
-
Brace framework


Easy and transparent

cloud programming


Single
-
source code authoring


Unification of distributed

and shared memory paradigms


Single

node execution and debugging



The M
-
Brace runtime


Process and data

flow orchestration between nodes


Constant supervision and monitoring


Process execution


Node e
nvironment

state


Resource allocation and usage


per node (CPU, network, etc.)


Automated distribution of code


and state upon failure







Why M
-
Brace?


Distribution and orchestration has compositional
properties, based on computation expressions


Conceptual model is simple


Lightweight and transparent


Underlying cloud services are abstracted


Based on managed code


Solely based on F# concepts and architecture


No 3
rd

party frameworks or tools needed








Uses and applications


High performance computing


Simulation and

engineering


Computational finance


Bio
-
engineering


Weather

forecasting


DSP and imaging








Uses and applications


Map
-
reduce algorithms


Data mining and

large data manipulation


Web crawling and graph traversal


Document clustering and inverted index building




Large
-
scale web applications


Social

networks and large e
-
shops


Messaging systems







Distributed computations


Exception management


Fault tolerance


Local testing and debugging


Windows Azure implementation


Distributed data


Messaging


Hot code swapping


On
-
demand tracing and logging


Distributed computation run
-
time


optimizations


Support for more cloud platforms





Opinions and feedback from the F# community


Usage and testing on real
-
life scenarios


Funding and/or investors to:


Accelerate development


Expand and specialize to the needs of specific markets

www.m
-
brace.net