SlideShare une entreprise Scribd logo
1  sur  29
Building Reactive Systems with Akka
Today’s Agenda
 Part 1 – Introduction to Akka
 Part 2 – Scala Crash Course™
 Part 3 – Hello Reactive World
 Part 4 – A more complex example
Part 1 – Introduction to Akka
Problems with traditional systems
 Extreme growth of data and number of clients
 Mobile web (*), Internet of Things, etc.
 Threads won’t scale
 1 thread for each user
 1 Mb minimum stack size / thread on 64 bit VMs
 10 000 concurrent users => do the math 
 Existing programming models won’t scale either
 Writing bug-free thread synchronization / locking code manually is extreme hard
 Mutable state is the root of all evil
 Mutable state is the basic idea of Object Oriented Programming.. (oops)
 Polling sucks, we live in a realtime world
Properties of Reactive Systems
 Responsive
 Gives low-latency responses even for overloaded systems
 Resilient
 Stays responsive even upon system failures
 Message driven
 Asynchronous and non-blocking, concurrent by design
 Has no mutable shared state
 Elastic
 Can scale out horizontally on demand
Introducing Akka
 A framework and runtime engine for building reactive systems on the JVM
 Implements the Actor model (mathematical model of Carl Hewitt, 1973)
 Asynchronous, distributed by design
 Resilient and self-healing system (motto: “Let it crash”)
 High performance
 50 million message / sec
 2.5 million actor instances per GB of heap space
 Written in the Scala language, has Scala and Java bindings
 Open source with Apache2 license, commercially supported by Typesafe Inc.
Introducing Akka Actors
 Actors are the base building blocks of actor systems
 Actors are lightweight objects
 ~300 bytes / instance
 Encapsulate state and behavior
 Have no shared state ever
 Actors are asynchronous and non-blocking
 Communicate only via message passing
 Have a mailbox for inbound messages
 Always process messages in order
 Actors live in hierarchy
 Used for supervising
 Actors have a reference
 Phone number analogy
Part 2 – Scala Crash Course™
The Scala language
 Strong static type system
 Compiles to Java bytecode, runs on the JVM
 Mixes object-oriented and functional style
 Designed by Martin Odersky (javac)
 Publicly available since 2004
 Commercial support by Typesafe Inc. since 2011
Scala Crash Course in 9 lines
 Things to observe:
 Packages, objects and classes
 Constructor in object body
 Values and method calls
 Also note there are:
 no semicolons (;)
Scala Crash Course in 9 lines
 Things to observe:
 Packages, objects and classes
 Constructor in object body
 Values and method calls
 Method definitions
 Also note there are:
 no semicolons (;)
 no explicit types, unless necessary
Scala Crash Course in 9 lines
 Things to observe:
 Packages, objects and classes
 Constructor in object body
 Values and method calls
 Method definitions
 Case classes
 Also note there are:
 no semicolons (;)
 no explicit types, unless necessary
 no unnecessary braces ({ } ( ))
Scala Crash Course in 9 lines
 Things to observe:
 Packages, objects and classes
 Constructor in object body
 Values and method calls
 Method definitions
 Case classes
 Higher order functions
 String interpolation
 Also note there are:
 no semicolons (;)
 no unnecessary braces ({ } ( ))
 no explicit types, unless necessary
Part 3 – Hello Reactive World
Akka basics in Scala
 Actors live in an ActorSystem
 val system = ActorSystem(“hello”)
 Actors are created via Props (factories)
 val actor: ActorRef = system.actorOf(Props(classOf[MyActor.class]))
 Messages are most often plain case classes / case objects
 case class HelloMessage(message: String)
 ActorRefs are used to send messages
 actor ! HelloMessage(s“hello from $self”)
Akka HelloWorld
Part 4 – A more complex example
Building a Twitter streamer
 Twitter == poor man’s Big Data (up to 50msg/sec)
 Goal: Build a web application which displays the Twitter stream
and the number of connected users
 Tech stack
 Twitter4J – twitter API
 Play! – Scala web framework with WebSocket support, built on Akka
 Akka – actors based middleware
 Websocket JS API, JQuery, Bootstrap CSS
 Gatling – stress test tool
Demo
A reactive architecture
 System components:
 Akka Event Bus
 Play! Framework controller
 Actors in the system:
 1 x Streamer – connects to Twitter, receives status updates
 n x WSProxy – proxies events via WebSocket to client
 1 x ClientsTracker – tracks the number of clients, publishes the number every N seconds
 WebSocket in the browser:
 Registers with Play! controller, connects to Actor
 Receives push messages in JSON
 Replaces DOM with JQuery
