SlideShare una empresa de Scribd logo
1 de 18
Descargar para leer sin conexión
Message Switching
 for Actor based
     designs
    Jean-Lou Dupont
me

● President of Data-Tester Inc.
  ○ Fiber Optics Test Equipment company
  ○ Build system / Python
  ○ Web-Services on Google AppEngine / Python

● Python since ~2007
what

● Actor Design Pattern
  ○ concurrency
  ○ abstraction
  ○ based on "message passing"


● "mswitch": an implementation in Python
why

● Facilitates the "Actor Design Pattern"

   ○ Less "boiler plate" code
     ■ No per message type "wiring"

   ○ Increased flexibility (loose coupling)
mswitch / attributes

● Software based Message Bus (mswitch)
    ○ Anonymous Sender
    ○ Receiver based "wiring"
    ○ Snooping support (for debugging)


●   Can either be
    ○ inter-process
    ○ intra-process
how
● Actors are "adresseless"

● Each Actor "connects" to the mswitch

● First time a message of a Type X is sent
  ○ All Actors receive the message
  ○ Each Actor signals "interest" for a message Type X


● On subsequent message message of Type X
  ○ only the Actor(s) which explicitly expressed their
    interest receive the message
implementation / high-level api
● Connecting
  ○ mswitch.subscribe( Actor )


● Sending
  ○ mswitch.send( origin Actor, msg )


● Receiving
  ○ Actor.mailbox( msg )
architecture / connecting


               Actor       Actor        Actor
                1           2            3



                       Message Switch




● Each Actor "connects" to mswitch
architecture / sending


                   Actor       Actor        Actor
                    1           2            3



                           Message Switch




● Actor sends message of Type X for 1st time
  ○ All other Actors receive it
● Split Horizon
  ○ Sender doesn't receive what it sends
architecture / wiring


                    Actor       Actor        Actor
                     1           2            3



                            Message Switch




● Each Actor wires itself for message Type X
  ○ Actor replies "Interested" --> mswitch places "wire"
  ○ Actor replies "! Interested" --> mswitch removes "wire"
Example /1
                                                                                         Web


                        Presenter                                    Cache              Fetcher



                                                                       data?                 data?

mswitch




                                 data?                                       snooping



                        Manager                                      Stats


   ●   Actor "Manager" wants to have some "data"
   ●   Actor "Stats" maintains various statistics about the system
Example /2
                                                                                        Web


                       Presenter                                   Cache               Fetcher


                                data                                    data                 data
                               (none)                                  (none)               (none)

mswitch


                                data
                               (none)
                                                                            snooping



                        Manager                                     Stats


   ●   Actor "Cache" doesn't have a fresh copy of "data"
   ●   Actor "Fetcher" understands to go fetch the data from the remote source
   ●   Actors "Manager" and "Presenter" understand they have to wait for the data
Example /3
                                                                                          Web


                       Presenter                                      Cache              Fetcher



                                data                                          data              data

mswitch


                                data
                                                                              snooping



                        Manager                                       Stats


   ●   Actor "Fetcher" provides a fresh copy of "data"
   ●   Actor "Cache" caches "data"
   ●   Actors "Manager" and "Presenter" receive the required "data"
code /1
""" mswitch module """
from Queue import Queue, Empty

def publish(orig, msgType, *pargs, **kargs):
     q=_switch.iq
     if msgType.startswith("__"):
          q=_switch.isq
     q.put((orig, msgType, (pargs, kargs)), block=False)

def subscribe(orig, q, sq):
     _switch.iq.put((orig, "__sub__", (q, sq)), block=False)


Normal priority queue: iq
High priority queue: isq
code /2
""" Actor base """
class ActorThreadedBase(Thread, ActorBase):
     def __init__(self):
          Thread.__init__(self)
          ActorBase.__init__(self)
     def run(self):
          """message loop"""
          mswitch.subscribe(self.id, self.iq, self.isq)
          _quit=False
          while not _quit:
              _quit=process_queues(self)


