SlideShare a Scribd company logo
INTRODUCTION TO
AKKA-STREAMS
Dmytro Mantula
GlobalLogic, Kyiv
PREVIOUS AGE OF COMPUTING SYSTEMS
• Monolith software architecture
• Managed servers and containers
• RDBMS, transactions isolation
• Scalability: scale-up by more powerful hardware
• Proprietary enterprise solutions
NEW CHALLENGES
• response time: s -> ms
• high availability: 3 nines (8h/y) -> 5+ nines (5– m/y)
• storage: GBs (10
9
) -> PBs (10
15
)+
• hardware: spread from mobile phone to 1000+
nodes cluster
MOORE’S LAW
EVIL OF CPU PERFORMANCE:
MOORE’S LAW
DOESN’T WORK
ANYMORE
FOR A SINGLE CORE
The more CPU cores a system
has,
the faster it is.
True or false?
EVIL OF PARALLELISM:
AMDAHL’S LAW
Gene Amdahl
1967
STUBBORN AMDAHL’S LAW
The speedup of a program
using multiple processors in parallel computing
is limited by the sequential fraction of the program.
EVIL OF CONCURRENCY:
SHARED MUTABLE
STATE
«Do not communicate
by sharing memory.
Instead, share memory
by communicating»
– Effective Go
v1.0: July 2013
v2.0: Sept 2014
REACTIVE SOFTWARE DESIGN
http://www.reactivemanifesto.org/
• rapid and consistent response times
• response in SLA time may be more
important than late correct response
• problems may be detected quickly
and dealt with effectively
react to users
Responsive
react to load
Elastic
• No contention points or central bottlenecks
• ability to shard or replicate components
and distribute inputs among them
• Automatic resource management
• scale-up
• scale-out
• scale-down
• scale-in
• “Let it crash!”: there is no way to think
about every single failure point
• failure is not dealt with as an error
• means that some capacity of the
system will be reduced
• dealt with as a message
react to failures
Resilient
Asynchronous message-passing
• loose coupling
• isolation of components
• location transparency
• failures as messages
Benefits:
• load management
• elasticity
• flow control (monitoring , back-pressure)
react to events
Message Driven
Application
should be reactive
from top to
bottom
v1.0: July 2013
v2.0: Sept 2014
REACTIVE SOFTWARE DESIGN
http://www.reactivemanifesto.org/
CARL HEWITT, 1973
ACTOR MODEL
• Describes:
• message processing algorithm
• data storage principles
• interaction between modules
• Erlang
• Used in telecommunication systems
• High Availability of 9 “nines”
• Written in Scala
• Stable since 2009
• Part of Scala Standard Library since 2013
• Supports Java 8 since 2014
by
ex
WHAT IS AN ACTOR?
Actor is a unit of code
with a mailbox
and an internal state
that just responds to messages
in a single thread
(briefly)
IDLE
TWO STATES OF ACTOR
IDLE
TWO STATES OF ACTOR
MESSAGE PROCESSING
WHAT IS AN ACTOR?
• Similar to object in OOP, but message-driven
• Even more isolated than object: no explicit access
exposed (hidden behind ActorRef)
• no shared state
• location transparent (can live in different JVMs)
• Light-weight: 300B memory footprint (millions per GB)
• No threads allocated in idle state
• Single-threaded invocation inside, sequential message
processing
• Supervises children actors
WHAT CAN ACTOR DO?
• If no messages being processed:
• Nothing
• When message being processed (one at a time):
• make local decisions
• send messages to other actors (incl. sender() and self())
• do other actions with side-effects (IO, logs, DB access)
• change own behavior for next messages
• create more actors (and promise to supervise them)
BENEFITS
• You’re not going to have multiple threads modifying a
variable at the same time.
• Forget about:
• Shared state
• Threads
• Locks, “synchronized”
• Concurrent collections
• wait/notify/notifyAll
• Describe only business behavior in the code.
• Akka and app configuration care about everything else.
ACTOR AND ACTOR MESSAGE
purely-immutable serializable
ACTORSYSTEM AND ENTRY POINT
OTHER FEATURES OF AKKA
• Supervision model
• Routing via configuration
• Remote actors via configuration
• Clustering via configuration
• etc.
WEAKNESS OF AKKA #1:
NO DSL FOR DATA FLOW
AND
TYPE-UNSAFE MESSAGE
PASSING
ACTORS BECAME JUST ANOTHER
CONCURRENCY
PRIMITIVE
AND SHOULD BE HIDDEN
BEHIND HIGHER-LEVEL ABSTRACTIONS
WEAKNESS OF AKKA #2:
AGGRESSIVE STRATEGIES
OF DEALING WITH
BUFFER OVERFLOW
DANGEROUS SITUATION
PUBLISHER SUBSCRIBER
Data
Asynchronous
boundary
Asynchronous
boundary
DON’T PUSH BACK – JUST DON’T ASK
BACK-PRESSURE
PUBLISHER SUBSCRIBER
Demand
Data
HOW CAN PRODUCER DEAL
WITH BACK-PRESSURE?
• Slow down producing data (if it can)
• Buffer (using bounded buffer, of course)
• Drop elements
• Fail
PARTIALLY BACK-PRESSURED STREAM
PARTIALLY BACK-PRESSURED STREAM
THE WHOLE STREAM SHOULD BE BACK-PRESSURED
REACTIVE STREAMS GOALS
• minimalistic
• asynchronous
• never block (waste time/resources)
• safe (back-threads pressure)
• purely local abstraction
• allow synchronous implementations
• compatible with TCP
REACTIVE STREAMS
• 2013 – “reactive non-blocking asynchronous back-pressure”
• 2015 – JEP-266: Introduced to OpenJDK 9 by Doug Lea
http://openjdk.java.net/jeps/266
REACTIVE STREAMS: INTERFACES
http://www.reactive-streams.org/
AKKA-STREAMS
• Implements Reactive Streams, transparently for
the user
• Uses Akka under the hood:
• Derived actors can be configured using akka
configuration
• Clustering, networking, HTTP, profiling tools
DEMO
PRINT OUT LIST(“HELLO”, “WORLD”)
AKKA-STREAMS
MAIN BUILDING BLOCKS
Source Flow Sink
AKKA-STREAMS ALGEBRA
• Source + Sink = RunnableGraph
• Source + Flow = (composite) Source
• Flow + Sink = (composite) Sink
• Flow + Flow = (composite) Flow
DEMO
PRINT (1 TO 10)
MULTIPLICATION BY 2
MATERIALIZATION
MATERIALIZATION
MATERIALIZATION
MATERIALIZED
VALUES
?
DEMO
ACTORREF AS MATERIALIZED VALUE
SUM OF EVEN NUMBERS
GRAPH DSL
MORE COMPLEX SHAPES
Fan-In Fan-Out BidiFlow
UniformFanInShape UniformFanOutShape
FanInShape1
FanInShape2
FanInShapeN
FanOutShape1
FanOutShape2
FanOutShapeN
PLAIN FLOW DSL
VS
GRAPH DSL
DEMO
BROADCAST-MERGE GRAPH
DEMO
BACK-PRESSURE
ON .THROTTLE AND ZIP
SOURCES OUT OF THE BOX
SINKS OUT OF THE BOX
OTHER FEATURES OF AKKA-STREAMS
• mapAsync for external calls
• Custom shapes
• Subgraph customisation with Attributes
• Custom processing with GraphStage
• Operator Fusing
• Supervision Strategies via ActorMaterializerSettings
• Integration with other RS implementations
• Streams TestKit
RESOURCES
Akka:
http://akka.io/
http://lightbend.com
http://letitcrash.com
Principles of Reactive Programming @ Coursera
Akka Streams:
http://doc.akka.io/docs/akka/current/scala/stream/
THANKS!
Q & A