Areactivearchitecture
Code review
Code review - Streamer actor
Code review - ClientsTracker actor
Code review - WSProxy actor
Code review - Play! controller class
WebSocket JS code
Demo – Load Test
Resources
 Twitter streamer source - https://github.com/kjozsa/reactive2
 Akka - http://akka.io/
 Play! Framework - https://playframework.com/

Contenu connexe

Tendances

Java 201 Intro to Test Driven Development in Java
Java 201   Intro to Test Driven Development in JavaJava 201   Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Javaagorolabs
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to ScalaRahul Jain
 
Semantic DEX Components
Semantic DEX ComponentsSemantic DEX Components
Semantic DEX ComponentsDavid Price
 
Introduction To MacWire
Introduction To MacWireIntroduction To MacWire
Introduction To MacWireKnoldus Inc.
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaiUnmesh Baile
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in ScalaRose Toomey
 
Tonel repositories in VA Smalltalk by Esteban Maringolo
Tonel repositories in VA Smalltalk by Esteban MaringoloTonel repositories in VA Smalltalk by Esteban Maringolo
Tonel repositories in VA Smalltalk by Esteban MaringoloFAST
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSteve Fort
 
Java 101 Intro to Java Programming - Exercises
Java 101   Intro to Java Programming - ExercisesJava 101   Intro to Java Programming - Exercises
Java 101 Intro to Java Programming - Exercisesagorolabs
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PunePankaj kshirsagar
 
Real-World Scala Design Patterns
Real-World Scala Design PatternsReal-World Scala Design Patterns
Real-World Scala Design PatternsNLJUG
 

Tendances (20)

Java 201 Intro to Test Driven Development in Java
Java 201   Intro to Test Driven Development in JavaJava 201   Intro to Test Driven Development in Java
Java 201 Intro to Test Driven Development in Java
 
Introduction to Scala
Introduction to ScalaIntroduction to Scala
Introduction to Scala
 
Semantic DEX Components
Semantic DEX ComponentsSemantic DEX Components
Semantic DEX Components
 
Introduction To MacWire
Introduction To MacWireIntroduction To MacWire
Introduction To MacWire
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 
java-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbaijava-corporate-training-institute-in-mumbai
java-corporate-training-institute-in-mumbai
 
Practical type mining in Scala
Practical type mining in ScalaPractical type mining in Scala
Practical type mining in Scala
 
Tonel repositories in VA Smalltalk by Esteban Maringolo
Tonel repositories in VA Smalltalk by Esteban MaringoloTonel repositories in VA Smalltalk by Esteban Maringolo
Tonel repositories in VA Smalltalk by Esteban Maringolo
 
Core java
Core javaCore java
Core java
 
Java
JavaJava
Java
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Java 101 Intro to Java Programming - Exercises
Java 101   Intro to Java Programming - ExercisesJava 101   Intro to Java Programming - Exercises
Java 101 Intro to Java Programming - Exercises
 
RIBBUN SOFTWARE
RIBBUN SOFTWARERIBBUN SOFTWARE
RIBBUN SOFTWARE
 
Java intro
Java introJava intro
Java intro
 
Java01
Java01Java01
Java01
 
Java fundamentals 2
Java fundamentals 2Java fundamentals 2
Java fundamentals 2
 
Java interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council PuneJava interview questions and answers for cognizant By Data Council Pune
Java interview questions and answers for cognizant By Data Council Pune
 
Real-World Scala Design Patterns
Real-World Scala Design PatternsReal-World Scala Design Patterns
Real-World Scala Design Patterns
 
C Sharp Course 101.5
C Sharp Course 101.5C Sharp Course 101.5
C Sharp Course 101.5
 

En vedette

Travel Portfolio
Travel PortfolioTravel Portfolio
Travel Portfoliochrissnyny
 
WebSocket bemutatás
WebSocket bemutatásWebSocket bemutatás
WebSocket bemutatásKristof Jozsa
 
Jasig-sakai2012-communitytranslation-kajita
Jasig-sakai2012-communitytranslation-kajitaJasig-sakai2012-communitytranslation-kajita
Jasig-sakai2012-communitytranslation-kajitaShoji Kajita
 
Introduction to Big Data
Introduction to Big DataIntroduction to Big Data
Introduction to Big DataKristof Jozsa
 
50 ans d'anticipation n°5 : le journal de TNS Sofres
50 ans d'anticipation n°5 : le journal de TNS Sofres50 ans d'anticipation n°5 : le journal de TNS Sofres
50 ans d'anticipation n°5 : le journal de TNS SofresKantar
 
