SlideShare a Scribd company logo
Reactive and Parallel
Programming
Presents...
Enrico Pigozzi
Vito Ressa
Who is Agile Lab?
GO BIG (data) or GO HOME
Summary
• Concurrency problem
Recurrent issues
Handle concurrency
• Akka
Overview
How it works
Akka cluster
Expansions and use-cases
How we use Akka
• Demo time
Parallel and
concurrent
Programming
Ⓒ2016 Agile Lab S.r.l.
“We need to stop coding our concurrency
and just let our code run concurrently”
Shared/mutable state
• Threads (pool) usage to make code “faster” + synchronization features
(primitives, locks, defensive copies, etc.) to make it “safe”.
• We tend to create the problem first, and (don’t) fix it up later (N.B. no real
concurrency allowed)
Issues
• Threads
• expensive (startup, memory, context switching)
• limited (by OS)
• CPU Vs. Synchronus IO balance required
• optimizated usage requires non-blocking API (cumbersome to write and test)
• Design
• bottlenecks, race conditions, deadlocks
• traditional errors management approches (exceptions and error codes) don’t
translate well
• maintenance / refactoring costs can increase to a fairy high degree (and therefore
avoided)
Software Transactional Memory
• Turns memory heap in a transactional data set (Atomic, Consistent, Isolated)
• Based on Transactional References:
 Memory cells, holding an immutable value (separates identity from
value)
 Implement CAS (Compare-And-Swap) semantic (old value still availabe
after change)
 Can only be altered within a transaction
 Very fast (near constant time)
 Thread and iteration safe
Futures
future(a,b)futureB(a)
 Asynchronous values
 Composable functional abstraction
 Error propagation and recover allowed
 Callback on termination available
