SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Jobim: an Actors
Library for the Clojure
Programming Language


         Antonio Garrote
      María N. Moreno García
Clojure

• New Lisp dialect
• Hosted: JVM, CLR
• Focus on concurrency: (STM, Agents,
  futures, fork-join, java.util.concurrent.*)
Distributed concurrent
applications in Clojure?

“Given the diversity, sophistication, maturity,
interoperability,robustness etc of these options, it's
unlikely I'm going to fiddle around with some
language-specific solution.”

 Rich Hickey
Distributed applications
      on the JVM
• JINI
• Java Spaces
• JMS
• Terracota
• RabbitMQ
• ZeroMQ
• Gearman
Problems

• Different computational models
• Hard to port code from one solution to
  other
• Friction with Clojure semantics
Extending Clojure

• Computational model?
• Suitable notation?
• Underlying implementation?
Computational Model
Actors: components

• Named channel (PID)      PID




• Message box                    MBox
                                        Execution
                                         Context



• Execution context

Computation based on the exchange of messages
Actors: mobile
                processes
PID3                                        PID1


                 Execution                                Execution
       MBox                                        MBox
                  Context                                  Context
                                    Msg




               PID3                                PID3




                PID2


                                      Execution
                             MBox
                                       Context
Notation
Actors: minimal
     interface
(def *pid* (spawn f))

(is (= *pid* (self)))

(send! *pid* msg)

(def msg (receive *pid*))
Selective Reception
(let [p (promise)
      pid (spawn
           #(let [a (receive odd?)
                  b (receive even?)]
              (deliver p [a b])))]

  (send! pid 2)
  (send! pid 1)

  (is (= @p [1 2])))
Implementation
Message Box

• Lamina - Z. Tellman (https://github.com/
  ztellman/lamina)
• Transforms Clojure sequences into event-
  driven channels
• Synchronous and asynchronous interface
PIDs/Channel Names

• Plain Java strings: easy to exchange
• Globally unique identifiers for actors across
  all the nodes in a Jobim cluster
• Generated by Jobim’s runtime
• GUID node + process counter
Execution context
• Threaded actors:
 - Java thread per actor
 - End of thread execution, releases
     resources
 -   Threaded actors do not scale (~2000
     threads per node max.)
Execution context

• Evented actors (Scala):
 - Actors context = closure + callback
     functions
 -   Small number of reactor threads execute
     all the evented threads
(spawn
             #(loop []
               (let [[from msg] (receive)]
Threaded          (send! from msg)
                  (recur))))



            (spawn-evented
              #(react-loop []
                 (react [[from msg]]
Evented                 (send! from msg)
                        (react-recur))))
react-loop
               Callbacks+Contexts queues



Events



                                                  listen-once

         Reactor1        ...       ReactorN                       publish

                                                     react-recur

                     Multiplexer

                                                      react-future
                                     Messages


                                                thread- publish
                                                                    handler
                                                 pool
Distribution
3 problems


Messaging    Coordination   Serialization
Modular solution
            Protocols: jobim.services.*


Messaging         Coordination      Serialization




                     Plugins
Coordination

• Name service
• Membership groups: presence
• Distributed agreement: 2PC protocol
Coordination

• Apache ZooKeeper plugin
 - Light-weight
 - Scalable
 - Small set of primitives to build
    sophisticated coordination protocols
Coordination: name
 service - group
  membership
(nodes)

(resolve-node-name node-name)

(register-name name *pid*)

(def *pid* (resolve-name name))
Coordination: 2PC -
group membership


   (link *pid1* *pid2*)



         Signal
Messaging

