SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Concurrency, Scalability  & Fault-tolerance 2.0 with Actors & STM by Mario Fusco mario.fusco@gmail.com twitter: @mariofusco
Which are the biggestchallengesin contemporary software development?
Deal with overloadedsystems
Do concurrencyeffectively
Design, develop and deployapplicationsthat scale well
The native Java concurrency model Based on: Threads Semaphores Synchronization Locks They are sometimes plain evil … … and sometimes a necessary pain … … but always the wrong default
Actors: a different model of concurrency ,[object Object]
Share NOTHING
Isolated lightweight processes
Communicates through messages
Asynchronous and non-blocking
Each actor has a mailbox (message queue)
A single thread can managemany (thousands of) actors,[object Object]
What is Akka? ,[object Object]
Written in Scala, butalsoworking in Java
Nowrealeasing 1.0 after 2 years of development (currentlyRC4 available)
Better performances and throughput and smallermemoryfootprint (650 bytes) than native scala actors
Open source (Apache2),[object Object]
Sending message to UntypedActors There are 3 different ways to send a message to an actor: Fire-and-forget ( !  In Scala ) actor.sendOneWay(msg); Uses a Future under the hood, blocking the sender Actor until eithera reply is received or the Future times out ( !!  In Scala ) Object res1 = actor.sendRequestReply(msg); Object res2 = actor.sendRequestReply(msg, 1000); // timeout Explicitly returns a Future ( !!!  In Scala ) Future future= actor.sendRequestReplyFuture(msg); IMPORTANT: Messages can be any kind of object but have to be immutable.  Akkacan’t enforce immutability (yet) so this has to be by convention
Typed Actors public class CounterImplextends TypedActorimplements Counter {     private int counter = 0;     public void count() {         counter++; System.out.println(counter);     }     public intgetCountNr() { returncounter;    } } Counter counter= (Counter)TypedActor              .newInstance(Counter.class, CounterImpl.class, 1000); counter.count(); // Fire-and-forget intcount = counter.getCountNr(); // uses Future under the hood
“Let it crash”  fault-tolerance  through  supervisor hierarchies
You can’t avoid failures: shit happens
What’swrong in trying to preventerrors? Java and other languages and frameworks (not designed with concurrency in mind) signal faults/errors with exceptions Throwing an exception in concurrent code will just simply blow up the thread that currently executes the code that threw it: There is no way to find out that things went wrong, apart from inspecting the stack trace There is nothing you can do to recover from the problem and bring back your system to a normal functioning
Fail fast & build self-repairing systems
Supervisedactors ,[object Object]
Supervised actors also allow you to create sets (hierarchies) of actors where you can be sure that either all are dead or none are dead
That encourages non-defensive programming: don’t try to prevent things from go wrong, because they will. Failures are a natural state in the life-cycle of your app: crash early and let someone else (that sees the whole picture), deal with it
A supervisor is responsible for starting, stopping and monitoring its child processes. It can act with 2 fault handling strategies:One-For-One or All-For-One
Declarative supervised actors configuration Supervisor supervisor = new Supervisor(   new SupervisorConfig(     new AllForOneStrategy(          // or OneForOneStrategy        new Class[]{Exception.class}, // Exceptions to handle        3,           // maximum number of restart retries        5000),       // within time in millis     new Supervise[] {   new Supervise( UntypedActor.actorOf(MyActor1.class),     permanent()), // the actor will always be restarted   new Supervise( UntypedActor.actorOf(MyActor2.class),     temporary())  // the actor won’t be shut down normally })); // You can also link and unlink actors from a supervisor supervisor.link(actor1); supervisor.unlink(actor1);

Weitere ähnliche Inhalte

Was ist angesagt?

Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8RichardWarburton
 
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...Chris Richardson
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Dhaval Dalal
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Mario Fusco
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Trisha Gee
 
Why we cannot ignore Functional Programming
Why we cannot ignore Functional ProgrammingWhy we cannot ignore Functional Programming
Why we cannot ignore Functional ProgrammingMario Fusco
 
Creating Lazy stream in CSharp
Creating Lazy stream in CSharpCreating Lazy stream in CSharp
Creating Lazy stream in CSharpDhaval Dalal
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8Dhaval Dalal
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple ProgramsUpender Upr
 
Jumping-with-java8
Jumping-with-java8Jumping-with-java8
Jumping-with-java8Dhaval Dalal
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical FileSoumya Behera
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manualsameer farooq
 
friends functionToshu
friends functionToshufriends functionToshu
friends functionToshuSidd Singh
 

Was ist angesagt? (20)

Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8Pragmatic functional refactoring with java 8
Pragmatic functional refactoring with java 8
 
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...Map(), flatmap() and reduce() are your new best friends: simpler collections,...
Map(), flatmap() and reduce() are your new best friends: simpler collections,...
 
Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)Currying and Partial Function Application (PFA)
Currying and Partial Function Application (PFA)
 
Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...Reactive Programming for a demanding world: building event-driven and respons...
Reactive Programming for a demanding world: building event-driven and respons...
 
Monadic Java
Monadic JavaMonadic Java
Monadic Java
 
Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)Refactoring to Java 8 (Devoxx BE)
Refactoring to Java 8 (Devoxx BE)
 
Why we cannot ignore Functional Programming
Why we cannot ignore Functional ProgrammingWhy we cannot ignore Functional Programming
Why we cannot ignore Functional Programming
 
CS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUALCS2309 JAVA LAB MANUAL
CS2309 JAVA LAB MANUAL
 
Creating Lazy stream in CSharp
Creating Lazy stream in CSharpCreating Lazy stream in CSharp
Creating Lazy stream in CSharp
 
DRYing to Monad in Java8
DRYing to Monad in Java8DRYing to Monad in Java8
DRYing to Monad in Java8
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
Jumping-with-java8
Jumping-with-java8Jumping-with-java8
Jumping-with-java8
 
Advanced Java Practical File
Advanced Java Practical FileAdvanced Java Practical File
Advanced Java Practical File
 
Java programming lab manual
Java programming lab manualJava programming lab manual
Java programming lab manual
 
Simple Java Programs
Simple Java ProgramsSimple Java Programs
Simple Java Programs
 
Java Lab Manual
Java Lab ManualJava Lab Manual
Java Lab Manual
 
Java 8: the good parts!
Java 8: the good parts!Java 8: the good parts!
Java 8: the good parts!
 
C++ aptitude
C++ aptitudeC++ aptitude
C++ aptitude
 
friends functionToshu
friends functionToshufriends functionToshu
friends functionToshu
 
Ad java prac sol set
Ad java prac sol setAd java prac sol set
Ad java prac sol set
 

Andere mochten auch

Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
Building large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkBuilding large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkVignesh Sukumar
 
未来につながる言語
未来につながる言語未来につながる言語
未来につながる言語yukihiro_matz
 
エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理maruyama097
 
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache SparkLightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache SparkLightbend
 
Slides - Intro to Akka.Cluster
Slides - Intro to Akka.ClusterSlides - Intro to Akka.Cluster
Slides - Intro to Akka.Clusterpetabridge
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentationGene Chang
 
Teratail Study  ~機械学習編#1~
Teratail Study  ~機械学習編#1~Teratail Study  ~機械学習編#1~
Teratail Study  ~機械学習編#1~Kosuke Fujimoto
 
Comparing different concurrency models on the JVM
Comparing different concurrency models on the JVMComparing different concurrency models on the JVM
Comparing different concurrency models on the JVMMario Fusco
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Jonas Bonér
 
Go初心者向けハンズオン コマンドラインツールを作ろう
Go初心者向けハンズオン コマンドラインツールを作ろうGo初心者向けハンズオン コマンドラインツールを作ろう
Go初心者向けハンズオン コマンドラインツールを作ろうTakuya Ueda
 
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache KafkaExploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache KafkaLightbend
 
My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoToru Furukawa
 
粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法Takuya Ueda
 
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けー
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けープログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けー
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けーTanUkkii
 

Andere mochten auch (19)

Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
Building large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor frameworkBuilding large scale, job processing systems with Scala Akka Actor framework
Building large scale, job processing systems with Scala Akka Actor framework
 
未来につながる言語
未来につながる言語未来につながる言語
未来につながる言語
 
エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理エンタープライズ・クラウドと 並列・分散・非同期処理
エンタープライズ・クラウドと 並列・分散・非同期処理
 
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache SparkLightbend Training for Scala, Akka, Play Framework and Apache Spark
Lightbend Training for Scala, Akka, Play Framework and Apache Spark
 
Akka Fundamentals
Akka FundamentalsAkka Fundamentals
Akka Fundamentals
 
Akka Unit Testing
Akka Unit TestingAkka Unit Testing
Akka Unit Testing
 
Slides - Intro to Akka.Cluster
Slides - Intro to Akka.ClusterSlides - Intro to Akka.Cluster
Slides - Intro to Akka.Cluster
 
Akka入門
Akka入門Akka入門
Akka入門
 
SGDによるDeepLearningの学習
SGDによるDeepLearningの学習SGDによるDeepLearningの学習
SGDによるDeepLearningの学習
 
Akka Actor presentation
Akka Actor presentationAkka Actor presentation
Akka Actor presentation
 
Teratail Study  ~機械学習編#1~
Teratail Study  ~機械学習編#1~Teratail Study  ~機械学習編#1~
Teratail Study  ~機械学習編#1~
 
Comparing different concurrency models on the JVM
Comparing different concurrency models on the JVMComparing different concurrency models on the JVM
Comparing different concurrency models on the JVM
 
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
Akka: Simpler Scalability, Fault-Tolerance, Concurrency & Remoting through Ac...
 
Go初心者向けハンズオン コマンドラインツールを作ろう
Go初心者向けハンズオン コマンドラインツールを作ろうGo初心者向けハンズオン コマンドラインツールを作ろう
Go初心者向けハンズオン コマンドラインツールを作ろう
 
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache KafkaExploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
Exploring Reactive Integrations With Akka Streams, Alpakka And Apache Kafka
 
My client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with GoMy client wanted their apps synced, and I made it with Go
My client wanted their apps synced, and I made it with Go
 
粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法粗探しをしてGoのコントリビューターになる方法
粗探しをしてGoのコントリビューターになる方法
 
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けー
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けープログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けー
プログラミング言語のパラダイムシフトーScalaから見る関数型と並列性時代の幕開けー
 

Ähnlich wie Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM

2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2Leonid Maslov
 
Software Transactioneel Geheugen
Software Transactioneel GeheugenSoftware Transactioneel Geheugen
Software Transactioneel GeheugenDevnology
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09Guy Korland
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every dayVadym Khondar
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++ppd1961
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3Jieyi Wu
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actorsbloodredsun
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestPavan Chitumalla
 
Java design patterns
Java design patternsJava design patterns
Java design patternsShawn Brito
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot NetNeeraj Kaushik
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionKent Huang
 

Ähnlich wie Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM (20)

Saving lives with rx java
Saving lives with rx javaSaving lives with rx java
Saving lives with rx java
 
Akka
AkkaAkka
Akka
 
2. Design patterns. part #2
2. Design patterns. part #22. Design patterns. part #2
2. Design patterns. part #2
 
Rx workshop
Rx workshopRx workshop
Rx workshop
 
JavaScript for real men
JavaScript for real menJavaScript for real men
JavaScript for real men
 
Software Transactioneel Geheugen
Software Transactioneel GeheugenSoftware Transactioneel Geheugen
Software Transactioneel Geheugen
 
Ngrx meta reducers
Ngrx meta reducersNgrx meta reducers
Ngrx meta reducers
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
Reactive programming every day
Reactive programming every dayReactive programming every day
Reactive programming every day
 
Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++Generalized Functors - Realizing Command Design Pattern in C++
Generalized Functors - Realizing Command Design Pattern in C++
 
Thread
ThreadThread
Thread
 
Design pattern - part 3
Design pattern - part 3Design pattern - part 3
Design pattern - part 3
 
Martin Anderson - threads v actors
Martin Anderson - threads v actorsMartin Anderson - threads v actors
Martin Anderson - threads v actors
 
2 презентация rx java+android
2 презентация rx java+android2 презентация rx java+android
2 презентация rx java+android
 
Finagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at PinterestFinagle and Java Service Framework at Pinterest
Finagle and Java Service Framework at Pinterest
 
Java design patterns
Java design patternsJava design patterns
Java design patterns
 
Tech talk
Tech talkTech talk
Tech talk
 
Parallel Programming With Dot Net
Parallel Programming With Dot NetParallel Programming With Dot Net
Parallel Programming With Dot Net
 
Clean Code: Chapter 3 Function
Clean Code: Chapter 3 FunctionClean Code: Chapter 3 Function
Clean Code: Chapter 3 Function
 

Mehr von Mario Fusco

Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automationMario Fusco
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APIMario Fusco
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...Mario Fusco
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep diveMario Fusco
 
Real world DSL - making technical and business people speaking the same language
Real world DSL - making technical and business people speaking the same languageReal world DSL - making technical and business people speaking the same language
Real world DSL - making technical and business people speaking the same languageMario Fusco
 
Introducing Drools
Introducing DroolsIntroducing Drools
Introducing DroolsMario Fusco
 
No more loops with lambdaj
No more loops with lambdajNo more loops with lambdaj
No more loops with lambdajMario Fusco
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meetMario Fusco
 

Mehr von Mario Fusco (11)

Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automation
 
Let's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java APILet's make a contract: the art of designing a Java API
Let's make a contract: the art of designing a Java API
 
How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...How and why I turned my old Java projects into a first-class serverless compo...
How and why I turned my old Java projects into a first-class serverless compo...
 
OOP and FP
OOP and FPOOP and FP
OOP and FP
 
Lazy java
Lazy javaLazy java
Lazy java
 
Drools 6 deep dive
Drools 6 deep diveDrools 6 deep dive
Drools 6 deep dive
 
Real world DSL - making technical and business people speaking the same language
Real world DSL - making technical and business people speaking the same languageReal world DSL - making technical and business people speaking the same language
Real world DSL - making technical and business people speaking the same language
 
Introducing Drools
Introducing DroolsIntroducing Drools
Introducing Drools
 
Hammurabi
HammurabiHammurabi
Hammurabi
 
No more loops with lambdaj
No more loops with lambdajNo more loops with lambdaj
No more loops with lambdaj
 
Scala - where objects and functions meet
Scala - where objects and functions meetScala - where objects and functions meet
Scala - where objects and functions meet
 

Kürzlich hochgeladen

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
 
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
 
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
 
[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
 
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 slidevu2urc
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
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 productivityPrincipled Technologies
 
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.pptxEarley Information Science
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
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 WorkerThousandEyes
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
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
 
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
 
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 Processorsdebabhi2
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 

Kürzlich hochgeladen (20)

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
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
[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
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
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
 
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
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
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
 
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
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
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
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 

Concurrency, Scalability & Fault-tolerance 2.0 with Akka Actors & STM

  • 1. Concurrency, Scalability & Fault-tolerance 2.0 with Actors & STM by Mario Fusco mario.fusco@gmail.com twitter: @mariofusco
  • 2. Which are the biggestchallengesin contemporary software development?
  • 5. Design, develop and deployapplicationsthat scale well
  • 6. The native Java concurrency model Based on: Threads Semaphores Synchronization Locks They are sometimes plain evil … … and sometimes a necessary pain … … but always the wrong default
  • 7.
  • 12. Each actor has a mailbox (message queue)
  • 13.
  • 14.
  • 15. Written in Scala, butalsoworking in Java
  • 16. Nowrealeasing 1.0 after 2 years of development (currentlyRC4 available)
  • 17. Better performances and throughput and smallermemoryfootprint (650 bytes) than native scala actors
  • 18.
  • 19. Sending message to UntypedActors There are 3 different ways to send a message to an actor: Fire-and-forget ( ! In Scala ) actor.sendOneWay(msg); Uses a Future under the hood, blocking the sender Actor until eithera reply is received or the Future times out ( !! In Scala ) Object res1 = actor.sendRequestReply(msg); Object res2 = actor.sendRequestReply(msg, 1000); // timeout Explicitly returns a Future ( !!! In Scala ) Future future= actor.sendRequestReplyFuture(msg); IMPORTANT: Messages can be any kind of object but have to be immutable. Akkacan’t enforce immutability (yet) so this has to be by convention
  • 20. Typed Actors public class CounterImplextends TypedActorimplements Counter { private int counter = 0; public void count() { counter++; System.out.println(counter); } public intgetCountNr() { returncounter; } } Counter counter= (Counter)TypedActor .newInstance(Counter.class, CounterImpl.class, 1000); counter.count(); // Fire-and-forget intcount = counter.getCountNr(); // uses Future under the hood
  • 21. “Let it crash” fault-tolerance through supervisor hierarchies
  • 22. You can’t avoid failures: shit happens
  • 23. What’swrong in trying to preventerrors? Java and other languages and frameworks (not designed with concurrency in mind) signal faults/errors with exceptions Throwing an exception in concurrent code will just simply blow up the thread that currently executes the code that threw it: There is no way to find out that things went wrong, apart from inspecting the stack trace There is nothing you can do to recover from the problem and bring back your system to a normal functioning
  • 24. Fail fast & build self-repairing systems
  • 25.
  • 26. Supervised actors also allow you to create sets (hierarchies) of actors where you can be sure that either all are dead or none are dead
  • 27. That encourages non-defensive programming: don’t try to prevent things from go wrong, because they will. Failures are a natural state in the life-cycle of your app: crash early and let someone else (that sees the whole picture), deal with it
  • 28. A supervisor is responsible for starting, stopping and monitoring its child processes. It can act with 2 fault handling strategies:One-For-One or All-For-One
  • 29. Declarative supervised actors configuration Supervisor supervisor = new Supervisor( new SupervisorConfig( new AllForOneStrategy( // or OneForOneStrategy new Class[]{Exception.class}, // Exceptions to handle 3, // maximum number of restart retries 5000), // within time in millis new Supervise[] { new Supervise( UntypedActor.actorOf(MyActor1.class), permanent()), // the actor will always be restarted new Supervise( UntypedActor.actorOf(MyActor2.class), temporary()) // the actor won’t be shut down normally })); // You can also link and unlink actors from a supervisor supervisor.link(actor1); supervisor.unlink(actor1);
  • 30.
  • 31. Uses a very efficient and scalable I/O implementation built upon JBossNetty and Google Protocol Buffers
  • 32. Can be secured with a cookie authentication mechanism
  • 33. Can be bothTyped and Untyped
  • 35. server-managed: run on the machine thatcreateditwhile client can lookup and obtain a proxy
  • 36.
  • 37.
  • 38. Consistent: a transaction gets a consistent of reality
  • 39.
  • 41. are managed and enforced by the STM for coordinated changes across many Refs
  • 42.
  • 44.
  • 45. In this case an (exponential) delay isused to preventfurthercontentions
  • 46.
  • 48. Coordinating Actors with STM public class Counter extends UntypedActor { private Ref<Integer> count = new Ref(0); private void increment() { count.set(count.get() + 1); } public void onReceive(Object incoming) throws Exception { if (incoming instanceof Coordinated) { Coordinated coordinated = (Coordinated) incoming; Object message = coordinated.getMessage(); if (message instanceof Increment) { Increment increment = (Increment) message; if (increment.hasFriend()) { increment.getFriend() .sendOneWay(coordinated.coordinate(new Increment())); } coordinated.atomic(new Atomically() { public void atomically() { increment(); } }); }}}}
  • 49. Actors + STM = Transactors public class Counter extends UntypedTransactor { Ref<Integer> count = new Ref<Integer>(0); @Override public Set<SendTo> coordinate(Object message) { if (message instanceof Increment) { Increment increment = (Increment) message; if (increment.hasFriend()) return include(increment.getFriend(), new Increment()); } return nobody(); } public void atomically(Object message) { if (message instanceof Increment) { count.set(count.get() + 1); } } }
  • 50.
  • 52. PersistencemodulesupportingmanyNoSQL DB like: Cassandra, MongoDB, Riak, Redis, Terrastore, CouchDB, Voldemort, Hbase
  • 53. Integration betweenAkkaSTM and JTA (Java Transaction API)
  • 55. Integration with Spring allowing to defineTyped Actors as Spring managed bean
  • 56.