SlideShare ist ein Scribd-Unternehmen logo
1 von 36
Downloaden Sie, um offline zu lesen
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"] *

Weitere ähnliche Inhalte

Was ist angesagt?

NS-2 Tutorial
NS-2 TutorialNS-2 Tutorial
NS-2 Tutorial
code453
 
Kafka replication apachecon_2013
Kafka replication apachecon_2013Kafka replication apachecon_2013
Kafka replication apachecon_2013
Jun Rao
 
Network emulator
Network emulatorNetwork emulator
Network emulator
jeromy fu
 

Was ist angesagt? (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
 

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

Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101Unified Messaging and Data Streaming 101
Unified Messaging and Data Streaming 101
Timothy Spann
 
Scaling Django with gevent
Scaling Django with geventScaling Django with gevent
Scaling Django with gevent
Mahendra M
 

Ähnlich wie 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
 

Mehr von 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
 

Kürzlich hochgeladen

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
Enterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

[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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
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...
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
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
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

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"] *