SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Downloaden Sie, um offline zu lesen
Concurrency for dummies
 and for real people too




               By
       Azrul Hasni Mad Isa
(azrul.madisa@my.experian.com)
About me
• Senior Software
  Architect at Experian
  Decision Analytics
• 10 years of experience in
  IT and such
• Graduated from France
  (INSA)
About Experian
• In Cyberjaya
   – Other R&D Centres in
     Nottingham, Monaco,
     Washington
• Financial analytics, market
  analytics
• 200+ people and growing
• We use Scrum
• We are looking for people
   – Java, PHP, Perl, C#
   – Dev, QA, Architects, Team
     lead
Introduction
• What is concurrency
        Concurrency is a property of systems
        in which several computations are
        executing        simultaneously,      and
        potentially interacting with each other


        -- Wikipedia
Introduction
• Why concurrent applications are important
Introduction
• Our business processes are getting more
  complex!
Business case for concurrency
• E-commerce
                                Buy Product
                                  Online

User
                                Parallel Split


                                          Charge Credit Card
             “Your request is
             being process”                 Check availability

                                            Reserve product

                                           Email confirmation
Business case for concurrency
• Financial – credit verification

                                              CCRIS
                      Apply Credit Card


                    Credential Verification   Equifax
User

                      Decision making
                                              Experian

                        Approve/Not
Business case for concurrency
• Logistics
                Arrival of merchandises


                For every merchandise


                              Parallel Split



              Custom & Port       Warehousing     Quality check
     …          authority



                                 Transportation
Business case for concurrency
• Many others …
Model for concurrency management
•   Actors
•   Agents
•   Dataflow
•   Stm
•   Data paralellism
    – Concurrent collections
    – Asynchronous functions (closure)
    – Fork/Join
Model for concurrency management
•   Actors
•   Agents
•   Dataflow
•   Stm
•   Data paralellism
    – Concurrent collections
    – Asynchronous functions (closure)
    – Fork/Join
GPARS
GPars
• Gpars is a concurrency
  management library for
  Groovy and Java
• Allow running models
  presented above
• http://gpars.codehaus.org/
ACTORS
Actors
• Why couldn’t they call ‘em actresses instead?
• A body of code that:
  – Receive a message asynchronously
  – React to a message if it can
  – Queue a received message if it’s busy
  – Asynchronous messaging (JMS)
Actor
• Synchronous messaging = immediate reply

          The Nora Elena
        actress is soo cute!




                                   Why You !! You !!...
                                     I’ll kill you!!
Actor
• Asynchronous messaging = non-immediate
  reply
  – We can do other things while waiting
                 Could you please
                make me a drink? …
                I’m going to ponder
               about the meaning of
                life in the meantime
Actor
• Asynchronous messaging = non-immediate
  reply
  – We can do other things while waiting
                 Could you please
                make me a drink? …
                I’m going to ponder
               about the meaning of               2 hours later
                life in the meantime




                                       I was watching TV.
                                       Go make the drink
                                            yourself!
Actors


       Queue                          Queue


               “sending a
OneActor       message”     AnotherActor
Actors


       Queue    “reply to a             Queue
                message”


OneActor                      AnotherActor
Actors
• Example: DefaultActor {
  class MyActor extends
      Actor anotherActor
      void act() {
          loop {
                       anotherActor.send “Hello” //send message to someone
                       react { String message -> //message could be any POGO
                      …//do something
                       reply someReply //some reply is any POGO
                       …
                       terminate() //kill the actor *gasp!*
                  }
              }
          }
      }
  }
Actors
• Two types
  – Stateless : DynamicDispatchActor
  – Stateful: DefaultActor
• Actors are can share a common
  threadpool
• Threadpool + statelessness =
  SCALABILITY
• No remote actors yet
Actor
• Some methods
  – loop
     • Infinite loop on the actor
  – react
     • React on message received
  – send
     • Send a message
  – reply
     • Reply to a message
Actor
• Cool stuff
  – Loop counting
  – Code in actors are guaranteed to be thread safe
  – Life cycle methods
  – Dealing with unsent messages
     • Business Process Compensation
  – Remote actors – coming
DATAFLOW
Dataflow
• First introduced in a language called Oz
  – Composed of tasks
  – Each task has input and output
  – A task is run as soon as all its input are available
Dataflow
Not executed

    Task
   print z

    Task
   z = a+b

  Task
  b=32

  Task
  a=20
Dataflow
Not executed   First round                       Executed

    Task          Task
   print z       print z

    Task         Task
   z = a+b       z = a+b

  Task          Task
  b=32          b=32           No input needed

  Task          Task
  a=20          a=20
Dataflow
Not executed   First round    Second round               Executed

    Task          Task          Task
   print z       print z       print z

    Task         Task           Task
   z = a+b       z = a+b       z = a+b
                                             Input, a and b,
  Task          Task           Task             becomes
  b=32          b=32           b=32             available

  Task          Task           Task
  a=20          a=20           a=20
