SlideShare uma empresa Scribd logo
1 de 27
Baixar para ler offline
Simplifying concurrency: Actors
In particular, AKKA
KRISTO IILA, ENGINEERING MANAGER
PLANET OS - MARCH 2016
The Many Ways of Concurrency
• Multithreading / semaphores / locking / mutexes
• Lock-free data structures
• Software Transactional Memory
• Message passing
• Futures / Async
• Actors
PLANET OS - MARCH 2016
What are Actors?
• Lightweight object
• No shared state
• Communication via message passing
• Supervision hierarchies
• Originally implemented in Erlang 

(high availability telephone switches)
• Don’t need to think in terms of threads and locks
• Distributable by design
PLANET OS - MARCH 2016
An Actor System Implementation - AKKA
• Implements actor model
• Makes remoting seamless
• Works with Java, Scala and .net
• Fits very well with scala
• Automatically scheduled to threads
• Can have multiple thread pools
Actor A Mailbox
Actor B
Message
PLANET OS - MARCH 2016
Messages
• Communication between actors
• Tell: Fire and Forget
• Ask: Tell + Future { reply }
• Guaranteed ordering for one
sender and receiver pair
• Access to a mailbox
• Messages can be anything
// Tell example
actorRef ! Notify("hi!")
// Ask example
val future = qaActor ? Question(“What?”)
// Process result
future.onComplete { … }
// Send result to actor
future pipeTo actorRef2
PLANET OS - MARCH 2016
Futures
• Future is a way to
Future { socket.read() }
retrieve results …
of concurrent operations …
asynchronously or synchronously.
• Examples
Eg code block:
Or actor ask: qaActor ? Question(“What is the meaning of life?”)
• Futures are composable
PLANET OS - MARCH 2016
Actor Creation
• Each actor
val qaActor = system.actorOf(
Props[QuestionAnswerer], 

“Oracle”
)
... is an instance of a class with parameters
… has a name
• To create an actor:
PLANET OS - MARCH 2016
Actor References
• You can not talk to actors directly
• When you create an actor, you get an ActorRef
• ActorRef is a reference to an actor
… that can be passed around
… also in messages
… is serializable
… possibly remote
… hides local state
PLANET OS - MARCH 2016
QA Actor example
PLANET OS - MARCH 2016
But What if We Want an Already Existing ActorRef?
val selection = context.actorSelection("/user/AllKnowing/oracle")
• ActorSelection
val allAnswerers = context.actorSelection("/user/AllKnowing/*")
• The result can contain multiple actors:
allAnswerers ! Question(“Why are there petunias?”)
• But you can still send it messages:
• Transparently remote
PLANET OS - MARCH 2016
But how do I know the actor path?
• Actors are in a hierarchy (tree)
• Tree root is ActorSystem
• System guardian and user guardian
• All user-created actors live under 

/user
• It is a bit more complicated if the
actor is in a remote machine
ActorSystem
/user /system
/user/Allknowing
/user/AllKnowing/Oracle
PLANET OS - MARCH 2016
What else can we do with the hierarchy? Supervision!
• Reliability
• Error kernel pattern
• Errors are escalated up the hierarchy
• Each level can decide how to respond
• Escalate error
• Restart child
• Stop child
• Resume child
• Top level guardian will shut down entire actor system
/c1
/b1
/c2
/a1
/b2
/user
/a2
/b3
/c4 /c5
/
/
system
PLANET OS - MARCH 2016
Where do messages go? Mailboxes!
• Each actor has access to one
• Possibly shared
• Multiple types
• Bounded / Unbounded
• Priority
• Can be order-preserving, but not always
Actor A Mailbox
Actor B
Message
PLANET OS - MARCH 2016
Message Delivery Reliability
• Local message delivery is reliable

Except for vm errors, and it’s better to always code for failure cases anyway.
• Mostly order preserving

Unless you explicitly select non-order-preserving mailboxes of course
• Remote delivery is unreliable
• Should retry messages until acknowledged

Or be ok with losing some, or most, or all, depending on the network.
• If message processing is idempotent, things get a lot easier to manage
PLANET OS - MARCH 2016
Who schedules actors to threads? Dispatchers!
• Messages arrive to actor mailboxes
• Dispatcher takes a message
• from actor mailbox …
• and schedules actor …
• to handle it on a thread
• Threads are taken from execution contexts
• … aka thread pools
• Dispatchers are assigned to actors via rules
Actor A Mailbox
Actor B
Message
Dispatcher
Examples
Planet OS Data Intelligence
PLANET OS - MARCH 2016
Websocket handling with actors
• Actor based web server
• One actor that receives connections
• Creates per-connection actors
• Supervises / terminates connection actors
• Connection actors handle data updates
• Better performance than 