for {
a ← futureA()
b ← futureB(a)
c ← futureC(a,b)
} yield c
futureA()
Actors & Message passing
• Unit of code organization: “policy” separated from “logic”, incapsulate state,
behaviour, mailbox
• Weakly / Adaptive typed: achitectural flexibility enhanced (decupled design)
• Safe: one thing a time in isolated context (actor accessed by reference, interaction by
messages)
• Immutable structures/messages managed by actors in isolated/safe context
Finite State Machine
• Applied to actor: must be in one of the defined (in type system) state all the
time
• A data object can be attached to each state (M:N relation)
• A starting state (and eventually data) has to be defined
• Event insted of simple messages: provides current state info
• 'When/goto/stay' model: define actor reaction (partial function) to event
for a state
S1
S2
S3
S4S5
A
B A
A A
A
B
B
B
B
A,B = possible messages
S1,…S5 = States
Microservices
• Bounded Context: Each element of functionality into a separate service
• Fault tolerance
• Deployment independency
• DataStore independency
• Loose coupling
• Service Discovery
• Sync/async messaging between services
• Scalability
Akka
Ⓒ2016 Agile Lab S.r.l.
Overview
Event-driven systems
with
Actors
High Performance
Easy concurrency handling
Simple distribution
High flexibility
Resilience
Reactive Manifesto
http://www.reactivemanifesto.org/
Commercial Support
Strenghts
How it works?
• Actor as an essential code unit
• Messages for actors interaction
• Hierarchical organization
• Supervision Hierarchy
Actors Lifecycle
• Actor instance is hidden
• Actor restarting
transparent to other actors
• Mailbox bounded to the
incarnation
Messages
• Any kind of message but immutable!
• Hint: In scala use case classes and take advantage of
pattern matching (see next slide)
Tell or Ask
Mailbox
• Landing point for messages
• Bounded to the incarnation of the actor (not the instance!)
• Allows different configurations (FIFO, LIFO, custom priority, ...)
• A mailbox can be shared in case of balancing pools
MAILBOX STASH
unstash()
Behaviors
Message handling
Behaviors management
Akka
Cluster
Ⓒ2016 Agile Lab S.r.l.
Akka Cluster
Node A
Node B
Node C
Node D
Leader
CLUSTER
Cluster membership service
• Peer to peer
• Decentralized
• Fault tolerant
• No single point of failure
• No single point of bottleneck
A Node is identified by a tuple
hostname:port:uid
• Gossip Protocol
• Automatic failure detector
Failure detection
An implementation of The Phi Accrual Failure Detector
Failure Detector
input
Nodes heartbeats phi-value
Is a node unreachable or not?
Depends on a treshold
Extensions and
use-cases
Ⓒ2016 Agile Lab S.r.l.
Extensions
Community projects available at
http://akka.io/community/
• Akka persistence - http://doc.akka.io/docs/akka/current/scala/persistence.html
• Akka HTTP - http://doc.akka.io/docs/akka-stream-and-http-
experimental/current/scala/http/
• Akka Streams - http://doc.akka.io/docs/akka-stream-and-http-
experimental/current/scala/http/
• Akka Camel - http://doc.akka.io/docs/akka/current/scala/camel.html
• Akka FSM - http://doc.akka.io/docs/akka/current/scala/fsm.html
Use cases: GearPump
Ref: https://www.typesafe.com/resources/case-studies-and-stories/intels-gearpump-real-
time-streaming-engine-using-akka
• Real-time streaming engine
• Multiple stream datasources
• Need of HA, scalability, performance
• "Once at a time" transactional message processing
With 4 nodes GearPump can
process up to 11 million
messages per seconds with
an average latency of 17ms
(100 bytes messages)
Use cases: Paycasso
• Three-factor authentication platform
• High speed authentication is mandatory
• Scala, Akka and Cassandra at the core as a reactive stack
• Make use of Akka HTTP, Akka Persistence, Akka Cluster Sharding.
Ref: https://www.typesafe.com/resources/case-studies-and-stories/paycasso-conquers-
speed-gap-in-three-factor-authentications-with-reactive-stack
Use cases: SAMI
• Data broker in the cloud for IoT
• Need for reactiveness and resiliency
• Microservices-based platform with Akka
Akka
usages
• Actors dedicated to clients for each WebSocket.
• At the transformation layer, where data is
streamed into the system and normalized.
Ref: https://www.typesafe.com/resources/case-studies-and-stories/samsung-strategy-
and-innovation-center-executes-iot-vision-at-startup-speed-with-reactive-architecture
Other use cases
Interesting Discussion
http://stackoverflow.com/questions/4493001/good-use-case-for-akka
Online Gaming
Finance
Statistics
Betting
Social Media
Telecom
Web Media
How we use
Akka
Ⓒ2016 Agile Lab S.r.l.
Akka in Action with
Microservices
Mosaico RCS
Reverse Proxy
Akka
Srv1
Akka
Srv2
Akka
Srv3
Akka
Srv4
Akka
Srv5
Akka
Srv6
Mongo
DB
Mongo
DB
My
SQL
S3
Akka
Custering
Akka in Action with BigData
Wasp AgileLab
Akka
Custering
master
Producer
Guardian
Consumer
Gardian
API
Guardian
E
P
E
P
E
P
E
P
K
R
K
R
K
R
R
T
S
P
S
P
WS TCP
Legend:
EP: EndPoint DataIn
KR:KafkaRouter
SP: Spark Pipeline
RT: Real Time
WS: Web Socket API
DataIn
Control
Plane
Demo time...
Ⓒ2016 Agile Lab S.r.l.
We are
hiring...
Ⓒ2016 Agile Lab S.r.l.
paolo.platter@agilelab.it

More Related Content

What's hot

AI at Scale
AI at ScaleAI at Scale
AI at Scale
Adi Polak
 
xPatterns - Spark Summit 2014
xPatterns - Spark Summit   2014xPatterns - Spark Summit   2014
xPatterns - Spark Summit 2014
Claudiu Barbura
 
