1 / 53

F# in the cloud

F# in the cloud. The present and the future. George Stavroulakis and Gian Ntzik Nessos Information Technologies – M-Brace team. About us. Nessos IT S.A. – M-Brace team F# runtime/framework for developing cloud apps Distributed computations Distributed data Messaging. Outline.

jaeger
Download Presentation

F# in the cloud

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. F# in the cloud The present and the future George Stavroulakisand GianNtzik Nessos Information Technologies – M-Brace team

  2. About us • Nessos IT S.A. – M-Brace team • F# runtime/framework for developing cloud apps • Distributed computations • Distributed data • Messaging

  3. Outline • The cloud • Windows Azure • The present • F# and Azure • Actors / Agents • Distributed actors • The future • M-Brace http://www.microsoft.com/ windowsazure/sdk/

  4. The cloud • Perception of the cloud’s notion varies • Remote storage (eg: Hotmail, Skydrive, etc.) • Software running out-of-premise • Hardware operating out-of-premise • Mobile devices services (eg: iTunes, App store, etc.) • Essence of the cloud The cloud is a pool of shared resources where hardware, software, and information are provided as a service/utility over a network (typically the internet).

  5. The cloud • Combines and extends the concepts of: • Virtualization • Service-oriented architecture • Location-independent computing • Gives access to compute resources • Eliminates maintenance costs • Pay-as-you-go cost model • Features elasticity

  6. The cloud • IaaS: Infrastructure as a Service • On-demand servers with compute, storage and network resources. • Amazon EC2, VMWarevCloud • PaaS: Platform as a Service • On-demand application-hosting environment • Windows Azure, Google AppEngine, Salesforce.com • SaaS: Software as a Service • On-demand applications • Hotmail, Office 365, iTunes

  7. The cloud

  8. Windows Azure • Windows Azure is Microsoft’s cloud OS • Abstracts data center hardware details • Handles resource management, provisioning & monitoring • Manages application lifecycle • Allows developers to concentrate on business logic • Provides compute, storage and network resources • Virtualized storage, compute and network • Illusion of boundless resources • Provides common distributed app infrastructure • Queuing, key-value storage, SQL storage • Application services (access control, connectivity, etc)

  9. Windows Azure

  10. Windows Azure • Windows Azure service model: Apps as services • Definition information • Configuration information • Comprised of at least one role • Roles • Collection of code modules with an entry point, running on virtual machines • Web role: IIS7 and ASP.NET in Windows Azure • Worker role: Arbitrary code in Windows Azure • VM role: User supplied VHD with custom OS

  11. Windows Azure

  12. Windows Azure • Cloud application composition • Front end: Load-balanced stateless web servers • Middle worker tier: Order processing, encoding, etc. • Backend storage: SQL tables, files, BLOB storage Multiple instances of each for scalability and availability

  13. Windows Azure An Azure “Hello World” in F# www.m-brace.net/SkillsMatter/AzureExercises.zip

  14. Windows Azure

  15. Windows Azure

  16. Windows Azure

  17. Windows Azure • Sockets (TCP/IP) • Connection mechanism for inter-role (internal) and client-to-service (input) communication • Cloud queues • Queuing mechanism separated from running instances and available to all of them

  18. Windows Azure

  19. Windows Azure • CloudQueue • AddMessage: CloudQueueMessage-> int • DeleteMessage: CloudQueueMessage -> int • GetMessage: unit -> CloudQueueMessage

  20. The present • Visual Studio integrated with Windows Azure • Support for web and worker role development • Support for C# and VB • F# support for worker roles • Extended code repository from Microsoft • Mainly for C# and VB • Focused on: • Web roles • SQL Azure, ESB and other LOB technologies

  21. The present Big data and distributed computing solutions • Microsoft • Linq-To-HPC (DryadLinq) • Project Daytona • Microsoft Orleans • Others (Java, Scala, Ruby, PHP, Python, etc) • Akka • Gridgain • Hadoop • Heroku

  22. F# and Azure • Distributed algorithms: NOT easy to deal with • MSDN Map-reduce sample in F# • No real distributed implementation http://msdn.microsoft.com/en-us/magazine/gg983490.aspx • MSDN F# for Azure repository http://archive.msdn.microsoft.com/fsharpazure

  23. F# and Azure • F# vs. C# and VB • Expressiveness: maximizes source code density • Immutability: promotes statelessness • Function composition: leverages modularity • Monadic structures: facilitate the construction of problem specific DSLs • Rich language features • Asynchronous workflows (Async monad) • Agents (Mailbox processors) • List comprehensions • etc…

  24. Actors / Agents • F# MailboxProcessor • Used for Agents/Actors • Isolated (sequential) computation units • Communicate by exchanging messages • Message passing concurrency • A widely adopted paradigm for distributed computing

  25. Actors / Agents • Properties • No shared resources: state is actor-specific and internal • Impossible to corrupt data due to race conditions • Resource locking is unnecessary: no livelocks or deadlocks • Actor computations are sequential in nature • Can be applied as-is in distributed environments

  26. Distributed actors • F# MailboxProcessor • only shared memory message passing • Nessos.MBrace.Actors • A mini distributed actor framework • Distribution challenges • Support for different communication protocols • Locality transparent actor reference • Service-wide addressing scheme • Scheduling and balancing

  27. Distributed actors • Design decisions • Programming model similar to MailboxProcessor • Separation of concerns • Protocol, Actor,ActorRef TCP/IP Protocol Azure Queue Protocol In memory protocol ActorRef Actor

  28. Distributed actors

  29. Distributed actors • Challenges • Express computation workflows => FSM • Deployment and monitoring • Fault tolerance Actor Actor Actor Actor Actor Actor Actor Actor Actor Actor Actor Actor

  30. Distributed actors • Application logic fragmentation • Considerations beyond application’s function • Messages • Actor granularity • Fault tolerance: re-application of state • Code noise • Code maintenance • Updating • Debugging

  31. The future • Greater level of abstraction • Hide cloud platform details • Programming model that looks sequential but executes distributed • async { } • … • cloud { }

  32. The future • RunRemoteSynchronously() would send the quotation to the runtime for execution. • askDeepThought()would be executed somewhere in the runtime’s cloud based worker pool. [<Cloud>] let askDeepThought () = cloud { return “42” } let answer = Cloud.RunRemoteSynchronously<@ askDeepThought() @>

  33. M-Brace What is M-Brace? • 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 Embrace the cloud

  34. M-Brace What is NOT M-Brace? • 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 Embrace the cloud

  35. M-Brace overview Distributed computations Distributed data Messaging

  36. M-Brace 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

  37. M-Brace The M-Brace runtime • Process and data flow orchestration between nodes • Constant supervision and monitoring • Process execution • Node environment state • Resource allocation and usage • per node (CPU, network, etc.)

  38. M-Brace The M-Brace runtime • Automated distribution of code and state upon failure • Hot code swapping • On-demand tracing and logging • Optimizes code on runtime based • on real-time resources metrics

  39. M-Brace 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 3rd party frameworks or tools needed

  40. M-Brace Uses and applications • High performance computing • Simulation and engineering • Computational finance • Bio-engineering • Weather forecasting • DSP and imaging

  41. M-Brace 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, large e-shops • Messaging systems

  42. Cloud Monad [<Cloud>] let askDeepThought () = cloud { return “42” } let answer = Cloud.RunRemoteSynchronously <@ askDeepThought() @> Cloud storage code+state code+state Workers Workers M-Brace runtime

  43. Cloud Monad - Composition [<Cloud>] let askDeepThought () = cloud { return “42” } [<Cloud>] let getUltimateQuestionAnswer () = cloud { let! firstTime = askDeepThought () let! secondTime = askDeepThought () return sprintf “%s and %s !” firstTimesecondTime } let result = Cloud.RunRemoteSynchronously <@ getUltimateQuestionAnswer() @>

  44. Cloud Monad - Composition • getUltimateQuestionAnswer() begins execution in some worker let askDeepThought () = cloud { return “42” } let getUltimateQuestionAnswer () = cloud { let! firstTime = askDeepThought () let! secondTime = askDeepThought () return sprintf “%s and %s !” firstTimesecondTime } 1

  45. Cloud Monad - Composition • on let!,askDeepThought() begins execution (in some other worker) • Execution of getUltimateQuestionAnswer() is suspended until the result is received let askDeepThought () = cloud { return “42” } let getUltimateQuestionAnswer () = cloud { let!firstTime = askDeepThought() let! secondTime = askDeepThought () return sprintf “%s and %s !” firstTimesecondTime } 1 2

  46. Cloud Monad - Composition • The returned result is bound to firstTime • The rest of computation continues (until the second let!) 2 let askDeepThought () = cloud {return “42” } let getUltimateQuestionAnswer () = cloud { let!firstTime= askDeepThought() let! secondTime = askDeepThought () return sprintf “%s and %s !” firstTimesecondTime } 1 3

  47. Cloud Monad – Parallel Composition 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[]>

  48. Demo • 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

  49. Some code Map-reduce user function Splits a list in two halves Cloud-parallel combinator

  50. Some code Mapping: Download files and count words Download text from web string -> ICloud<(string*int) list>

More Related