Indic threads pune12-akka-actors

8
Implementing Lock Free Concurrency with AKKA Sameer Arora

description

The 7th Annual IndicThreads Pune Conference was held on 14-15 December 2012. http://pune12.indicthreads.com/

Transcript of Indic threads pune12-akka-actors

Page 1: Indic threads pune12-akka-actors

Implementing Lock Free Concurrency with AKKA

Sameer Arora

Page 2: Indic threads pune12-akka-actors

2

Agenda● Actor Model for Concurrency.

● Actors V Threads.

● Sleeping Barber Problem.

● Introduction to Akka.

● Demo

● Questions & Feedback

Page 3: Indic threads pune12-akka-actors

3

Actors● Are Objects that communicate only by means of Asynchronous message passing.

● Do not expose their state to other objects/actors.

● Provide a Non Blocking,highly performant event-driven programming model .

Page 4: Indic threads pune12-akka-actors

4

Actors V Threads● Writing Concurrent programs using Threads is too hard to write and test.

● Shared Memory Model causes Race Conditions, Lowered throughput, deadlocks.

● Actors are Lightweight - consume ~600 bytes memory.

● Do not map one-to-one with OS Threads.

● Actors remain in a suspended state – function via Schedulers running underneath.

● Actors Offer a Lock-free approach to concurrency – helps in Scaling and increased Throughput.

Page 5: Indic threads pune12-akka-actors

5

Sleeping Barber Problem

Page 6: Indic threads pune12-akka-actors

6

AKKA

● Provides a Run time for Actors Programming model.

● Manages the Actors life-cycle

● Has API for Java and Scala .

● Provides Integration with Spring Integration,Apache Camel, Google Guice etc.

Page 7: Indic threads pune12-akka-actors

7

Demo

Sleeping Barber problem with Akka

Simple Routing Application on Akka

Page 8: Indic threads pune12-akka-actors

8

Questions/Comments/Feedback