Strata San Jose 2016: Scalable Ensemble Learning with H2O
Strata San Jose 2016: Scalable Ensemble Learning with H2OStrata San Jose 2016: Scalable Ensemble Learning with H2O
Strata San Jose 2016: Scalable Ensemble Learning with H2O
Sri Ambati
 
Understanding and Improving Code Generation
Understanding and Improving Code GenerationUnderstanding and Improving Code Generation
Understanding and Improving Code Generation
Databricks
 
Productionizing Machine Learning in Our Health and Wellness Marketplace
Productionizing Machine Learning in Our Health and Wellness MarketplaceProductionizing Machine Learning in Our Health and Wellness Marketplace
Productionizing Machine Learning in Our Health and Wellness Marketplace
Databricks
 
Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape
NETWAYS
 
Splice Machine's use of Apache Spark and MLflow
Splice Machine's use of Apache Spark and MLflowSplice Machine's use of Apache Spark and MLflow
Splice Machine's use of Apache Spark and MLflow
Databricks
 
Best Practices for Engineering Production-Ready Software with Apache Spark
Best Practices for Engineering Production-Ready Software with Apache SparkBest Practices for Engineering Production-Ready Software with Apache Spark
Best Practices for Engineering Production-Ready Software with Apache Spark
Databricks
 
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
HostedbyConfluent
 
From Idea to Model: Productionizing Data Pipelines with Apache Airflow
From Idea to Model: Productionizing Data Pipelines with Apache AirflowFrom Idea to Model: Productionizing Data Pipelines with Apache Airflow
From Idea to Model: Productionizing Data Pipelines with Apache Airflow
Databricks
 
Apache edgent
Apache edgentApache edgent
Apache edgent
Soma Shekarchi
 
Productionizing Deep Reinforcement Learning with Spark and MLflow
Productionizing Deep Reinforcement Learning with Spark and MLflowProductionizing Deep Reinforcement Learning with Spark and MLflow
Productionizing Deep Reinforcement Learning with Spark and MLflow
Databricks
 
Cloud powered search
Cloud powered searchCloud powered search
Cloud powered search
Codecamp Romania
 
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFs
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFsAutomating Predictive Modeling at Zynga with PySpark and Pandas UDFs
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFs
Databricks
 
Moving advanced analytics to your sql server databases
Moving advanced analytics to your sql server databasesMoving advanced analytics to your sql server databases
Moving advanced analytics to your sql server databases
Enrico van de Laar
 
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
Databricks
 
Librecon 2016 bilbao: kappa architecture IoT of the cars
Librecon 2016 bilbao:   kappa architecture IoT of the carsLibrecon 2016 bilbao:   kappa architecture IoT of the cars
Librecon 2016 bilbao: kappa architecture IoT of the cars
Juantomás García Molina
 
Building an intelligent big data application in 30 minutes
Building an intelligent big data application in 30 minutesBuilding an intelligent big data application in 30 minutes
Building an intelligent big data application in 30 minutes
Claudiu Barbura
 
Intro stream processing.be meetup #1
Intro stream processing.be meetup #1Intro stream processing.be meetup #1
Intro stream processing.be meetup #1
Peter Vandenabeele
 
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Databricks
 

What's hot (20)

AI at Scale
AI at ScaleAI at Scale
AI at Scale
 
xPatterns - Spark Summit 2014
xPatterns - Spark Summit   2014xPatterns - Spark Summit   2014
xPatterns - Spark Summit 2014
 
Strata San Jose 2016: Scalable Ensemble Learning with H2O
Strata San Jose 2016: Scalable Ensemble Learning with H2OStrata San Jose 2016: Scalable Ensemble Learning with H2O
Strata San Jose 2016: Scalable Ensemble Learning with H2O
 
Understanding and Improving Code Generation
Understanding and Improving Code GenerationUnderstanding and Improving Code Generation
Understanding and Improving Code Generation
 