Dataflow
Not executed   First round       Second round   Third round

    Task          Task              Task          Task
   print z       print z     Input,print z
                                    z,            print z
                             becomes
    Task         Task        available
                                    Task          Task
   z = a+b       z = a+b           z = a+b       z = a+b

  Task          Task              Task           Task
  b=32          b=32              b=32           b=32

  Task          Task              Task           Task
  a=20          a=20              a=20           a=20
Dataflow: code
final def x = new DataFlowVariable()
final def y = new DataFlowVariable()
final def z = new DataFlowVariable()

task {
  z << x.val + y.val
}

task {
  x << 10
}

task {
  y << 5
}

println "Result: ${z.val}"
Dataflow: principles
• Create a dataflow variable
   – The variable can be written once
     only
• Read it
   – If it has no value yet, the program
     will wait for the new value while
     executing other tasks
• Write to it
   – The moment a variable is written
     (or bounded) any task waiting for
     this variable will be reactivated
Dataflow: beauty
• “Declarative” concurrency
• Clean code
  – Business logic is much more obvious
  – Business logic can be sequential
• Flow is deterministic
• If no deadlock in unit test, it is guaranteed
  that there will be no deadlocks in production.
Dataflow in business process
               Apply Credit Card


                 Parallel split


       CCRIS        Equifax        Experian


                  Parallel join

               Decision making


                 Approve/Not
Dataflow in business process
                       Apply Credit Card


Do business              Parallel split
users really
  think in
               CCRIS        Equifax        Experian
  Parallel
executions?
                          Parallel join

                       Decision making


                         Approve/Not
Dataflow in business process
 I want to verify user
  credentials against
CCRIS, Experian and       You need parallel
       Equifax               processing




Business                 Solution
                         architect
stakeholder
Dataflow in business process
                         Suggestion by the solution architect

 I want to verify user
  credentials against
CCRIS, Experian and              You need parallel
       Equifax                      processing




Business                        Solution
                                architect
stakeholder
Dataflow in business process
• Meanwhile, in a parallel universe … pun intended ☺

    I want to verify user   Dataflow Tasks        OK?
     credentials against    Apply Credit Card
   CCRIS, Experian and
          Equifax                CCRIS
                                Equifax
                               Experian
                            Decision making
                              Approve/Not
                                                Solution
    Business                                    architect
   stakeholder
Dataflow in business process
• Meanwhile, in a parallel universe                Parallel
                                                 execution is
                                                    done
              Hey, I totally get that!          automatically
              I totally want to give              by GPars
              you more business!                  Dataflow
                Would you like a
                  pony too?



   Business                              Solution
                                         architect
  stakeholder
Dataflow in business process
• Meanwhile, in a parallel universe

                                  Yes please




                                  Solution
                                  architect
Conclusion
• Actor
  – Asynchronous messaging
• Dataflow
  – “Declarative” concurrency
Conclusion
• What we see is merely the tip of
  the iceberg
• Explore yourself
   – http://gpars.codehaus.org/
   – http://groovy.codehaus.org/
   – http://en.wikipedia.org/wiki/Acto
     r_model
   – http://en.wikipedia.org/wiki/Data
     flow
• My contact:
  azrul.madisa@my.experian.com

Weitere ähnliche Inhalte

Ähnlich wie Concurrency for dummies

Functional Programming and Composing Actors
Functional Programming and Composing ActorsFunctional Programming and Composing Actors
Functional Programming and Composing Actorslegendofklang
 
Functional solid
Functional solidFunctional solid
Functional solidMatt Stine
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven DevelopmentMarakana Inc.
 
FP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleFP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleChristophe Grand
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...JAX London
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++Mike Acton
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkVictor Rentea
 
Inventing the future Business Programming Language
Inventing the future  Business Programming LanguageInventing the future  Business Programming Language
Inventing the future Business Programming LanguageESUG
 
Pivotal tracker presentation 10-13-2010
Pivotal tracker presentation   10-13-2010Pivotal tracker presentation   10-13-2010
Pivotal tracker presentation 10-13-2010pivotjoe
 
Unraveling the mystery of monads
Unraveling the mystery of monadsUnraveling the mystery of monads
Unraveling the mystery of monadsFaisal Waris
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Fwdays
 
Actors: Not Just for Movies Anymore
Actors: Not Just for Movies AnymoreActors: Not Just for Movies Anymore
Actors: Not Just for Movies AnymoreVictorOps
 
Outbrain River Presentation at Reversim Summit 2013
Outbrain River Presentation at Reversim Summit 2013Outbrain River Presentation at Reversim Summit 2013
Outbrain River Presentation at Reversim Summit 2013Harel Ben-Attia
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015Ben Lesh
 
