ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
AKKAWriting 'SCALA' ble & concurrent code
CHENSE meetup , Aug 24 2013
AGENDA
What is a concurrent system?
Paradigm
AKKA / Actors
My First Akka Code & Code walk through
Where & How could I use Akka?
Q&A
WHAT IS A CONCURRENT
SYSTEM?
"Concurrency solves the problem of having
scarce CPU resources and many tasks. So,
you create threads or independent paths
of execution through code in order to
share time on the scarce resource"
WHAT IS A CONCURRENT
SYSTEM ? (CONTD.)
capable of doing as many tasks but only one task at a time
like our mind - human mind capability is infinite but we can do at most one task at a time
handle thread lock and manage resources very efficiently
great for writing scalable application
EXAMPLE - "GOPHER'S BURNING PROBLEM" W/O
CONCURRENCY
EXAMPLE - HELPING GOPHERS WITH CONCURRENCY
Note : Multiple Gophers => Multicore CPU
PARADIGM
actor - a concurrent abstraction much like our human
mind
actors over threads to handle concurrency
communicate through message passing (async/ sync)
let actors decide what task to pick up at any instant of
time (take a deep breath)
ACTORS <=> AKKA
lightweight objects which handle message via case
classes in Scala
use pattern matching to receive msgs
async in nature
CODE KATA - MY FIRST
ACTOR
class Greeter extends Actor {
var greeting = ""
def receive = {
case WhoToGreet(who) => {
greeting = s"hello, $who"
println(greeting)
}
}
}
CODE KATA - WRITING
AKKA CLIENT
object HelloAkkaScala extends App {
// Create the 'helloakka' actor system
val system = ActorSystem("helloakka")
// Create the 'greeter' actor
val greeter = system.actorOf(Props[Greeter], "greeter")
greeter.!(WhoToGreet("first message"))
system.shutdown()
}
LET'S GET REAL !!!
WHERE & HOW COULD I
USE AKKA ?
concurrent applications
modeling concurrency
clustered message processing
Q & A
SESSION WHERE ABOUTS
Source :- https://github.com/prassee/hello-akka
Chense G+ page
https://plus.google.com/communities/10010288600516114105
-> THANKS <-

More Related Content

Introduction to akka chense

  • 1. AKKAWriting 'SCALA' ble & concurrent code CHENSE meetup , Aug 24 2013
  • 2. AGENDA What is a concurrent system? Paradigm AKKA / Actors My First Akka Code & Code walk through Where & How could I use Akka? Q&A
  • 3. WHAT IS A CONCURRENT SYSTEM? "Concurrency solves the problem of having scarce CPU resources and many tasks. So, you create threads or independent paths of execution through code in order to share time on the scarce resource"
  • 4. WHAT IS A CONCURRENT SYSTEM ? (CONTD.) capable of doing as many tasks but only one task at a time like our mind - human mind capability is infinite but we can do at most one task at a time handle thread lock and manage resources very efficiently great for writing scalable application
  • 5. EXAMPLE - "GOPHER'S BURNING PROBLEM" W/O CONCURRENCY
  • 6. EXAMPLE - HELPING GOPHERS WITH CONCURRENCY Note : Multiple Gophers => Multicore CPU
  • 7. PARADIGM actor - a concurrent abstraction much like our human mind actors over threads to handle concurrency communicate through message passing (async/ sync) let actors decide what task to pick up at any instant of time (take a deep breath)
  • 8. ACTORS <=> AKKA lightweight objects which handle message via case classes in Scala use pattern matching to receive msgs async in nature
  • 9. CODE KATA - MY FIRST ACTOR class Greeter extends Actor { var greeting = "" def receive = { case WhoToGreet(who) => { greeting = s"hello, $who" println(greeting) } } }
  • 10. CODE KATA - WRITING AKKA CLIENT object HelloAkkaScala extends App { // Create the 'helloakka' actor system val system = ActorSystem("helloakka") // Create the 'greeter' actor val greeter = system.actorOf(Props[Greeter], "greeter") greeter.!(WhoToGreet("first message")) system.shutdown() }
  • 12. WHERE & HOW COULD I USE AKKA ? concurrent applications modeling concurrency clustered message processing
  • 13. Q & A
  • 14. SESSION WHERE ABOUTS Source :- https://github.com/prassee/hello-akka Chense G+ page https://plus.google.com/communities/10010288600516114105 -> THANKS <-