Productionizing Machine Learning in Our Health and Wellness Marketplace
Productionizing Machine Learning in Our Health and Wellness MarketplaceProductionizing Machine Learning in Our Health and Wellness Marketplace
Productionizing Machine Learning in Our Health and Wellness Marketplace
 
Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape Rootconf 2017 - State of the Open Source monitoring landscape
Rootconf 2017 - State of the Open Source monitoring landscape
 
Splice Machine's use of Apache Spark and MLflow
Splice Machine's use of Apache Spark and MLflowSplice Machine's use of Apache Spark and MLflow
Splice Machine's use of Apache Spark and MLflow
 
Best Practices for Engineering Production-Ready Software with Apache Spark
Best Practices for Engineering Production-Ready Software with Apache SparkBest Practices for Engineering Production-Ready Software with Apache Spark
Best Practices for Engineering Production-Ready Software with Apache Spark
 
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
Nordstrom's Event-Sourced Architecture and Kafka-as-a-Service | Adam Weyant a...
 
From Idea to Model: Productionizing Data Pipelines with Apache Airflow
From Idea to Model: Productionizing Data Pipelines with Apache AirflowFrom Idea to Model: Productionizing Data Pipelines with Apache Airflow
From Idea to Model: Productionizing Data Pipelines with Apache Airflow
 
Apache edgent
Apache edgentApache edgent
Apache edgent
 
Productionizing Deep Reinforcement Learning with Spark and MLflow
Productionizing Deep Reinforcement Learning with Spark and MLflowProductionizing Deep Reinforcement Learning with Spark and MLflow
Productionizing Deep Reinforcement Learning with Spark and MLflow
 
Cloud powered search
Cloud powered searchCloud powered search
Cloud powered search
 
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFs
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFsAutomating Predictive Modeling at Zynga with PySpark and Pandas UDFs
Automating Predictive Modeling at Zynga with PySpark and Pandas UDFs
 
Moving advanced analytics to your sql server databases
Moving advanced analytics to your sql server databasesMoving advanced analytics to your sql server databases
Moving advanced analytics to your sql server databases
 
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
Monitoring Half a Million ML Models, IoT Streaming Data, and Automated Qualit...
 
Librecon 2016 bilbao: kappa architecture IoT of the cars
Librecon 2016 bilbao:   kappa architecture IoT of the carsLibrecon 2016 bilbao:   kappa architecture IoT of the cars
Librecon 2016 bilbao: kappa architecture IoT of the cars
 
Building an intelligent big data application in 30 minutes
Building an intelligent big data application in 30 minutesBuilding an intelligent big data application in 30 minutes
Building an intelligent big data application in 30 minutes
 
Intro stream processing.be meetup #1
Intro stream processing.be meetup #1Intro stream processing.be meetup #1
Intro stream processing.be meetup #1
 
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
Taking Jupyter Notebooks and Apache Spark to the Next Level PixieDust with Da...
 

Viewers also liked

iBeacon - I vantaggi nel mondo retail
iBeacon - I vantaggi nel mondo retailiBeacon - I vantaggi nel mondo retail
iBeacon - I vantaggi nel mondo retailEmanuele Cucci
 
Agile Lab_BigData_Meetup
Agile Lab_BigData_MeetupAgile Lab_BigData_Meetup
Agile Lab_BigData_Meetup
Paolo Platter
 
Big data & hadoop framework
Big data & hadoop frameworkBig data & hadoop framework
Big data & hadoop framework
Tu Pham
 
Scala Intro
Scala IntroScala Intro
Scala Intro
Paolo Platter
 
Introduzione ai Big Data e alla scienza dei dati - Big Data
Introduzione ai Big Data e alla scienza dei dati - Big DataIntroduzione ai Big Data e alla scienza dei dati - Big Data
Introduzione ai Big Data e alla scienza dei dati - Big Data
Vincenzo Manzoni
 
