SlideShare a Scribd company logo
1 of 26
Akka.NET: Concurrency without
the Pain
By Aaron Stannard,
Founder, Akka.NET
CEO, Petabridge
Modern CPUs: More Cores!
Source: Karl Rupp https://www.karlrupp.net/2018/02/42-years-of-microprocessor-trend-data/
Modern Software: Concurrent
• Can’t take advantage of multi-core
architectures without multi-threaded or
multi-process (concurrent) application
designs
• Industry best practices increasingly push
language and API designs to drive this:
– Task and Parallelism Library (TPL)
– Async / Await
– More native async APIs in standard and third
party libraries
Concurrent Programming is
Hard
How to Write Concurrent
Software
Shared State is Tricky
Enter the Actor Model
Actor Model Origins
• Originally conceived in
1973 to build large, multi-
core applications.
• First implemented in 1986
by Ericsson. Powers
modern day GPRS, 3G,
and LTE cell networks.
• Later adopted by Internet
giants.
• Made popular again by
cloud computing.
Actor Model Core Concepts
What is an Actor?
Actors
• Actors are independent micro-processes.
• They are cheap, disposable, units of work.
• Each has its own state and resources that
can’t be shared or directly accessed from
the outside.
• They work by sending and processing
immutable messages to each other.
Actors Process One
Message at a Time
Processes Usually Contain
Many Actors
Parent Actors Supervise
Children
How Actors Make Concurrent
Programming Easier
• Since actor state is private and can only be modified
serially, it’s automatically thread-safe
– No locks, critical regions, or synchronization
mechanisms needed
• Actors process messages asynchronously
– Lots of actors can process messages simultaneously
– Scale up to take advantage of multiple CPUs
automatically
• Robust fault-handling model
– Parents supervise child failures
– Faults isolated to failing actor only
– Actor restarts are transparent and “not a big deal”
Akka.NET: Actor Model for .NET
Actor Syntax
IActorRef – Actor References
Actor References are
Location Transparent
• IActorRef can point to
local actor (in-
memory messaging.)
• IActorRef can point to
actor running in
another remote
process (TCP
messaging.)
• You don’t need to
explicitly know or care
which is which.
But Actors Still
Have Explicit Addresses
Demo
Akka.Remote Chat Example
https://github.com/akkadotnet/akka.net
Akka.NET Modules
• Akka – core actor library
• Akka.Remote – cross-node actor deployment /
communication
• Akka.Cluster – elastic actor networks (HA)
• Akka.Persistence – event-sourcing, durable actor state &
recovery
• Akka.Streams – streaming workflows
• Akka.Cluster.Tools – cluster singleton, distributed pub
sub
• Akka.Cluster.Sharding – durable state partitioning
• Akka.DData – eventually consistent data replication
When to Use Actors (Generally)
• Building stateful applications:
– Applications that can’t be built reliably using a
database as the sole source of truth.
– Examples: real-time applications, IOT, trading,
monitoring, marketing automation, large-scale
data analysis.
• Building highly fault-tolerant applications.
• Just need better concurrency tools in non-
distributed applications.
Where to Learn More
• http://learnakka.net – Akka.NET bootcamp
• http://getakka.net/ - Official website
• https://petabridge.com/ - Blog and tutorials

More Related Content

More from petabridge

More from petabridge (13)

We're all distributed systems devs now: a crash course in distributed program...
We're all distributed systems devs now: a crash course in distributed program...We're all distributed systems devs now: a crash course in distributed program...
We're all distributed systems devs now: a crash course in distributed program...
 
The New .NET Enterprise Stack
The New .NET Enterprise StackThe New .NET Enterprise Stack
The New .NET Enterprise Stack
 
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET ActorsFull-Stack, Message-oriented Programming w/ Akka.NET Actors
Full-Stack, Message-oriented Programming w/ Akka.NET Actors
 
OSS From the Outside In - A Personal Journey With Akka.NET
OSS From the Outside In - A Personal Journey With Akka.NETOSS From the Outside In - A Personal Journey With Akka.NET
OSS From the Outside In - A Personal Journey With Akka.NET
 
Concurrency, Without the Pain: An Intro to Akka.NET @ Bay.NET
Concurrency, Without the Pain: An Intro to Akka.NET @ Bay.NETConcurrency, Without the Pain: An Intro to Akka.NET @ Bay.NET
Concurrency, Without the Pain: An Intro to Akka.NET @ Bay.NET
 
Syncromatics Akka.NET Case Study
Syncromatics Akka.NET Case StudySyncromatics Akka.NET Case Study
Syncromatics Akka.NET Case Study
 