More Related Content

PPTX
How to manage large amounts of data with akka streams
PDF
Kafka Summit NYC 2017 - Introducing Exactly Once Semantics in Apache Kafka
PDF
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
PDF
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
PDF
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
PPTX
Streaming and Messaging
PDF
Kafka At Scale in the Cloud
PDF
Bootstrapping Microservices with Kafka, Akka and Spark
How to manage large amounts of data with akka streams
Kafka Summit NYC 2017 - Introducing Exactly Once Semantics in Apache Kafka
Monitoring, the Prometheus Way - Julius Voltz, Prometheus
Kafka Summit NYC 2017 - Running Hundreds of Kafka Clusters with 5 People
Kafka Summit SF 2017 - Kafka Stream Processing for Everyone with KSQL
Streaming and Messaging
Kafka At Scale in the Cloud
Bootstrapping Microservices with Kafka, Akka and Spark

What's hot (20)

PDF
From Three Nines to Five Nines - A Kafka Journey
PDF
Multi cluster, multitenant and hierarchical kafka messaging service slideshare
PDF
Better Kafka Performance Without Changing Any Code | Simon Ritter, Azul
PPTX
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
PDF
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
PDF
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
PPTX
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
PPTX
Exactly-once Stream Processing with Kafka Streams
PDF
Error Resilient Design: Building Scalable & Fault-Tolerant Microservices with...
PDF
Netflix Keystone Pipeline at Samza Meetup 10-13-2015
PDF
Apache Kafka: New Features That You Might Not Know About
PPTX
Introducing Exactly Once Semantics To Apache Kafka
PDF
Netflix at-disney-09-26-2014
PPTX
Apache Incubator Samza: Stream Processing at LinkedIn
PDF
Apache Kafka - Martin Podval
PPTX
Akka Microservices Architecture And Design
PDF
Deploying Kafka at Dropbox, Mark Smith, Sean Fellows
PDF
Exactly-once Semantics in Apache Kafka
PDF
Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
PDF
Pulsarctl & Pulsar Manager
From Three Nines to Five Nines - A Kafka Journey
Multi cluster, multitenant and hierarchical kafka messaging service slideshare
Better Kafka Performance Without Changing Any Code | Simon Ritter, Azul
When it Absolutely, Positively, Has to be There: Reliability Guarantees in Ka...
S3, Cassandra or Outer Space? Dumping Time Series Data using Spark - Demi Be...
What is the State of my Kafka Streams Application? Unleashing Metrics. | Neil...
Fundamentals of Stream Processing with Apache Beam, Tyler Akidau, Frances Perry
Exactly-once Stream Processing with Kafka Streams
Error Resilient Design: Building Scalable & Fault-Tolerant Microservices with...
Netflix Keystone Pipeline at Samza Meetup 10-13-2015
Apache Kafka: New Features That You Might Not Know About
Introducing Exactly Once Semantics To Apache Kafka
Netflix at-disney-09-26-2014
Apache Incubator Samza: Stream Processing at LinkedIn
Apache Kafka - Martin Podval
Akka Microservices Architecture And Design
Deploying Kafka at Dropbox, Mark Smith, Sean Fellows
Exactly-once Semantics in Apache Kafka
Monitoring and Scaling Redis at DataDog - Ilan Rabinovitch, DataDog
Pulsarctl & Pulsar Manager
Ad