Big Data and Implications on Platform Architecture
Big Data and Implications on Platform ArchitectureBig Data and Implications on Platform Architecture
Big Data and Implications on Platform Architecture
Odinot Stanislas
 
R-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
R-IoT Retail IoT - Come le IoT influenzano il mercato del RetailR-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
R-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
riot-markets
 
Introduzione ai Big Data e alla scienza dei dati
Introduzione ai Big Data e alla scienza dei datiIntroduzione ai Big Data e alla scienza dei dati
Introduzione ai Big Data e alla scienza dei dati
Vincenzo Manzoni
 
Apache Gearpump next-gen streaming engine
Apache Gearpump next-gen streaming engineApache Gearpump next-gen streaming engine
Apache Gearpump next-gen streaming engine
Tianlun Zhang
 
QCON 2015: Gearpump, Realtime Streaming on Akka
QCON 2015: Gearpump, Realtime Streaming on AkkaQCON 2015: Gearpump, Realtime Streaming on Akka
QCON 2015: Gearpump, Realtime Streaming on Akka
Sean Zhong
 
Real Time Big Data Framework
Real Time Big Data FrameworkReal Time Big Data Framework
Real Time Big Data Framework
Red Hat India Pvt. Ltd.
 
Analysis and Characterization of Devices and Protocol Stacks for the Internet...
Analysis and Characterization of Devices and Protocol Stacks for the Internet...Analysis and Characterization of Devices and Protocol Stacks for the Internet...
Analysis and Characterization of Devices and Protocol Stacks for the Internet...
Mauro Losciale
 
Big Data & Smart Cities
Big Data & Smart CitiesBig Data & Smart Cities
Big Data & Smart Cities
Moutaz Haddara
 
Data Streaming Technology Overview
Data Streaming Technology OverviewData Streaming Technology Overview
Data Streaming Technology Overview
Dan Lynn
 
File Format Benchmarks - Avro, JSON, ORC, & Parquet
File Format Benchmarks - Avro, JSON, ORC, & ParquetFile Format Benchmarks - Avro, JSON, ORC, & Parquet
File Format Benchmarks - Avro, JSON, ORC, & Parquet
Owen O'Malley
 

Viewers also liked (15)

iBeacon - I vantaggi nel mondo retail
iBeacon - I vantaggi nel mondo retailiBeacon - I vantaggi nel mondo retail
iBeacon - I vantaggi nel mondo retail
 
Agile Lab_BigData_Meetup
Agile Lab_BigData_MeetupAgile Lab_BigData_Meetup
Agile Lab_BigData_Meetup
 
Big data & hadoop framework
Big data & hadoop frameworkBig data & hadoop framework
Big data & hadoop framework
 
Scala Intro
Scala IntroScala Intro
Scala Intro
 
Introduzione ai Big Data e alla scienza dei dati - Big Data
Introduzione ai Big Data e alla scienza dei dati - Big DataIntroduzione ai Big Data e alla scienza dei dati - Big Data
Introduzione ai Big Data e alla scienza dei dati - Big Data
 
Big Data and Implications on Platform Architecture
Big Data and Implications on Platform ArchitectureBig Data and Implications on Platform Architecture
Big Data and Implications on Platform Architecture
 
R-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
R-IoT Retail IoT - Come le IoT influenzano il mercato del RetailR-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
R-IoT Retail IoT - Come le IoT influenzano il mercato del Retail
 
Introduzione ai Big Data e alla scienza dei dati
Introduzione ai Big Data e alla scienza dei datiIntroduzione ai Big Data e alla scienza dei dati
Introduzione ai Big Data e alla scienza dei dati
 
Apache Gearpump next-gen streaming engine
Apache Gearpump next-gen streaming engineApache Gearpump next-gen streaming engine
Apache Gearpump next-gen streaming engine
 
QCON 2015: Gearpump, Realtime Streaming on Akka
QCON 2015: Gearpump, Realtime Streaming on AkkaQCON 2015: Gearpump, Realtime Streaming on Akka
QCON 2015: Gearpump, Realtime Streaming on Akka
 