Akka.NET @ London.NET
Akka.NET @ London.NETAkka.NET @ London.NET
Akka.NET @ London.NET
 
Akka.NET Fundamentals — #ProgNet15
Akka.NET Fundamentals — #ProgNet15Akka.NET Fundamentals — #ProgNet15
Akka.NET Fundamentals — #ProgNet15
 
Slides - Intro to Akka.Cluster
Slides - Intro to Akka.ClusterSlides - Intro to Akka.Cluster
Slides - Intro to Akka.Cluster
 
Akka.NET: Concurrency Without the Pain (Intro to the Actor Model)
Akka.NET: Concurrency Without the Pain (Intro to the Actor Model)Akka.NET: Concurrency Without the Pain (Intro to the Actor Model)
Akka.NET: Concurrency Without the Pain (Intro to the Actor Model)
 
Distributed Transactions in Akka.NET
Distributed Transactions in Akka.NETDistributed Transactions in Akka.NET
Distributed Transactions in Akka.NET
 
Streaming ETL With Akka.NET
Streaming ETL With Akka.NETStreaming ETL With Akka.NET
Streaming ETL With Akka.NET
 
2 12-2015 - Cassandra Day LA - Using DataStax Enterprise and Actor Systems fo...
2 12-2015 - Cassandra Day LA - Using DataStax Enterprise and Actor Systems fo...2 12-2015 - Cassandra Day LA - Using DataStax Enterprise and Actor Systems fo...
2 12-2015 - Cassandra Day LA - Using DataStax Enterprise and Actor Systems fo...
 

Recently uploaded

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 

Recently uploaded (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 

Akka.NET Concurrency Without the Pain

  • 1. Akka.NET: Concurrency without the Pain By Aaron Stannard, Founder, Akka.NET CEO, Petabridge
  • 2. Modern CPUs: More Cores! Source: Karl Rupp https://www.karlrupp.net/2018/02/42-years-of-microprocessor-trend-data/
  • 3. Modern Software: Concurrent • Can’t take advantage of multi-core architectures without multi-threaded or multi-process (concurrent) application designs • Industry best practices increasingly push language and API designs to drive this: – Task and Parallelism Library (TPL) – Async / Await – More native async APIs in standard and third party libraries
  • 5. How to Write Concurrent Software
  • 8. Actor Model Origins • Originally conceived in 1973 to build large, multi- core applications. • First implemented in 1986 by Ericsson. Powers modern day GPRS, 3G, and LTE cell networks. • Later adopted by Internet giants. • Made popular again by cloud computing.
  • 9. Actor Model Core Concepts
  • 10. What is an Actor?
  • 11. Actors • Actors are independent micro-processes. • They are cheap, disposable, units of work. • Each has its own state and resources that can’t be shared or directly accessed from the outside. • They work by sending and processing immutable messages to each other.
  • 15. How Actors Make Concurrent Programming Easier • Since actor state is private and can only be modified serially, it’s automatically thread-safe – No locks, critical regions, or synchronization mechanisms needed • Actors process messages asynchronously – Lots of actors can process messages simultaneously – Scale up to take advantage of multiple CPUs automatically • Robust fault-handling model – Parents supervise child failures – Faults isolated to failing actor only – Actor restarts are transparent and “not a big deal”
  • 18. IActorRef – Actor References
  • 19.
  • 20.
  • 21. Actor References are Location Transparent • IActorRef can point to local actor (in- memory messaging.) • IActorRef can point to actor running in another remote process (TCP messaging.) • You don’t need to explicitly know or care which is which.
  • 22. But Actors Still Have Explicit Addresses
  • 24. Akka.NET Modules • Akka – core actor library • Akka.Remote – cross-node actor deployment / communication • Akka.Cluster – elastic actor networks (HA) • Akka.Persistence – event-sourcing, durable actor state & recovery • Akka.Streams – streaming workflows • Akka.Cluster.Tools – cluster singleton, distributed pub sub • Akka.Cluster.Sharding – durable state partitioning • Akka.DData – eventually consistent data replication
  • 25. When to Use Actors (Generally) • Building stateful applications: – Applications that can’t be built reliably using a database as the sole source of truth. – Examples: real-time applications, IOT, trading, monitoring, marketing automation, large-scale data analysis. • Building highly fault-tolerant applications. • Just need better concurrency tools in non- distributed applications.
  • 26. Where to Learn More • http://learnakka.net – Akka.NET bootcamp • http://getakka.net/ - Official website • https://petabridge.com/ - Blog and tutorials