Details omitted
code /3
""" Example Actor """
class ActorExample(ActorThreadedBase):
     def __init__(self):
          ActorThreadedBase.__init__(self)

    def hq_data(self, msg):
         """ handler for the 'data?' message """

    def h_data(self, msg):
         """ handler for the 'data' message """

_=ActorExample()
_.start()
final word



● Bunch of open-source projects based on this
  technique ( see http://www.systemical.com )

● Don't hesitate to get in touch:
       mailto:jldupont@systemical.com
         jeanlou.dupont@gmail.com
Merci :)
          Jean-Lou Dupont

http://ca.linkedin.com/in/jeanloudupont

Más contenido relacionado

La actualidad más candente

OGRE v1.10 manual - The Core Objects
OGRE v1.10 manual - The Core ObjectsOGRE v1.10 manual - The Core Objects
OGRE v1.10 manual - The Core ObjectsRiver Wang
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろうUnity Technologies Japan K.K.
 
Real time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.lyReal time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.lyVarun Vijayaraghavan
 
Brian sabbeth smart_pointers
Brian sabbeth smart_pointersBrian sabbeth smart_pointers
Brian sabbeth smart_pointersBrian Sabbeth
 
Multithreading and Parallelism on iOS [MobOS 2013]
 Multithreading and Parallelism on iOS [MobOS 2013] Multithreading and Parallelism on iOS [MobOS 2013]
Multithreading and Parallelism on iOS [MobOS 2013]Kuba Břečka
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...JAX London
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryAlexandre Morgaut
 

La actualidad más candente (7)

OGRE v1.10 manual - The Core Objects
OGRE v1.10 manual - The Core ObjectsOGRE v1.10 manual - The Core Objects
OGRE v1.10 manual - The Core Objects
 
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
【Unite 2017 Tokyo】ScriptableObjectを使ってプログラマーもアーティストも幸せになろう
 
Real time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.lyReal time stream processing presentation at General Assemb.ly
Real time stream processing presentation at General Assemb.ly
 
Brian sabbeth smart_pointers
Brian sabbeth smart_pointersBrian sabbeth smart_pointers
Brian sabbeth smart_pointers
 
Multithreading and Parallelism on iOS [MobOS 2013]
 Multithreading and Parallelism on iOS [MobOS 2013] Multithreading and Parallelism on iOS [MobOS 2013]
Multithreading and Parallelism on iOS [MobOS 2013]
 
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
Java Core | Understanding the Disruptor: a Beginner's Guide to Hardcore Concu...
 
NoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love StoryNoSQL and JavaScript: a Love Story
NoSQL and JavaScript: a Love Story
 

Destacado

Flow control and error control
Flow control and error controlFlow control and error control
Flow control and error controlBHUVIJAYAVELU
 
quantization | Communication Systems
quantization | Communication Systemsquantization | Communication Systems
quantization | Communication SystemsLearn By Watch
 
Bit Oriented Protocols in Data Communication DC23
Bit Oriented Protocols in Data Communication DC23Bit Oriented Protocols in Data Communication DC23
Bit Oriented Protocols in Data Communication DC23koolkampus
 
Computer and Communication Networks in ODL
Computer and Communication Networks in ODLComputer and Communication Networks in ODL
Computer and Communication Networks in ODLSanjaya Mishra
 
Data link control
Data link controlData link control
Data link controlIffat Anjum
 
Data Link Control in Data Communication DC20
Data Link Control in Data Communication DC20Data Link Control in Data Communication DC20
Data Link Control in Data Communication DC20koolkampus
 
Digitization of Audio.ppt
Digitization of Audio.pptDigitization of Audio.ppt
Digitization of Audio.pptVideoguy
 
Circuit Packet
Circuit PacketCircuit Packet
Circuit PacketWaqas !!!!
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switchingasimnawaz54
 
