SlideShare a Scribd company logo
2.0 Reloaded

       Meetu Maltiar
Email: meetu@knoldus.com
  Twitter:@meetumaltiar
Akka 2.0
Akka name comes from Sami mythology is actually
     name of a goddess of wisdom and beauty.

    Akka incidentally means sister in Telugu!!
The Problem
It is way too hard to build
  => correct highly concurrent systems
  => truly scalable systems
  => self-healing, fault-tolerant systems
What is Akka?
Right abstraction with actors for concurrent, fault-tolerant
and scalable applications


For Fault-Tolerance uses “let it crash” model


Abstraction for transparent distribution for load
Introducing Actors
Actor is an entity encapsulating behavior, state and a
mailbox to receive messages

For a message received by Actor a thread is allocated to it

Then Actors behavior is applied to the message and
potentially some state is changed or messages is passed to
other Actors
Introducing Actors..
There is elasticity between message processing and
addition of new messages. New messages can be added
while actor execution is happening.

When processing of messages is completed thread is
deallocated from the actor. It can be reallocated a thread at
a later time
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Create Application
import akka.actor.ActorSystem

val system =
ActorSystem("firstApp")
My First Actor
import akka.actor.{ Actor, Props }


class MyFirstActor extends Actor {
  def receive = {
    case msg => println("Hello!!")
  }
}
Create Actors
import akka.actor.{ ActorSystem, Props }


val system = ActorSystem("firstApp")
val myFirstActor =
system.actorOf(Props[MyFirstActor])


     MyFirstActor is an ActorRef
       Create a top level actor
Stop Actors
system stop myFirstActor



Also stops all actors in hierarchy
Send: !
myFirstActor ! “Hello”



      fire-forget
Ask: ?
import akka.pattern.ask


implicit val timeout = Timeout(50000 milliseconds)

val future = myActor ? "hello"


Await.result(future, timeout.duration).asInstanceOf[Int]




           Returns a Future[Any]
Reply
import akka.actor.Actor

class LongWorkingActor extends Actor {
  def receive = {
    case number: Int =>
      sender ! (“Hi I received ” + number)
  }
}
Routers
RoundRobin
Random
SmallestMailBox
BroadCast
ScatterGaherFirstCompleted
Routers...