thread-per-connection model
• Easier and scales better than 

… callbacks for data send/receive

… event loops
Listening

Socket
Connection 

Manager Actor
Connection

Actor
Connection

Actor
Connection

Actor
PLANET OS - MARCH 2016
Data update publish
Kafka
Connection

Actor
Connection

Actor
Connection

Actor
Kafka

receiver actor
Socket
Connection
Socket
Connection
Socket
Connection
PLANET OS - MARCH 2016
SCADA
SCADA
SCADA
WS
Kafka
Queue
Process
Turbine 1
Turbine 2
Turbine 3
Power Plant
Dashboard
PLANET OS - MARCH 2016
Event processing with actors
• Actors represent domain entities
• wind turbine
• power plant
• alert
• Receive event updates from Kafka
• Produce new events sent to Kafka
• Some events are joins of multiple events (eg alerts)
• Some events go to Web Sockets
PLANET OS - MARCH 2016
Challenges
• Code must correctly handle idempotency
• Code must correctly handle crashes / restarts anywhere
• Data updates must not be lost
• Even cascaded data updates must not be lost
• Purely actor based model must mix consistency handling
in business logic
Planet OS Data Hub
PLANET OS - MARCH 2016
DPipe - the magic behind the Data Hub
• Data pipeline:
• Acquisition
• Transformation
• Analysis
• Indexing
• For spatio-temporal data:
• Time series
• Forecasts
• Satellites
• Sensors
• Models
PLANET OS - MARCH 2016
DPipe - large scale data processing
• Multiple stages
• Each stage runs a cluster of actor systems
• Actor system has a scheduler that distributes work
to worker actors
• Multiple pipelines also within a stage
• Can scale linearly with data sources
• Can do fork/join in data pipes with parallelisation
• Framework for exactly-once processing at scale
As if it wasn’t already quite obvious
We ARE in fact looking for new team members.
There are many interesting challenges to work on.
Interested? Come talk to me or 

e-mail kristo@planetos.com
Questions?
KRISTO IILA, kristo@planetos.com

Mais conteĂşdo relacionado

Último

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceanilsa9823
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 

Último (20)

SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female serviceCALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
CALL ON ➥8923113531 🔝Call Girls Badshah Nagar Lucknow best Female service
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data ScienceChristy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Simplifying concurrency: Actors. In particular, AKKA.

  • 1. Simplifying concurrency: Actors In particular, AKKA KRISTO IILA, ENGINEERING MANAGER
  • 2. PLANET OS - MARCH 2016 The Many Ways of Concurrency • Multithreading / semaphores / locking / mutexes • Lock-free data structures • Software Transactional Memory • Message passing • Futures / Async • Actors
  • 3. PLANET OS - MARCH 2016 What are Actors? • Lightweight object • No shared state • Communication via message passing • Supervision hierarchies • Originally implemented in Erlang 
 (high availability telephone switches) • Don’t need to think in terms of threads and locks • Distributable by design
  • 4. PLANET OS - MARCH 2016 An Actor System Implementation - AKKA • Implements actor model • Makes remoting seamless • Works with Java, Scala and .net • Fits very well with scala • Automatically scheduled to threads • Can have multiple thread pools Actor A Mailbox Actor B Message
  • 5. PLANET OS - MARCH 2016 Messages • Communication between actors • Tell: Fire and Forget • Ask: Tell + Future { reply } • Guaranteed ordering for one sender and receiver pair • Access to a mailbox • Messages can be anything // Tell example actorRef ! Notify("hi!") // Ask example val future = qaActor ? Question(“What?”) // Process result future.onComplete { … } // Send result to actor future pipeTo actorRef2
  • 6. PLANET OS - MARCH 2016 Futures • Future is a way to Future { socket.read() } retrieve results … of concurrent operations … asynchronously or synchronously. • Examples Eg code block: Or actor ask: qaActor ? Question(“What is the meaning of life?”) • Futures are composable
  • 7. PLANET OS - MARCH 2016 Actor Creation • Each actor val qaActor = system.actorOf( Props[QuestionAnswerer], 
 “Oracle” ) ... is an instance of a class with parameters … has a name • To create an actor:
  • 8. PLANET OS - MARCH 2016 Actor References • You can not talk to actors directly • When you create an actor, you get an ActorRef • ActorRef is a reference to an actor … that can be passed around … also in messages … is serializable … possibly remote … hides local state
  • 9. PLANET OS - MARCH 2016 QA Actor example
  • 10. PLANET OS - MARCH 2016 But What if We Want an Already Existing ActorRef? val selection = context.actorSelection("/user/AllKnowing/oracle") • ActorSelection val allAnswerers = context.actorSelection("/user/AllKnowing/*") • The result can contain multiple actors: allAnswerers ! Question(“Why are there petunias?”) • But you can still send it messages: • Transparently remote
  • 11. PLANET OS - MARCH 2016 But how do I know the actor path? • Actors are in a hierarchy (tree) • Tree root is ActorSystem • System guardian and user guardian • All user-created actors live under 
 /user • It is a bit more complicated if the actor is in a remote machine ActorSystem /user /system /user/Allknowing /user/AllKnowing/Oracle
  • 12. PLANET OS - MARCH 2016 What else can we do with the hierarchy? Supervision! • Reliability • Error kernel pattern • Errors are escalated up the hierarchy • Each level can decide how to respond • Escalate error • Restart child • Stop child • Resume child • Top level guardian will shut down entire actor system /c1 /b1 /c2 /a1 /b2 /user /a2 /b3 /c4 /c5 / / system
  • 13. PLANET OS - MARCH 2016 Where do messages go? Mailboxes! • Each actor has access to one • Possibly shared • Multiple types • Bounded / Unbounded • Priority • Can be order-preserving, but not always Actor A Mailbox Actor B Message
  • 14. PLANET OS - MARCH 2016 Message Delivery Reliability • Local message delivery is reliable
 Except for vm errors, and it’s better to always code for failure cases anyway. • Mostly order preserving
 Unless you explicitly select non-order-preserving mailboxes of course • Remote delivery is unreliable • Should retry messages until acknowledged
 Or be ok with losing some, or most, or all, depending on the network. • If message processing is idempotent, things get a lot easier to manage
  • 15. PLANET OS - MARCH 2016 Who schedules actors to threads? Dispatchers! • Messages arrive to actor mailboxes • Dispatcher takes a message • from actor mailbox … • and schedules actor … • to handle it on a thread • Threads are taken from execution contexts • … aka thread pools • Dispatchers are assigned to actors via rules Actor A Mailbox Actor B Message Dispatcher
  • 17. Planet OS Data Intelligence
  • 18. PLANET OS - MARCH 2016 Websocket handling with actors • Actor based web server • One actor that receives connections • Creates per-connection actors • Supervises / terminates connection actors • Connection actors handle data updates • Better performance than 
 thread-per-connection model • Easier and scales better than 
 … callbacks for data send/receive
 … event loops Listening
 Socket Connection 
 Manager Actor Connection
 Actor Connection
 Actor Connection
 Actor
  • 19. PLANET OS - MARCH 2016 Data update publish Kafka Connection
 Actor Connection
 Actor Connection
 Actor Kafka
 receiver actor Socket Connection Socket Connection Socket Connection
  • 20. PLANET OS - MARCH 2016 SCADA SCADA SCADA WS Kafka Queue Process Turbine 1 Turbine 2 Turbine 3 Power Plant Dashboard
  • 21. PLANET OS - MARCH 2016 Event processing with actors • Actors represent domain entities • wind turbine • power plant • alert • Receive event updates from Kafka • Produce new events sent to Kafka • Some events are joins of multiple events (eg alerts) • Some events go to Web Sockets
  • 22. PLANET OS - MARCH 2016 Challenges • Code must correctly handle idempotency • Code must correctly handle crashes / restarts anywhere • Data updates must not be lost • Even cascaded data updates must not be lost • Purely actor based model must mix consistency handling in business logic
  • 24. PLANET OS - MARCH 2016 DPipe - the magic behind the Data Hub • Data pipeline: • Acquisition • Transformation • Analysis • Indexing • For spatio-temporal data: • Time series • Forecasts • Satellites • Sensors • Models
  • 25. PLANET OS - MARCH 2016 DPipe - large scale data processing • Multiple stages • Each stage runs a cluster of actor systems • Actor system has a scheduler that distributes work to worker actors • Multiple pipelines also within a stage • Can scale linearly with data sources • Can do fork/join in data pipes with parallelisation • Framework for exactly-once processing at scale
  • 26. As if it wasn’t already quite obvious We ARE in fact looking for new team members. There are many interesting challenges to work on. Interested? Come talk to me or 
 e-mail kristo@planetos.com