Pourquoi créer un bulletin paroissial électronique
Pourquoi créer un bulletin paroissial électroniquePourquoi créer un bulletin paroissial électronique
Pourquoi créer un bulletin paroissial électroniqueftr_
 
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...Arnaud A.
 
Etude de marché Beiersdorf/Nivea
Etude de marché Beiersdorf/NiveaEtude de marché Beiersdorf/Nivea
Etude de marché Beiersdorf/NiveaEdouard Kinziger
 

En vedette (12)

Travel Portfolio
Travel PortfolioTravel Portfolio
Travel Portfolio
 
Chris Sanders
Chris SandersChris Sanders
Chris Sanders
 
Diablo II
Diablo IIDiablo II
Diablo II
 
Lifestyle
LifestyleLifestyle
Lifestyle
 
WebSocket bemutatás
WebSocket bemutatásWebSocket bemutatás
WebSocket bemutatás
 
Jasig-sakai2012-communitytranslation-kajita
Jasig-sakai2012-communitytranslation-kajitaJasig-sakai2012-communitytranslation-kajita
Jasig-sakai2012-communitytranslation-kajita
 
Dividends
DividendsDividends
Dividends
 
Introduction to Big Data
Introduction to Big DataIntroduction to Big Data
Introduction to Big Data
 
50 ans d'anticipation n°5 : le journal de TNS Sofres
50 ans d'anticipation n°5 : le journal de TNS Sofres50 ans d'anticipation n°5 : le journal de TNS Sofres
50 ans d'anticipation n°5 : le journal de TNS Sofres
 
Pourquoi créer un bulletin paroissial électronique
Pourquoi créer un bulletin paroissial électroniquePourquoi créer un bulletin paroissial électronique
Pourquoi créer un bulletin paroissial électronique
 
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...
Microsoft TechDays 2012 France - BPOS301 La réversibilité des données dans le...
 
Etude de marché Beiersdorf/Nivea
Etude de marché Beiersdorf/NiveaEtude de marché Beiersdorf/Nivea
Etude de marché Beiersdorf/Nivea
 

Similaire à Building reactive systems with Akka

A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency ConstructsTed Leung
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)Netcetera
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuSalesforce Developers
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel Fomitescu
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overviewstasimus
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelMassimo Bonanni
 
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Codemotion
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingFabio Tiriticco
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With AkkaYaroslav Tkachenko
 

Similaire à Building reactive systems with Akka (20)

A Survey of Concurrency Constructs
A Survey of Concurrency ConstructsA Survey of Concurrency Constructs
A Survey of Concurrency Constructs
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
EnScript Workshop
EnScript WorkshopEnScript Workshop
EnScript Workshop
 
iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)iPhone development from a Java perspective (Jazoon '09)
iPhone development from a Java perspective (Jazoon '09)
 
10-DesignPatterns.ppt
10-DesignPatterns.ppt10-DesignPatterns.ppt
10-DesignPatterns.ppt
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and Heroku
 
Ruby On Rails
Ruby On RailsRuby On Rails
Ruby On Rails
 
Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016Manuel - SPR - Intro to Java Language_2016
Manuel - SPR - Intro to Java Language_2016
 
Devoxx
DevoxxDevoxx
Devoxx
 
Concurrency Constructs Overview
Concurrency Constructs OverviewConcurrency Constructs Overview
Concurrency Constructs Overview
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
Unit 1 notes.pdf
Unit 1 notes.pdfUnit 1 notes.pdf
Unit 1 notes.pdf
 
Introduction java programming
Introduction java programmingIntroduction java programming
Introduction java programming
 
Introducing Akka
Introducing AkkaIntroducing Akka
Introducing Akka
 
Discovering the Service Fabric's actor model
Discovering the Service Fabric's actor modelDiscovering the Service Fabric's actor model
Discovering the Service Fabric's actor model
 
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
Beyond fault tolerance with actor programming - Fabio Tiriticco - Codemotion ...
 
Beyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor ProgrammingBeyond Fault Tolerance with Actor Programming
Beyond Fault Tolerance with Actor Programming
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With Akka
 

Dernier

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 

Dernier (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 

Building reactive systems with Akka

  • 2. Today’s Agenda  Part 1 – Introduction to Akka  Part 2 – Scala Crash Course™  Part 3 – Hello Reactive World  Part 4 – A more complex example
  • 3. Part 1 – Introduction to Akka
  • 4. Problems with traditional systems  Extreme growth of data and number of clients  Mobile web (*), Internet of Things, etc.  Threads won’t scale  1 thread for each user  1 Mb minimum stack size / thread on 64 bit VMs  10 000 concurrent users => do the math   Existing programming models won’t scale either  Writing bug-free thread synchronization / locking code manually is extreme hard  Mutable state is the root of all evil  Mutable state is the basic idea of Object Oriented Programming.. (oops)  Polling sucks, we live in a realtime world
  • 5. Properties of Reactive Systems  Responsive  Gives low-latency responses even for overloaded systems  Resilient  Stays responsive even upon system failures  Message driven  Asynchronous and non-blocking, concurrent by design  Has no mutable shared state  Elastic  Can scale out horizontally on demand
  • 6. Introducing Akka  A framework and runtime engine for building reactive systems on the JVM  Implements the Actor model (mathematical model of Carl Hewitt, 1973)  Asynchronous, distributed by design  Resilient and self-healing system (motto: “Let it crash”)  High performance  50 million message / sec  2.5 million actor instances per GB of heap space  Written in the Scala language, has Scala and Java bindings  Open source with Apache2 license, commercially supported by Typesafe Inc.
  • 7. Introducing Akka Actors  Actors are the base building blocks of actor systems  Actors are lightweight objects  ~300 bytes / instance  Encapsulate state and behavior  Have no shared state ever  Actors are asynchronous and non-blocking  Communicate only via message passing  Have a mailbox for inbound messages  Always process messages in order  Actors live in hierarchy  Used for supervising  Actors have a reference  Phone number analogy
  • 8. Part 2 – Scala Crash Course™
  • 9. The Scala language  Strong static type system  Compiles to Java bytecode, runs on the JVM  Mixes object-oriented and functional style  Designed by Martin Odersky (javac)  Publicly available since 2004  Commercial support by Typesafe Inc. since 2011
  • 10. Scala Crash Course in 9 lines  Things to observe:  Packages, objects and classes  Constructor in object body  Values and method calls  Also note there are:  no semicolons (;)
  • 11. Scala Crash Course in 9 lines  Things to observe:  Packages, objects and classes  Constructor in object body  Values and method calls  Method definitions  Also note there are:  no semicolons (;)  no explicit types, unless necessary
  • 12. Scala Crash Course in 9 lines  Things to observe:  Packages, objects and classes  Constructor in object body  Values and method calls  Method definitions  Case classes  Also note there are:  no semicolons (;)  no explicit types, unless necessary  no unnecessary braces ({ } ( ))
  • 13. Scala Crash Course in 9 lines  Things to observe:  Packages, objects and classes  Constructor in object body  Values and method calls  Method definitions  Case classes  Higher order functions  String interpolation  Also note there are:  no semicolons (;)  no unnecessary braces ({ } ( ))  no explicit types, unless necessary
  • 14. Part 3 – Hello Reactive World
  • 15. Akka basics in Scala  Actors live in an ActorSystem  val system = ActorSystem(“hello”)  Actors are created via Props (factories)  val actor: ActorRef = system.actorOf(Props(classOf[MyActor.class]))  Messages are most often plain case classes / case objects  case class HelloMessage(message: String)  ActorRefs are used to send messages  actor ! HelloMessage(s“hello from $self”)
  • 17. Part 4 – A more complex example
  • 18. Building a Twitter streamer  Twitter == poor man’s Big Data (up to 50msg/sec)  Goal: Build a web application which displays the Twitter stream and the number of connected users  Tech stack  Twitter4J – twitter API  Play! – Scala web framework with WebSocket support, built on Akka  Akka – actors based middleware  Websocket JS API, JQuery, Bootstrap CSS  Gatling – stress test tool
  • 19. Demo
  • 20. A reactive architecture  System components:  Akka Event Bus  Play! Framework controller  Actors in the system:  1 x Streamer – connects to Twitter, receives status updates  n x WSProxy – proxies events via WebSocket to client  1 x ClientsTracker – tracks the number of clients, publishes the number every N seconds  WebSocket in the browser:  Registers with Play! controller, connects to Actor  Receives push messages in JSON  Replaces DOM with JQuery
  • 23. Code review - Streamer actor
  • 24. Code review - ClientsTracker actor
  • 25. Code review - WSProxy actor
  • 26. Code review - Play! controller class
  • 29. Resources  Twitter streamer source - https://github.com/kjozsa/reactive2  Akka - http://akka.io/  Play! Framework - https://playframework.com/