val router =
system.actorOf(
Props[RouterWorkerActor].
withRouter(RoundRobinRouter(nrOfInstances = 5)))
Let It Crash
Fault Tolerance
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Akka 2.0 Reloaded
Actor Path
val actorRef =
system.actorFor("akka://actorPathApp/user/pa
rent/child")

val parent = context.actorFor("..")

val sibling = context.actorFor("../sibling")


val refPath = actorRef.path
Supervision
class Supervisor extends Actor {
  override val supervisorStrategy =
OneForOneStrategy(maxNrOfRetries = 10,
withinTimeRange = 1 minute) {
    case _: ArithmeticException => Resume
    case _: NullPointerException => Restart
    case _: IllegalArgumentException => Stop
    case _: Exception => Escalate
  }
}
Manage Failure
class FaultTolerantService extends Actor {
  def receive = {
    case msg => println(msg)
  }

    override def preRestart(reason: Throwable, message: Option[Any]) = {
        // clean up before restart
    }

    override def postRestart(reason: Throwable) = {
       // init after restart
    }
}
Code Samples

https://github.com/meetumaltiar/AkkaKnolX
References

Viktor Klang talk on Akka 2.0 at NE Scala symposium

Akka website akka.io

More Related Content

PDF
Introducing Akka
PPTX
Scale up your thinking
PPTX
Introduction to Akka - Atlanta Java Users Group
PDF
Akka and futures
PDF
Back to the futures, actors and pipes: using Akka for large-scale data migration
PDF
Building Massively Scalable application with Akka 2.0
PDF
Actor Model Akka Framework
PDF
Akka Futures and Akka Remoting
Introducing Akka
Scale up your thinking
Introduction to Akka - Atlanta Java Users Group
Akka and futures
Back to the futures, actors and pipes: using Akka for large-scale data migration
Building Massively Scalable application with Akka 2.0
Actor Model Akka Framework
Akka Futures and Akka Remoting

What's hot (20)

PDF
Testing akka-actors
ODP
String interpolation
PDF
The dark side of Akka and the remedy
PDF
First glance at Akka 2.0
PPTX
Scala basic
PDF
3 things you must know to think reactive - Geecon Kraków 2015
PPT
Scala introduction
PPTX
Java notes(OOP) jkuat IT esection
PPTX
Scalamen and OT
PPTX
Java 101 intro to programming with java
PDF
Stepping Up : A Brief Intro to Scala
PPTX
PROGRAMMING IN JAVA
PDF
Lecture1
PPTX
An Introduction to Scala
PDF
Java 8 features
PDF
Scala @ TechMeetup Edinburgh
PPTX
Let's start with Java- Basic Concepts
PPTX
Java 201 Intro to Test Driven Development in Java
PDF
scala
PDF
Advanced akka features
Testing akka-actors
String interpolation
The dark side of Akka and the remedy
First glance at Akka 2.0
Scala basic
3 things you must know to think reactive - Geecon Kraków 2015
Scala introduction
Java notes(OOP) jkuat IT esection
Scalamen and OT
Java 101 intro to programming with java
Stepping Up : A Brief Intro to Scala
PROGRAMMING IN JAVA
Lecture1
An Introduction to Scala
Java 8 features
Scala @ TechMeetup Edinburgh
Let's start with Java- Basic Concepts
Java 201 Intro to Test Driven Development in Java
scala
Advanced akka features
Ad

Similar to Akka 2.0 Reloaded (20)

PDF
Message-based communication patterns in distributed Akka applications
PDF
Akka Actors: an Introduction
PDF
Akka Testkit Patterns
PPTX
Nairobi JVM meetup : Introduction to akka
 
PDF
Concurrency and scalability with akka
PDF
Scalaz 8 vs Akka Actors
KEY
Akka london scala_user_group
PDF
Akka lsug skills matter
PDF
Scaling Web Apps with Akka
ODP
GPars (Groovy Parallel Systems)
PDF
Networks and types - the future of Akka
PDF
Activator and Reactive at Play NYC meetup
PDF
PDF
Reactive Programming in .Net - actorbased computing with Akka.Net
PPTX
Akka framework
PDF
From Elixir to Akka (and back) - ElixirConf Mx 2017
PPTX
.NET F# Events
PDF
Actor Clustering with Docker Containers and Akka.Net in F#
ODP
PDF
Akka Cluster in Java - JCConf 2015
Message-based communication patterns in distributed Akka applications
Akka Actors: an Introduction
Akka Testkit Patterns
Nairobi JVM meetup : Introduction to akka
 
Concurrency and scalability with akka
Scalaz 8 vs Akka Actors
Akka london scala_user_group
Akka lsug skills matter
Scaling Web Apps with Akka
GPars (Groovy Parallel Systems)
Networks and types - the future of Akka
Activator and Reactive at Play NYC meetup
Reactive Programming in .Net - actorbased computing with Akka.Net
Akka framework
From Elixir to Akka (and back) - ElixirConf Mx 2017
.NET F# Events
Actor Clustering with Docker Containers and Akka.Net in F#
Akka Cluster in Java - JCConf 2015
Ad

More from Meetu Maltiar (10)

PDF
Hands-On AWS: Java SDK + CLI for Cloud Developers
PDF
Getting Started With Scala
PDF
Fitnesse With Scala
ODP
Data structures in scala
PDF
Scala categorytheory
ODP
Introducing scala
PDF
Scala test
PDF
Scala Collections
PPTX
Easy ORMness with Objectify-Appengine
PDF
Getting Started With Scala
Hands-On AWS: Java SDK + CLI for Cloud Developers
Getting Started With Scala
Fitnesse With Scala
Data structures in scala
Scala categorytheory
Introducing scala
Scala test
Scala Collections
Easy ORMness with Objectify-Appengine
Getting Started With Scala

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Big Data Technologies - Introduction.pptx
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Advanced Soft Computing BINUS July 2025.pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
20250228 LYD VKU AI Blended-Learning.pptx
“AI and Expert System Decision Support & Business Intelligence Systems”
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Big Data Technologies - Introduction.pptx
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Understanding_Digital_Forensics_Presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
The Rise and Fall of 3GPP – Time for a Sabbatical?
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
Reach Out and Touch Someone: Haptics and Empathic Computing
Advanced Soft Computing BINUS July 2025.pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Akka 2.0 Reloaded