Physical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and DevicesPhysical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and DevicesShahid Khan
 
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)Adil Mehmoood
 
Flow & Error Control
Flow & Error ControlFlow & Error Control
Flow & Error Controltameemyousaf
 
CCNA Introducing Networks
CCNA Introducing NetworksCCNA Introducing Networks
CCNA Introducing NetworksDsunte Wilson
 
Network ppt
Network pptNetwork ppt
Network ppthlalu861
 
Circuit switching packet switching
Circuit switching  packet  switchingCircuit switching  packet  switching
Circuit switching packet switchingSneha Dalvi
 

Destacado (20)

Flow control and error control
Flow control and error controlFlow control and error control
Flow control and error control
 
quantization | Communication Systems
quantization | Communication Systemsquantization | Communication Systems
quantization | Communication Systems
 
Bit Oriented Protocols in Data Communication DC23
Bit Oriented Protocols in Data Communication DC23Bit Oriented Protocols in Data Communication DC23
Bit Oriented Protocols in Data Communication DC23
 
Mod8
Mod8Mod8
Mod8
 
Packet Switching
Packet SwitchingPacket Switching
Packet Switching
 
Computer and Communication Networks in ODL
Computer and Communication Networks in ODLComputer and Communication Networks in ODL
Computer and Communication Networks in ODL
 
Data link control
Data link controlData link control
Data link control
 
Data Link Control in Data Communication DC20
Data Link Control in Data Communication DC20Data Link Control in Data Communication DC20
Data Link Control in Data Communication DC20
 
Digitization of Audio.ppt
Digitization of Audio.pptDigitization of Audio.ppt
Digitization of Audio.ppt
 
Circuit Packet
Circuit PacketCircuit Packet
Circuit Packet
 
Network layer and circuit switching
Network layer and circuit switchingNetwork layer and circuit switching
Network layer and circuit switching
 
circuit switching
circuit  switchingcircuit  switching
circuit switching
 
Physical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and DevicesPhysical Layer of ISO-OSI model and Devices
Physical Layer of ISO-OSI model and Devices
 
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)
Multiplexing and switching(TDM ,FDM, Data gram, circuit switching)
 
Flow & Error Control
Flow & Error ControlFlow & Error Control
Flow & Error Control
 
Circuit Switching
Circuit SwitchingCircuit Switching
Circuit Switching
 
Flow control
Flow controlFlow control
Flow control
 
CCNA Introducing Networks
CCNA Introducing NetworksCCNA Introducing Networks
CCNA Introducing Networks
 
Network ppt
Network pptNetwork ppt
Network ppt
 
Circuit switching packet switching
Circuit switching  packet  switchingCircuit switching  packet  switching
Circuit switching packet switching
 

Similar a Message Switching for Actor-Based Designs

MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big DataTakahiro Inoue
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And DesignYaroslav Tkachenko
 
Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Yandex
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsServer Density
 