Viewers also liked (13)

PDF
Hot and spicy Java with Lombok. Live!
PDF
Introduction to concurrent programming with akka actors
PDF
Introduction to Akka
PDF
Introducing Akka
PPTX
Flume vs. kafka
PPTX
Animals
DOCX
CV Engr Qaisar Mahmood
PDF
Kubo Recruitment: Attracting Candidates
PPTX
LADIES FANCY KAFTAN MAXI DRESS
PPTX
Leftventricularassistdevice 150525194214-lva1-app6891
PDF
DCVCS using GIT
PPT
adjetivos,adverbios, comparativos y superlativos
PDF
Biokuras
Hot and spicy Java with Lombok. Live!
Introduction to concurrent programming with akka actors
Introduction to Akka
Introducing Akka
Flume vs. kafka
Animals
CV Engr Qaisar Mahmood
Kubo Recruitment: Attracting Candidates
LADIES FANCY KAFTAN MAXI DRESS
Leftventricularassistdevice 150525194214-lva1-app6891
DCVCS using GIT
adjetivos,adverbios, comparativos y superlativos
Biokuras
Ad

Similar to Introduction to Akka-Streams (20)

PDF
Take a Look at Akka+Java (English version)
PPTX
Reactive Streams - László van den Hoek
PPTX
Akka for big data developers
PDF
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
PDF
Actor model in F# and Akka.NET
PDF
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
PDF
Spring Boot Microservices vs Akka Actor Cluster
PDF
Reactive programming with akka
PPTX
Орхан Гасимов: "Reactive Applications in Java with Akka"
PDF
Building Stateful Microservices With Akka
PPTX
Akka Actors
PDF
Recipes to develop a reactive and cloud-ready application using Scala and Akka
PDF
Reactive applications with Akka.Net - DDD East Anglia 2015
PPTX
Introduction to Akka - Atlanta Java Users Group
PDF
Akka in Action 1st Edition Raymond Roestenburg download pdf
PPTX
Akka dotnet presentation ndc 2017
PDF
[PDF Download] Akka in Action 1st Edition Raymond Roestenburg fulll chapter
PDF
Reactive applications and Akka intro used in the Madrid Scala Meetup
PDF
Agile Lab_BigData_Meetup_AKKA
PDF
Reactive applications using Akka
Take a Look at Akka+Java (English version)
Reactive Streams - László van den Hoek
Akka for big data developers
Akka A to Z: A Guide To The Industry’s Best Toolkit for Fast Data and Microse...
Actor model in F# and Akka.NET
Building a Reactive System with Akka - Workshop @ O'Reilly SAConf NYC
Spring Boot Microservices vs Akka Actor Cluster
Reactive programming with akka
Орхан Гасимов: "Reactive Applications in Java with Akka"
Building Stateful Microservices With Akka
Akka Actors
Recipes to develop a reactive and cloud-ready application using Scala and Akka
Reactive applications with Akka.Net - DDD East Anglia 2015
Introduction to Akka - Atlanta Java Users Group
Akka in Action 1st Edition Raymond Roestenburg download pdf
Akka dotnet presentation ndc 2017
[PDF Download] Akka in Action 1st Edition Raymond Roestenburg fulll chapter
Reactive applications and Akka intro used in the Madrid Scala Meetup
Agile Lab_BigData_Meetup_AKKA
Reactive applications using Akka

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PPTX
Transform Your Business with a Software ERP System
PPTX
Materi-Enum-and-Record-Data-Type (1).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
medical staffing services at VALiNTRY
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPT
Introduction Database Management System for Course Database
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PPTX
history of c programming in notes for students .pptx
PDF
Complete React Javascript Course Syllabus.pdf
PPT
JAVA ppt tutorial basics to learn java programming
PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Materi_Pemrograman_Komputer-Looping.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
top salesforce developer skills in 2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Upgrade and Innovation Strategies for SAP ERP Customers
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Transform Your Business with a Software ERP System
Materi-Enum-and-Record-Data-Type (1).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
medical staffing services at VALiNTRY
How to Choose the Right IT Partner for Your Business in Malaysia
Introduction Database Management System for Course Database
2025 Textile ERP Trends: SAP, Odoo & Oracle
history of c programming in notes for students .pptx
Complete React Javascript Course Syllabus.pdf
JAVA ppt tutorial basics to learn java programming
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Which alternative to Crystal Reports is best for small or large businesses.pdf
Materi_Pemrograman_Komputer-Looping.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
ISO 45001 Occupational Health and Safety Management System
top salesforce developer skills in 2025.pdf

Introduction to Akka-Streams