• TCP plugin: Netty, Z.Tellman’s Aleph
  [https://github.com/ztellman/aleph]
• RabbitMQ plugin
• ZeroMQ plugin
Serialization

• Java Serialization plugin
• JSON plugin
• Kryo serialization library plugin (Yahoo S4)
Behaviours
Reusing distributed
     components?
• Encapsulate distributed patterns
• Hide message passing logic
• Building blocks for larger distributed
  systems
• Built using Clojure protocols
• Threaded and evented versions
Behaviours

• Supervisor
• Generic Server
• FSM
• Event Manager / Event Handler
• Generic TCP server
;; FSM Lock type

(def-fsm Lock
  (init [this code] [:locked {:so-far [] :code code}])
  (next-transition [this state-name state-data message]
                    (let [[topic _] message]
                      (condp = [state-name topic]
                        [:locked :button] handle-button
                        [:open   :lock] handle-lock
                        action-ignore)))
  (handle-info [this current-state current-data message]
               (do
                 (cond-match
                   [[?from :state] message] (send! from current-state))
                 (action-next-state current-state current-data))))
Demo
Future work

• Benchmarking + Performance
• Packaging / deployment / managing of
  distributed apps
• Missing functionality
Code+deps

• https://github.com/antoniogarrote/jobim

   [jobim-core "0.1.2-SNAPSHOT"]

 [jobim-rabbitmq "0.1.1-SNAPSHOT"]

 [jobim-zeromq "0.1.1-SNAPSHOT"] *

Más contenido relacionado

La actualidad más candente

Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik TambekarPratik Tambekar
 
Protocol implementation on NS2
Protocol implementation on NS2Protocol implementation on NS2
Protocol implementation on NS2amreshrai02
 
FOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the cornerFOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the cornerAndrey Vagin
 
Introduction to NS2 - Cont..
Introduction to NS2 - Cont..Introduction to NS2 - Cont..
Introduction to NS2 - Cont..cscarcas
 
Twisted: a quick introduction
Twisted: a quick introductionTwisted: a quick introduction
Twisted: a quick introductionRobert Coup
 
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...wallyqs
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorialcode453
 
Adaptive Linear Solvers and Eigensolvers
Adaptive Linear Solvers and EigensolversAdaptive Linear Solvers and Eigensolvers
Adaptive Linear Solvers and Eigensolversinside-BigData.com
 
Towards Chainer v1.5
Towards Chainer v1.5Towards Chainer v1.5
Towards Chainer v1.5Seiya Tokui
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013Jun Rao
 
Network emulator
Network emulatorNetwork emulator
Network emulatorjeromy fu
 
An Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux KernelAn Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux KernelSeongJae Park
 
Hs java open_party
Hs java open_partyHs java open_party
Hs java open_partyOpen Party
 

La actualidad más candente (18)

Network simulator 2
Network simulator 2Network simulator 2
Network simulator 2
 
~Ns2~
~Ns2~~Ns2~
~Ns2~
 
Distributed System by Pratik Tambekar
Distributed System by Pratik TambekarDistributed System by Pratik Tambekar
Distributed System by Pratik Tambekar
 
Protocol implementation on NS2
Protocol implementation on NS2Protocol implementation on NS2
Protocol implementation on NS2
 
FOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the cornerFOSDEM2015: Live migration for containers is around the corner
FOSDEM2015: Live migration for containers is around the corner
 
Ns2
Ns2Ns2
Ns2
 
Introduction to NS2 - Cont..
Introduction to NS2 - Cont..Introduction to NS2 - Cont..
Introduction to NS2 - Cont..
 
Twisted: a quick introduction
Twisted: a quick introductionTwisted: a quick introduction
Twisted: a quick introduction
 
Ns2 introduction 2
Ns2 introduction 2Ns2 introduction 2
Ns2 introduction 2
 
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...GopherCon 2017 -  Writing Networking Clients in Go: The Design & Implementati...
GopherCon 2017 - Writing Networking Clients in Go: The Design & Implementati...
 
NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
 
Tut hemant ns2
Tut hemant ns2Tut hemant ns2
Tut hemant ns2
 
Adaptive Linear Solvers and Eigensolvers
Adaptive Linear Solvers and EigensolversAdaptive Linear Solvers and Eigensolvers
Adaptive Linear Solvers and Eigensolvers
 
Towards Chainer v1.5
Towards Chainer v1.5Towards Chainer v1.5
Towards Chainer v1.5
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
 
Network emulator
Network emulatorNetwork emulator
Network emulator
 
An Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux KernelAn Introduction to the Formalised Memory Model for Linux Kernel
An Introduction to the Formalised Memory Model for Linux Kernel
 
Hs java open_party
Hs java open_partyHs java open_party
Hs java open_party
 

Similar a 4th European Lisp Symposium: Jobim: an Actors Library for the Clojure Programming Language

Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows AzureDamir Dobric
 
DevoxxFR 2016 - 3 degrees of MoM
DevoxxFR 2016 - 3 degrees of MoMDevoxxFR 2016 - 3 degrees of MoM
DevoxxFR 2016 - 3 degrees of MoMGuillaume Arnaud
 
Python twisted
Python twistedPython twisted
Python twistedMahendra M
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Diveconfluent
 
Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Timothy Spann
 
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Paolo Negri
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiDatabricks
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...DataWorks Summit/Hadoop Summit
 
Kafka practical experience
Kafka practical experienceKafka practical experience
Kafka practical experienceRico Chen
 
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...Alexandre Moneger
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringJoe Kutner
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with geventMahendra M
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Itzik Kotler
 
Stream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStreamlio
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8amix3k
 
Springone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorSpringone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorStéphane Maldini
 
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Strata Singapore: GearpumpReal time DAG-Processing with Akka at ScaleStrata Singapore: GearpumpReal time DAG-Processing with Akka at Scale
Strata Singapore: Gearpump Real time DAG-Processing with Akka at ScaleSean Zhong
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overviewjessesanford
 

Similar a 4th European Lisp Symposium: Jobim: an Actors Library for the Clojure Programming Language (20)

Architectures with Windows Azure
Architectures with Windows AzureArchitectures with Windows Azure
Architectures with Windows Azure
 
DevoxxFR 2016 - 3 degrees of MoM
DevoxxFR 2016 - 3 degrees of MoMDevoxxFR 2016 - 3 degrees of MoM
DevoxxFR 2016 - 3 degrees of MoM
 
Python twisted
Python twistedPython twisted
Python twisted
 
Citi TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep DiveCiti TechTalk Session 2: Kafka Deep Dive
Citi TechTalk Session 2: Kafka Deep Dive
 
Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101
 
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
Distributed and concurrent programming with RabbitMQ and EventMachine Rails U...
 
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali ZaidiNatural Language Processing with CNTK and Apache Spark with Ali Zaidi
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
 
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
End to End Processing of 3.7 Million Telemetry Events per Second using Lambda...
 
ROS distributed architecture
ROS  distributed architectureROS  distributed architecture
ROS distributed architecture
 
Kafka practical experience
Kafka practical experienceKafka practical experience
Kafka practical experience
 
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
BSides LV 2016 - Beyond the tip of the iceberg - fuzzing binary protocols for...
 
I can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and SpringI can't believe it's not a queue: Kafka and Spring
I can't believe it's not a queue: Kafka and Spring
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with gevent
 
05 defense
05 defense05 defense
05 defense
 
Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)Hack Like It's 2013 (The Workshop)
Hack Like It's 2013 (The Workshop)
 