Real Time Big Data Framework
Real Time Big Data FrameworkReal Time Big Data Framework
Real Time Big Data Framework
 
Analysis and Characterization of Devices and Protocol Stacks for the Internet...
Analysis and Characterization of Devices and Protocol Stacks for the Internet...Analysis and Characterization of Devices and Protocol Stacks for the Internet...
Analysis and Characterization of Devices and Protocol Stacks for the Internet...
 
Big Data & Smart Cities
Big Data & Smart CitiesBig Data & Smart Cities
Big Data & Smart Cities
 
Data Streaming Technology Overview
Data Streaming Technology OverviewData Streaming Technology Overview
Data Streaming Technology Overview
 
File Format Benchmarks - Avro, JSON, ORC, & Parquet
File Format Benchmarks - Avro, JSON, ORC, & ParquetFile Format Benchmarks - Avro, JSON, ORC, & Parquet
File Format Benchmarks - Avro, JSON, ORC, & Parquet
 

Similar to Agile Lab_BigData_Meetup_AKKA

Composable Futures with Akka 2.0
Composable Futures with Akka 2.0Composable Futures with Akka 2.0
Composable Futures with Akka 2.0
Mike Slinn
 
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
Vignesh Sukumar
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
Luka Zakrajšek
 
Akka.Net Overview
Akka.Net OverviewAkka.Net Overview
Akka.Net Overview
Geoffrey Vandiest
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?
Anton Nazaruk
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den Hoek
RubiX BV
 
Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)
Ilya Ganelin
 
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Flink Forward
 
Cloud Architect Alliance #15: Openstack
Cloud Architect Alliance #15: OpenstackCloud Architect Alliance #15: Openstack
Cloud Architect Alliance #15: Openstack
Microsoft
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
Ivo Andreev
 
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Robert "Chip" Senkbeil
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debugger
Iulian Dragos
 
Indic threads pune12-typesafe stack software development on the jvm
Indic threads pune12-typesafe stack software development on the jvmIndic threads pune12-typesafe stack software development on the jvm
Indic threads pune12-typesafe stack software development on the jvm
IndicThreads
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015
Evan Chan
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
Javier García Magna
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
Konstantin Tsykulenko
 
Machine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkMLMachine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkML
Arnab Biswas
 
Integrating Microservices with Apache Camel
Integrating Microservices with Apache CamelIntegrating Microservices with Apache Camel
Integrating Microservices with Apache Camel
Christian Posta
 
Reactive meetup 0 copy
Reactive meetup 0 copyReactive meetup 0 copy
Reactive meetup 0 copy
Patrick Charles
 
A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology
confluent
 

Similar to Agile Lab_BigData_Meetup_AKKA (20)

Composable Futures with Akka 2.0
Composable Futures with Akka 2.0Composable Futures with Akka 2.0
Composable Futures with Akka 2.0
 
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
 
Typesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and PlayTypesafe stack - Scala, Akka and Play
Typesafe stack - Scala, Akka and Play
 
Akka.Net Overview
Akka.Net OverviewAkka.Net Overview
Akka.Net Overview
 
Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?Big Data Streams Architectures. Why? What? How?
Big Data Streams Architectures. Why? What? How?
 