[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리NAVER D2
 
GR8Conf 2011: GPars
GR8Conf 2011: GParsGR8Conf 2011: GPars
GR8Conf 2011: GParsGR8Conf
 
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...confluent
 
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...Martin Zapletal
 
Streaming Dataflow with Apache Flink
Streaming Dataflow with Apache Flink Streaming Dataflow with Apache Flink
Streaming Dataflow with Apache Flink huguk
 
Apache Storm Concepts
Apache Storm ConceptsApache Storm Concepts
Apache Storm ConceptsAndré Dias
 
Actor model in .NET - Akka.NET
Actor model in .NET - Akka.NETActor model in .NET - Akka.NET
Actor model in .NET - Akka.NETKonrad Dusza
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Evan Chan
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory AnalysisMoabi.com
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...MongoDB
 
유연하고 확장성 있는 빅데이터 처리
유연하고 확장성 있는 빅데이터 처리유연하고 확장성 있는 빅데이터 처리
유연하고 확장성 있는 빅데이터 처리NAVER D2
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapKostas Tzoumas
 
(BDT318) How Netflix Handles Up To 8 Million Events Per Second
(BDT318) How Netflix Handles Up To 8 Million Events Per Second(BDT318) How Netflix Handles Up To 8 Million Events Per Second
(BDT318) How Netflix Handles Up To 8 Million Events Per SecondAmazon Web Services
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelMassimo Bonanni
 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...Dataconomy Media
 

Similar a Message Switching for Actor-Based Designs (20)

MongoDB: Intro & Application for Big Data
MongoDB: Intro & Application  for Big DataMongoDB: Intro & Application  for Big Data
MongoDB: Intro & Application for Big Data
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 
Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"Marco Cattaneo "Event data processing in LHCb"
Marco Cattaneo "Event data processing in LHCb"
 
So you think you can stream.pptx
So you think you can stream.pptxSo you think you can stream.pptx
So you think you can stream.pptx
 
MongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & AnalyticsMongoDB: Optimising for Performance, Scale & Analytics
MongoDB: Optimising for Performance, Scale & Analytics
 
[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리[214]유연하고 확장성 있는 빅데이터 처리
[214]유연하고 확장성 있는 빅데이터 처리
 
GR8Conf 2011: GPars
GR8Conf 2011: GParsGR8Conf 2011: GPars
GR8Conf 2011: GPars
 
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...
Kafka Connect: Operational Lessons Learned from the Trenches (Elizabeth Benne...
 
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
Large volume data analysis on the Typesafe Reactive Platform - Big Data Scala...
 
Streaming Dataflow with Apache Flink
Streaming Dataflow with Apache Flink Streaming Dataflow with Apache Flink
Streaming Dataflow with Apache Flink
 
Apache Storm Concepts
Apache Storm ConceptsApache Storm Concepts
Apache Storm Concepts
 
Actor model in .NET - Akka.NET
Actor model in .NET - Akka.NETActor model in .NET - Akka.NET
Actor model in .NET - Akka.NET
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015
 
[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis[Ruxcon 2011] Post Memory Corruption Memory Analysis
[Ruxcon 2011] Post Memory Corruption Memory Analysis
 
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
Ensuring High Availability for Real-time Analytics featuring Boxed Ice / Serv...
 
유연하고 확장성 있는 빅데이터 처리
유연하고 확장성 있는 빅데이터 처리유연하고 확장성 있는 빅데이터 처리
유연하고 확장성 있는 빅데이터 처리
 
Apache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmapApache Flink: API, runtime, and project roadmap
Apache Flink: API, runtime, and project roadmap
 
(BDT318) How Netflix Handles Up To 8 Million Events Per Second
(BDT318) How Netflix Handles Up To 8 Million Events Per Second(BDT318) How Netflix Handles Up To 8 Million Events Per Second
(BDT318) How Netflix Handles Up To 8 Million Events Per Second
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft..."Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
"Source Code Abstracts Classification Using CNN", Vadim Markovtsev, Lead Soft...
 

Más de Montreal Python

Mp26 : Connecting Startups with Talents
Mp26 : Connecting Startups with TalentsMp26 : Connecting Startups with Talents
Mp26 : Connecting Startups with TalentsMontreal Python
 
Mp26 : A Quick Introduction to NetworkX
Mp26 : A Quick Introduction to NetworkXMp26 : A Quick Introduction to NetworkX
Mp26 : A Quick Introduction to NetworkXMontreal Python
 
Mp26 : Tachyon, sloppiness is bliss
Mp26 : Tachyon, sloppiness is blissMp26 : Tachyon, sloppiness is bliss
Mp26 : Tachyon, sloppiness is blissMontreal Python
 
Mp26 : How do you Solve a Problem like Santa Claus?
Mp26 : How do you Solve a Problem like Santa Claus?Mp26 : How do you Solve a Problem like Santa Claus?
Mp26 : How do you Solve a Problem like Santa Claus?Montreal Python
 
Mp25: Optical Music Recognition with Python
Mp25: Optical Music Recognition with PythonMp25: Optical Music Recognition with Python
Mp25: Optical Music Recognition with PythonMontreal Python
 
Mp25: Audio Fingerprinting and metadata correction with Python
Mp25: Audio Fingerprinting and metadata correction with PythonMp25: Audio Fingerprinting and metadata correction with Python
Mp25: Audio Fingerprinting and metadata correction with PythonMontreal Python
 
Mp25: Mobile dev with QT and Python for the Notorious N9
Mp25: Mobile dev with QT and Python for the Notorious N9Mp25: Mobile dev with QT and Python for the Notorious N9
Mp25: Mobile dev with QT and Python for the Notorious N9Montreal Python
 
Mp24: Python in gaming industry
Mp24: Python in gaming industryMp24: Python in gaming industry
Mp24: Python in gaming industryMontreal Python
 
Mp24: Fabulous Mobile Development with and without Python
Mp24: Fabulous Mobile Development with and without PythonMp24: Fabulous Mobile Development with and without Python
Mp24: Fabulous Mobile Development with and without PythonMontreal Python
 
Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMontreal Python
 

Más de Montreal Python (10)

Mp26 : Connecting Startups with Talents
Mp26 : Connecting Startups with TalentsMp26 : Connecting Startups with Talents
Mp26 : Connecting Startups with Talents
 
Mp26 : A Quick Introduction to NetworkX
Mp26 : A Quick Introduction to NetworkXMp26 : A Quick Introduction to NetworkX
Mp26 : A Quick Introduction to NetworkX
 
Mp26 : Tachyon, sloppiness is bliss
Mp26 : Tachyon, sloppiness is blissMp26 : Tachyon, sloppiness is bliss
Mp26 : Tachyon, sloppiness is bliss
 
Mp26 : How do you Solve a Problem like Santa Claus?
Mp26 : How do you Solve a Problem like Santa Claus?Mp26 : How do you Solve a Problem like Santa Claus?
Mp26 : How do you Solve a Problem like Santa Claus?
 
Mp25: Optical Music Recognition with Python
Mp25: Optical Music Recognition with PythonMp25: Optical Music Recognition with Python
Mp25: Optical Music Recognition with Python
 
Mp25: Audio Fingerprinting and metadata correction with Python
Mp25: Audio Fingerprinting and metadata correction with PythonMp25: Audio Fingerprinting and metadata correction with Python
Mp25: Audio Fingerprinting and metadata correction with Python
 
Mp25: Mobile dev with QT and Python for the Notorious N9
Mp25: Mobile dev with QT and Python for the Notorious N9Mp25: Mobile dev with QT and Python for the Notorious N9
Mp25: Mobile dev with QT and Python for the Notorious N9
 
Mp24: Python in gaming industry
Mp24: Python in gaming industryMp24: Python in gaming industry
Mp24: Python in gaming industry
 
Mp24: Fabulous Mobile Development with and without Python
Mp24: Fabulous Mobile Development with and without PythonMp24: Fabulous Mobile Development with and without Python
Mp24: Fabulous Mobile Development with and without Python
 
Mp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook gameMp24: The Bachelor, a facebook game
Mp24: The Bachelor, a facebook game
 

Último

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfSeasiaInfotech2
 

Último (20)

SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
The Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdfThe Future of Software Development - Devin AI Innovative Approach.pdf
The Future of Software Development - Devin AI Innovative Approach.pdf
 

Message Switching for Actor-Based Designs

  • 1. Message Switching for Actor based designs Jean-Lou Dupont
  • 2. me ● President of Data-Tester Inc. ○ Fiber Optics Test Equipment company ○ Build system / Python ○ Web-Services on Google AppEngine / Python ● Python since ~2007
  • 3. what ● Actor Design Pattern ○ concurrency ○ abstraction ○ based on "message passing" ● "mswitch": an implementation in Python
  • 4. why ● Facilitates the "Actor Design Pattern" ○ Less "boiler plate" code ■ No per message type "wiring" ○ Increased flexibility (loose coupling)
  • 5. mswitch / attributes ● Software based Message Bus (mswitch) ○ Anonymous Sender ○ Receiver based "wiring" ○ Snooping support (for debugging) ● Can either be ○ inter-process ○ intra-process
  • 6. how ● Actors are "adresseless" ● Each Actor "connects" to the mswitch ● First time a message of a Type X is sent ○ All Actors receive the message ○ Each Actor signals "interest" for a message Type X ● On subsequent message message of Type X ○ only the Actor(s) which explicitly expressed their interest receive the message
  • 7. implementation / high-level api ● Connecting ○ mswitch.subscribe( Actor ) ● Sending ○ mswitch.send( origin Actor, msg ) ● Receiving ○ Actor.mailbox( msg )
  • 8. architecture / connecting Actor Actor Actor 1 2 3 Message Switch ● Each Actor "connects" to mswitch
  • 9. architecture / sending Actor Actor Actor 1 2 3 Message Switch ● Actor sends message of Type X for 1st time ○ All other Actors receive it ● Split Horizon ○ Sender doesn't receive what it sends
  • 10. architecture / wiring Actor Actor Actor 1 2 3 Message Switch ● Each Actor wires itself for message Type X ○ Actor replies "Interested" --> mswitch places "wire" ○ Actor replies "! Interested" --> mswitch removes "wire"
  • 11. Example /1 Web Presenter Cache Fetcher data? data? mswitch data? snooping Manager Stats ● Actor "Manager" wants to have some "data" ● Actor "Stats" maintains various statistics about the system
  • 12. Example /2 Web Presenter Cache Fetcher data data data (none) (none) (none) mswitch data (none) snooping Manager Stats ● Actor "Cache" doesn't have a fresh copy of "data" ● Actor "Fetcher" understands to go fetch the data from the remote source ● Actors "Manager" and "Presenter" understand they have to wait for the data
  • 13. Example /3 Web Presenter Cache Fetcher data data data mswitch data snooping Manager Stats ● Actor "Fetcher" provides a fresh copy of "data" ● Actor "Cache" caches "data" ● Actors "Manager" and "Presenter" receive the required "data"
  • 14. code /1 """ mswitch module """ from Queue import Queue, Empty def publish(orig, msgType, *pargs, **kargs): q=_switch.iq if msgType.startswith("__"): q=_switch.isq q.put((orig, msgType, (pargs, kargs)), block=False) def subscribe(orig, q, sq): _switch.iq.put((orig, "__sub__", (q, sq)), block=False) Normal priority queue: iq High priority queue: isq
  • 15. code /2 """ Actor base """ class ActorThreadedBase(Thread, ActorBase): def __init__(self): Thread.__init__(self) ActorBase.__init__(self) def run(self): """message loop""" mswitch.subscribe(self.id, self.iq, self.isq) _quit=False while not _quit: _quit=process_queues(self) Details omitted
  • 16. code /3 """ Example Actor """ class ActorExample(ActorThreadedBase): def __init__(self): ActorThreadedBase.__init__(self) def hq_data(self, msg): """ handler for the 'data?' message """ def h_data(self, msg): """ handler for the 'data' message """ _=ActorExample() _.start()
  • 17. final word ● Bunch of open-source projects based on this technique ( see http://www.systemical.com ) ● Don't hesitate to get in touch: mailto:jldupont@systemical.com jeanlou.dupont@gmail.com
  • 18. Merci :) Jean-Lou Dupont http://ca.linkedin.com/in/jeanloudupont