Stream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar Functions
 
Comet with node.js and V8
Comet with node.js and V8Comet with node.js and V8
Comet with node.js and V8
 
Springone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and ReactorSpringone2gx 2014 Reactive Streams and Reactor
Springone2gx 2014 Reactive Streams and Reactor
 
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
Strata Singapore: GearpumpReal time DAG-Processing with Akka at ScaleStrata Singapore: GearpumpReal time DAG-Processing with Akka at Scale
Strata Singapore: Gearpump Real time DAG-Processing with Akka at Scale
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overview
 

Más de Antonio Garrote Hernández

API Modeling Framework: a toolbox ofr API specs. Gluecon 2017
API Modeling Framework: a toolbox ofr API specs. Gluecon 2017API Modeling Framework: a toolbox ofr API specs. Gluecon 2017
API Modeling Framework: a toolbox ofr API specs. Gluecon 2017Antonio Garrote Hernández
 
Message Passing Concurrency in Clojure using Kilim
Message Passing Concurrency in Clojure using KilimMessage Passing Concurrency in Clojure using Kilim
Message Passing Concurrency in Clojure using KilimAntonio Garrote Hernández
 
RESTful writable APIs for the web of Linked Data using relational storage sol...
RESTful writable APIs for the web of Linked Data using relational storage sol...RESTful writable APIs for the web of Linked Data using relational storage sol...
RESTful writable APIs for the web of Linked Data using relational storage sol...Antonio Garrote Hernández
 

Más de Antonio Garrote Hernández (7)

API Modeling Framework: a toolbox ofr API specs. Gluecon 2017
API Modeling Framework: a toolbox ofr API specs. Gluecon 2017API Modeling Framework: a toolbox ofr API specs. Gluecon 2017
API Modeling Framework: a toolbox ofr API specs. Gluecon 2017
 
Linked Data APIs (Funding Circle May 2015)
Linked Data APIs (Funding Circle May 2015)Linked Data APIs (Funding Circle May 2015)
Linked Data APIs (Funding Circle May 2015)
 
Message Passing Concurrency in Clojure using Kilim
Message Passing Concurrency in Clojure using KilimMessage Passing Concurrency in Clojure using Kilim
Message Passing Concurrency in Clojure using Kilim
 
RESTful writable APIs for the web of Linked Data using relational storage sol...
RESTful writable APIs for the web of Linked Data using relational storage sol...RESTful writable APIs for the web of Linked Data using relational storage sol...
RESTful writable APIs for the web of Linked Data using relational storage sol...
 
lisp (vs ruby) metaprogramming
lisp (vs ruby) metaprogramminglisp (vs ruby) metaprogramming
lisp (vs ruby) metaprogramming
 
Developing Distributed Semantic Systems
Developing Distributed Semantic SystemsDeveloping Distributed Semantic Systems
Developing Distributed Semantic Systems
 
Egearmand: an Erlang Gearman daemon
Egearmand: an Erlang Gearman daemonEgearmand: an Erlang Gearman daemon
Egearmand: an Erlang Gearman daemon
 

Último

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
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.pdfEnterprise Knowledge
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
[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.pdfhans926745
 
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.pdfsudhanshuwaghmare1
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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)wesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 organizationRadu Cotescu
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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 Servicegiselly40
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 