Reactive Streams - László van den Hoek
Reactive Streams - László van den HoekReactive Streams - László van den Hoek
Reactive Streams - László van den Hoek
 
Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)Stream Computing (The Engineer's Perspective)
Stream Computing (The Engineer's Perspective)
 
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
Virtual Flink Forward 2020: How Streaming Helps Your Staging Environment and ...
 
Cloud Architect Alliance #15: Openstack
Cloud Architect Alliance #15: OpenstackCloud Architect Alliance #15: Openstack
Cloud Architect Alliance #15: Openstack
 
Azure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challengesAzure architecture design patterns - proven solutions to common challenges
Azure architecture design patterns - proven solutions to common challenges
 
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debugger
 
Indic threads pune12-typesafe stack software development on the jvm
Indic threads pune12-typesafe stack software development on the jvmIndic threads pune12-typesafe stack software development on the jvm
Indic threads pune12-typesafe stack software development on the jvm
 
Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015Akka in Production - ScalaDays 2015
Akka in Production - ScalaDays 2015
 
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20....Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
.Net Microservices with Event Sourcing, CQRS, Docker and... Windows Server 20...
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Machine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkMLMachine Learning With H2O vs SparkML
Machine Learning With H2O vs SparkML
 
Integrating Microservices with Apache Camel
Integrating Microservices with Apache CamelIntegrating Microservices with Apache Camel
Integrating Microservices with Apache Camel
 
Reactive meetup 0 copy
Reactive meetup 0 copyReactive meetup 0 copy
Reactive meetup 0 copy
 
A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology A Practical Guide to Selecting a Stream Processing Technology
A Practical Guide to Selecting a Stream Processing Technology
 

Agile Lab_BigData_Meetup_AKKA

  • 2. Who is Agile Lab? GO BIG (data) or GO HOME
  • 3. Summary • Concurrency problem Recurrent issues Handle concurrency • Akka Overview How it works Akka cluster Expansions and use-cases How we use Akka • Demo time
  • 4. Parallel and concurrent Programming Ⓒ2016 Agile Lab S.r.l. “We need to stop coding our concurrency and just let our code run concurrently”
  • 5. Shared/mutable state • Threads (pool) usage to make code “faster” + synchronization features (primitives, locks, defensive copies, etc.) to make it “safe”. • We tend to create the problem first, and (don’t) fix it up later (N.B. no real concurrency allowed)
  • 6. Issues • Threads • expensive (startup, memory, context switching) • limited (by OS) • CPU Vs. Synchronus IO balance required • optimizated usage requires non-blocking API (cumbersome to write and test) • Design • bottlenecks, race conditions, deadlocks • traditional errors management approches (exceptions and error codes) don’t translate well • maintenance / refactoring costs can increase to a fairy high degree (and therefore avoided)
  • 7. Software Transactional Memory • Turns memory heap in a transactional data set (Atomic, Consistent, Isolated) • Based on Transactional References:  Memory cells, holding an immutable value (separates identity from value)  Implement CAS (Compare-And-Swap) semantic (old value still availabe after change)  Can only be altered within a transaction  Very fast (near constant time)  Thread and iteration safe
  • 8. Futures future(a,b)futureB(a)  Asynchronous values  Composable functional abstraction  Error propagation and recover allowed  Callback on termination available for { a ← futureA() b ← futureB(a) c ← futureC(a,b) } yield c futureA()
  • 9. Actors & Message passing • Unit of code organization: “policy” separated from “logic”, incapsulate state, behaviour, mailbox • Weakly / Adaptive typed: achitectural flexibility enhanced (decupled design) • Safe: one thing a time in isolated context (actor accessed by reference, interaction by messages) • Immutable structures/messages managed by actors in isolated/safe context
  • 10. Finite State Machine • Applied to actor: must be in one of the defined (in type system) state all the time • A data object can be attached to each state (M:N relation) • A starting state (and eventually data) has to be defined • Event insted of simple messages: provides current state info • 'When/goto/stay' model: define actor reaction (partial function) to event for a state S1 S2 S3 S4S5 A B A A A A B B B B A,B = possible messages S1,…S5 = States
  • 11. Microservices • Bounded Context: Each element of functionality into a separate service • Fault tolerance • Deployment independency • DataStore independency • Loose coupling • Service Discovery • Sync/async messaging between services • Scalability
  • 13. Overview Event-driven systems with Actors High Performance Easy concurrency handling Simple distribution High flexibility Resilience Reactive Manifesto http://www.reactivemanifesto.org/ Commercial Support
  • 15. How it works? • Actor as an essential code unit • Messages for actors interaction • Hierarchical organization • Supervision Hierarchy
  • 16. Actors Lifecycle • Actor instance is hidden • Actor restarting transparent to other actors • Mailbox bounded to the incarnation
  • 17. Messages • Any kind of message but immutable! • Hint: In scala use case classes and take advantage of pattern matching (see next slide) Tell or Ask
  • 18. Mailbox • Landing point for messages • Bounded to the incarnation of the actor (not the instance!) • Allows different configurations (FIFO, LIFO, custom priority, ...) • A mailbox can be shared in case of balancing pools MAILBOX STASH unstash()
  • 21. Akka Cluster Node A Node B Node C Node D Leader CLUSTER Cluster membership service • Peer to peer • Decentralized • Fault tolerant • No single point of failure • No single point of bottleneck A Node is identified by a tuple hostname:port:uid • Gossip Protocol • Automatic failure detector
  • 22. Failure detection An implementation of The Phi Accrual Failure Detector Failure Detector input Nodes heartbeats phi-value Is a node unreachable or not? Depends on a treshold
  • 24. Extensions Community projects available at http://akka.io/community/ • Akka persistence - http://doc.akka.io/docs/akka/current/scala/persistence.html • Akka HTTP - http://doc.akka.io/docs/akka-stream-and-http- experimental/current/scala/http/ • Akka Streams - http://doc.akka.io/docs/akka-stream-and-http- experimental/current/scala/http/ • Akka Camel - http://doc.akka.io/docs/akka/current/scala/camel.html • Akka FSM - http://doc.akka.io/docs/akka/current/scala/fsm.html
  • 25. Use cases: GearPump Ref: https://www.typesafe.com/resources/case-studies-and-stories/intels-gearpump-real- time-streaming-engine-using-akka • Real-time streaming engine • Multiple stream datasources • Need of HA, scalability, performance • "Once at a time" transactional message processing With 4 nodes GearPump can process up to 11 million messages per seconds with an average latency of 17ms (100 bytes messages)
  • 26. Use cases: Paycasso • Three-factor authentication platform • High speed authentication is mandatory • Scala, Akka and Cassandra at the core as a reactive stack • Make use of Akka HTTP, Akka Persistence, Akka Cluster Sharding. Ref: https://www.typesafe.com/resources/case-studies-and-stories/paycasso-conquers- speed-gap-in-three-factor-authentications-with-reactive-stack
  • 27. Use cases: SAMI • Data broker in the cloud for IoT • Need for reactiveness and resiliency • Microservices-based platform with Akka Akka usages • Actors dedicated to clients for each WebSocket. • At the transformation layer, where data is streamed into the system and normalized. Ref: https://www.typesafe.com/resources/case-studies-and-stories/samsung-strategy- and-innovation-center-executes-iot-vision-at-startup-speed-with-reactive-architecture
  • 28. Other use cases Interesting Discussion http://stackoverflow.com/questions/4493001/good-use-case-for-akka Online Gaming Finance Statistics Betting Social Media Telecom Web Media
  • 29. How we use Akka Ⓒ2016 Agile Lab S.r.l.
  • 30. Akka in Action with Microservices Mosaico RCS Reverse Proxy Akka Srv1 Akka Srv2 Akka Srv3 Akka Srv4 Akka Srv5 Akka Srv6 Mongo DB Mongo DB My SQL S3 Akka Custering
  • 31. Akka in Action with BigData Wasp AgileLab Akka Custering master Producer Guardian Consumer Gardian API Guardian E P E P E P E P K R K R K R R T S P S P WS TCP Legend: EP: EndPoint DataIn KR:KafkaRouter SP: Spark Pipeline RT: Real Time WS: Web Socket API DataIn Control Plane
  • 33. We are hiring... Ⓒ2016 Agile Lab S.r.l. paolo.platter@agilelab.it