Upload
petabridge
View
601
Download
0
Embed Size (px)
Citation preview
@petabridge Petabridge.com
www.baynetug.org
Concurrency, Without the Pain: An Intro to Akka.NET
& the Actor Model with Andrew Skotzko
@petabridge Petabridge.com
• www.baynetug.org • @baynetug / #BayNetUG • An open and independent forum for evaluating and
extending knowledge of .NET architecture, technologies, tools and business applications
• Monthly events (technical, business, networking) – Mountain View, San Francisco, Berkeley
• Working groups
Bay.NET User Group
@petabridge Petabridge.com
.NET Community
San Francisco SQL Server User Group meetup.com/The-San-Francisco-SQL-Server-Meetup-Group
Azure Developers www.bayazure.org
San Francisco F# h"p://www.meetup.com/sfsharp/
@petabridge Petabridge.com
Coming Soon
• San Francisco: Hello DocumentDB – Tuesday, September 15th – Microsoft, 555 California St
• SouthBay.Net: Unit Testing Makes Me Faster: 8/27 – German International School of SV
• Silicon Valley Code Camp: 10/3-4
– Evergreen Valley College
@petabridge Petabridge.com
Concurrency Without the Pain
An Intro to Akka.NET & Actor Model
#AkkaDotNet @ #BayNetUG
Andrew Skotzko Co-‐founder — Petabridge
@petabridge Petabridge.com
Why should we care about
concurrency?
@petabridge Petabridge.com
1970 -‐ 2005
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
TANSTAAFL “There ain’t no such thing as a free lunch.” —R. A. Heinlein, The Moon Is a Harsh Mistress
@petabridge Petabridge.com
What the hell are you talking about?
@petabridge Petabridge.com
Concurrency.
We needs it.
@petabridge Petabridge.com
So why is this hard?
@petabridge Petabridge.com
How to Write Multithreaded Code
@petabridge Petabridge.com
Shared State Programming Sucks (Illustrated)
@petabridge Petabridge.com
Random?
• .NET 4.0: TPL (2010) • .NET 4.5: async/await (2012)
@petabridge Petabridge.com
Is there a better way? THERE MUST BE! THERE. MUST. BE. A. BETTER. WAY!
@petabridge Petabridge.com
Warning! Mind Blowingly Different
Programming Style Ahead!
@petabridge Petabridge.com
Warning! Mind Blowingly Different Programming Style Ahead!
@petabridge Petabridge.com
The Actor Model
@petabridge Petabridge.com
What is the actor model?
@petabridge Petabridge.com
Everything is an actor.
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
3 Core Abilities
1. Send messages 2. Create other actors 3. Change behavior
@petabridge Petabridge.com
Messages
@petabridge Petabridge.com
Actors work by passing each other messages
@petabridge Petabridge.com
Message passing in action
@petabridge Petabridge.com
BUZZWORD BINGO!
@petabridge Petabridge.com
Example Akka.NET Message
@petabridge Petabridge.com
Actors send messages to addresses
@petabridge Petabridge.com
Actor addresses have location transparency
@petabridge Petabridge.com
Which means…
@petabridge Petabridge.com
@petabridge Petabridge.com
@petabridge Petabridge.com
ReactiveManifesto.org
@petabridge Petabridge.com
What is Akka.NET?
@petabridge Petabridge.com
Battle-Tested (JVM)
@petabridge Petabridge.com
This is an actor
@petabridge Petabridge.com
These are messages
@petabridge Petabridge.com
Actors run on threads
@petabridge Petabridge.com
Actors are lazy
@petabridge Petabridge.com
Process messages one at a time
@petabridge Petabridge.com
The circle of life
@petabridge Petabridge.com
@petabridge Petabridge.com
Hierarchies
@petabridge Petabridge.com
Supervision
@petabridge Petabridge.com
Switchable Behavior
@petabridge Petabridge.com
And Can Form Highly Available Systems
@petabridge Petabridge.com
What’s this give me?
@petabridge Petabridge.com
Where can I use this? • Analytics systems • Marketing automation • Multi-player games • Device / IoT tracking • Alerting & monitoring systems • Recommendation engines • Dynamic pricing • Microservices • Reactive UI
@petabridge Petabridge.com
DEMO
@petabridge Petabridge.com
hZp://LearnAkka.net
@petabridge Petabridge.com
Hierarchies pt. deux
@petabridge Petabridge.com
Character Actor Pattern
@petabridge Petabridge.com
ActorSelection == selection by address
@petabridge Petabridge.com
Actor lifecycle
@petabridge Petabridge.com
Actor lifecycle