Último (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
[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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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)
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 

4th European Lisp Symposium: Jobim: an Actors Library for the Clojure Programming Language

  • 1. Jobim: an Actors Library for the Clojure Programming Language Antonio Garrote María N. Moreno García
  • 2. Clojure • New Lisp dialect • Hosted: JVM, CLR • Focus on concurrency: (STM, Agents, futures, fork-join, java.util.concurrent.*)
  • 3. Distributed concurrent applications in Clojure? “Given the diversity, sophistication, maturity, interoperability,robustness etc of these options, it's unlikely I'm going to fiddle around with some language-specific solution.” Rich Hickey
  • 4. Distributed applications on the JVM • JINI • Java Spaces • JMS • Terracota • RabbitMQ • ZeroMQ • Gearman
  • 5. Problems • Different computational models • Hard to port code from one solution to other • Friction with Clojure semantics
  • 6. Extending Clojure • Computational model? • Suitable notation? • Underlying implementation?
  • 7.
  • 9. Actors: components • Named channel (PID) PID • Message box MBox Execution Context • Execution context Computation based on the exchange of messages
  • 10. Actors: mobile processes PID3 PID1 Execution Execution MBox MBox Context Context Msg PID3 PID3 PID2 Execution MBox Context
  • 12. Actors: minimal interface (def *pid* (spawn f)) (is (= *pid* (self))) (send! *pid* msg) (def msg (receive *pid*))
  • 13. Selective Reception (let [p (promise) pid (spawn #(let [a (receive odd?) b (receive even?)] (deliver p [a b])))] (send! pid 2) (send! pid 1) (is (= @p [1 2])))
  • 15. Message Box • Lamina - Z. Tellman (https://github.com/ ztellman/lamina) • Transforms Clojure sequences into event- driven channels • Synchronous and asynchronous interface
  • 16. PIDs/Channel Names • Plain Java strings: easy to exchange • Globally unique identifiers for actors across all the nodes in a Jobim cluster • Generated by Jobim’s runtime • GUID node + process counter
  • 17. Execution context • Threaded actors: - Java thread per actor - End of thread execution, releases resources - Threaded actors do not scale (~2000 threads per node max.)
  • 18. Execution context • Evented actors (Scala): - Actors context = closure + callback functions - Small number of reactor threads execute all the evented threads
  • 19. (spawn #(loop [] (let [[from msg] (receive)] Threaded (send! from msg) (recur)))) (spawn-evented #(react-loop [] (react [[from msg]] Evented (send! from msg) (react-recur))))
  • 20. react-loop Callbacks+Contexts queues Events listen-once Reactor1 ... ReactorN publish react-recur Multiplexer react-future Messages thread- publish handler pool
  • 22. 3 problems Messaging Coordination Serialization
  • 23. Modular solution Protocols: jobim.services.* Messaging Coordination Serialization Plugins
  • 24. Coordination • Name service • Membership groups: presence • Distributed agreement: 2PC protocol
  • 25. Coordination • Apache ZooKeeper plugin - Light-weight - Scalable - Small set of primitives to build sophisticated coordination protocols
  • 26. Coordination: name service - group membership (nodes) (resolve-node-name node-name) (register-name name *pid*) (def *pid* (resolve-name name))
  • 27. Coordination: 2PC - group membership (link *pid1* *pid2*) Signal
  • 28. Messaging • TCP plugin: Netty, Z.Tellman’s Aleph [https://github.com/ztellman/aleph] • RabbitMQ plugin • ZeroMQ plugin
  • 29. Serialization • Java Serialization plugin • JSON plugin • Kryo serialization library plugin (Yahoo S4)
  • 31. Reusing distributed components? • Encapsulate distributed patterns • Hide message passing logic • Building blocks for larger distributed systems • Built using Clojure protocols • Threaded and evented versions
  • 32. Behaviours • Supervisor • Generic Server • FSM • Event Manager / Event Handler • Generic TCP server
  • 33. ;; FSM Lock type (def-fsm Lock (init [this code] [:locked {:so-far [] :code code}]) (next-transition [this state-name state-data message] (let [[topic _] message] (condp = [state-name topic] [:locked :button] handle-button [:open :lock] handle-lock action-ignore))) (handle-info [this current-state current-data message] (do (cond-match [[?from :state] message] (send! from current-state)) (action-next-state current-state current-data))))
  • 34. Demo
  • 35. Future work • Benchmarking + Performance • Packaging / deployment / managing of distributed apps • Missing functionality
  • 36. Code+deps • https://github.com/antoniogarrote/jobim [jobim-core "0.1.2-SNAPSHOT"] [jobim-rabbitmq "0.1.1-SNAPSHOT"] [jobim-zeromq "0.1.1-SNAPSHOT"] *