The disaster of mutable state
The disaster of mutable stateThe disaster of mutable state
The disaster of mutable statekenbot
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05lrdesign
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrencyAlex Miller
 

Ähnlich wie Concurrency for dummies (20)

Functional Programming and Composing Actors
Functional Programming and Composing ActorsFunctional Programming and Composing Actors
Functional Programming and Composing Actors
 
Functional solid
Functional solidFunctional solid
Functional solid
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
FP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit HoleFP Days: Down the Clojure Rabbit Hole
FP Days: Down the Clojure Rabbit Hole
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 
Data oriented design and c++
Data oriented design and c++Data oriented design and c++
Data oriented design and c++
 
The Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring FrameworkThe Proxy Fairy, and The Magic of Spring Framework
The Proxy Fairy, and The Magic of Spring Framework
 
Inventing the future Business Programming Language
Inventing the future  Business Programming LanguageInventing the future  Business Programming Language
Inventing the future Business Programming Language
 
Pivotal tracker presentation 10-13-2010
Pivotal tracker presentation   10-13-2010Pivotal tracker presentation   10-13-2010
Pivotal tracker presentation 10-13-2010
 
Unraveling the mystery of monads
Unraveling the mystery of monadsUnraveling the mystery of monads
Unraveling the mystery of monads
 
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
Алексей Ященко и Ярослав Волощук "False simplicity of front-end applications"
 
Actors: Not Just for Movies Anymore
Actors: Not Just for Movies AnymoreActors: Not Just for Movies Anymore
Actors: Not Just for Movies Anymore
 
Outbrain River Presentation at Reversim Summit 2013
Outbrain River Presentation at Reversim Summit 2013Outbrain River Presentation at Reversim Summit 2013
Outbrain River Presentation at Reversim Summit 2013
 
RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015RxJS and Reactive Programming - Modern Web UI - May 2015
RxJS and Reactive Programming - Modern Web UI - May 2015
 
The disaster of mutable state
The disaster of mutable stateThe disaster of mutable state
The disaster of mutable state
 
Let's Get to the Rapids
Let's Get to the RapidsLet's Get to the Rapids
Let's Get to the Rapids
 
How to-node-core
How to-node-coreHow to-node-core
How to-node-core
 
Message passing
Message passingMessage passing
Message passing
 
NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05NinjaScript and Mizugumo 2011-02-05
NinjaScript and Mizugumo 2011-02-05
 
Groovy concurrency
Groovy concurrencyGroovy concurrency
Groovy concurrency
 

Kürzlich hochgeladen

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
 
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 MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
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 MenDelhi Call girls
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
🐬 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
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
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
 

Kürzlich hochgeladen (20)

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...
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
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
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
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
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
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
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
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
 

Concurrency for dummies

  • 1. Concurrency for dummies and for real people too By Azrul Hasni Mad Isa (azrul.madisa@my.experian.com)
  • 2. About me • Senior Software Architect at Experian Decision Analytics • 10 years of experience in IT and such • Graduated from France (INSA)
  • 3. About Experian • In Cyberjaya – Other R&D Centres in Nottingham, Monaco, Washington • Financial analytics, market analytics • 200+ people and growing • We use Scrum • We are looking for people – Java, PHP, Perl, C# – Dev, QA, Architects, Team lead
  • 4. Introduction • What is concurrency Concurrency is a property of systems in which several computations are executing simultaneously, and potentially interacting with each other -- Wikipedia
  • 5. Introduction • Why concurrent applications are important
  • 6. Introduction • Our business processes are getting more complex!
  • 7. Business case for concurrency • E-commerce Buy Product Online User Parallel Split Charge Credit Card “Your request is being process” Check availability Reserve product Email confirmation
  • 8. Business case for concurrency • Financial – credit verification CCRIS Apply Credit Card Credential Verification Equifax User Decision making Experian Approve/Not
  • 9. Business case for concurrency • Logistics Arrival of merchandises For every merchandise Parallel Split Custom & Port Warehousing Quality check … authority Transportation
  • 10. Business case for concurrency • Many others …
  • 11. Model for concurrency management • Actors • Agents • Dataflow • Stm • Data paralellism – Concurrent collections – Asynchronous functions (closure) – Fork/Join
  • 12. Model for concurrency management • Actors • Agents • Dataflow • Stm • Data paralellism – Concurrent collections – Asynchronous functions (closure) – Fork/Join
  • 13. GPARS
  • 14. GPars • Gpars is a concurrency management library for Groovy and Java • Allow running models presented above • http://gpars.codehaus.org/
  • 16. Actors • Why couldn’t they call ‘em actresses instead? • A body of code that: – Receive a message asynchronously – React to a message if it can – Queue a received message if it’s busy – Asynchronous messaging (JMS)
  • 17. Actor • Synchronous messaging = immediate reply The Nora Elena actress is soo cute! Why You !! You !!... I’ll kill you!!
  • 18. Actor • Asynchronous messaging = non-immediate reply – We can do other things while waiting Could you please make me a drink? … I’m going to ponder about the meaning of life in the meantime
  • 19. Actor • Asynchronous messaging = non-immediate reply – We can do other things while waiting Could you please make me a drink? … I’m going to ponder about the meaning of 2 hours later life in the meantime I was watching TV. Go make the drink yourself!
  • 20. Actors Queue Queue “sending a OneActor message” AnotherActor
  • 21. Actors Queue “reply to a Queue message” OneActor AnotherActor
  • 22. Actors • Example: DefaultActor { class MyActor extends Actor anotherActor void act() { loop { anotherActor.send “Hello” //send message to someone react { String message -> //message could be any POGO …//do something reply someReply //some reply is any POGO … terminate() //kill the actor *gasp!* } } } } }
  • 23. Actors • Two types – Stateless : DynamicDispatchActor – Stateful: DefaultActor • Actors are can share a common threadpool • Threadpool + statelessness = SCALABILITY • No remote actors yet
  • 24. Actor • Some methods – loop • Infinite loop on the actor – react • React on message received – send • Send a message – reply • Reply to a message
  • 25. Actor • Cool stuff – Loop counting – Code in actors are guaranteed to be thread safe – Life cycle methods – Dealing with unsent messages • Business Process Compensation – Remote actors – coming
  • 27. Dataflow • First introduced in a language called Oz – Composed of tasks – Each task has input and output – A task is run as soon as all its input are available
  • 28. Dataflow Not executed Task print z Task z = a+b Task b=32 Task a=20
  • 29. Dataflow Not executed First round Executed Task Task print z print z Task Task z = a+b z = a+b Task Task b=32 b=32 No input needed Task Task a=20 a=20
  • 30. Dataflow Not executed First round Second round Executed Task Task Task print z print z print z Task Task Task z = a+b z = a+b z = a+b Input, a and b, Task Task Task becomes b=32 b=32 b=32 available Task Task Task a=20 a=20 a=20
  • 31. Dataflow Not executed First round Second round Third round Task Task Task Task print z print z Input,print z z, print z becomes Task Task available Task Task z = a+b z = a+b z = a+b z = a+b Task Task Task Task b=32 b=32 b=32 b=32 Task Task Task Task a=20 a=20 a=20 a=20
  • 32. Dataflow: code final def x = new DataFlowVariable() final def y = new DataFlowVariable() final def z = new DataFlowVariable() task { z << x.val + y.val } task { x << 10 } task { y << 5 } println "Result: ${z.val}"
  • 33. Dataflow: principles • Create a dataflow variable – The variable can be written once only • Read it – If it has no value yet, the program will wait for the new value while executing other tasks • Write to it – The moment a variable is written (or bounded) any task waiting for this variable will be reactivated
  • 34. Dataflow: beauty • “Declarative” concurrency • Clean code – Business logic is much more obvious – Business logic can be sequential • Flow is deterministic • If no deadlock in unit test, it is guaranteed that there will be no deadlocks in production.
  • 35. Dataflow in business process Apply Credit Card Parallel split CCRIS Equifax Experian Parallel join Decision making Approve/Not
  • 36. Dataflow in business process Apply Credit Card Do business Parallel split users really think in CCRIS Equifax Experian Parallel executions? Parallel join Decision making Approve/Not
  • 37. Dataflow in business process I want to verify user credentials against CCRIS, Experian and You need parallel Equifax processing Business Solution architect stakeholder
  • 38. Dataflow in business process Suggestion by the solution architect I want to verify user credentials against CCRIS, Experian and You need parallel Equifax processing Business Solution architect stakeholder
  • 39. Dataflow in business process • Meanwhile, in a parallel universe … pun intended ☺ I want to verify user Dataflow Tasks OK? credentials against Apply Credit Card CCRIS, Experian and Equifax CCRIS Equifax Experian Decision making Approve/Not Solution Business architect stakeholder
  • 40. Dataflow in business process • Meanwhile, in a parallel universe Parallel execution is done Hey, I totally get that! automatically I totally want to give by GPars you more business! Dataflow Would you like a pony too? Business Solution architect stakeholder
  • 41. Dataflow in business process • Meanwhile, in a parallel universe Yes please Solution architect
  • 42. Conclusion • Actor – Asynchronous messaging • Dataflow – “Declarative” concurrency
  • 43. Conclusion • What we see is merely the tip of the iceberg • Explore yourself – http://gpars.codehaus.org/ – http://groovy.codehaus.org/ – http://en.wikipedia.org/wiki/Acto r_model – http://en.wikipedia.org/wiki/Data flow • My contact: azrul.madisa@my.experian.com