SlideShare a Scribd company logo
Real World Scala hAkking


  Raymond Roestenburg
About me

•   Java since 1997
•   Scala since 2010
•   Mostly backend systems
•   Lead architect Traffic Management at CSC
•   Akka committer

code: http://github.com/RayRoestenburg
blog: http://roestenburg.agilesquad.com
twtr: @RayRoestenburg
Company I work for




             Traffic Management
             • Section Control
             • Weigh in Motion
             • Traffic Information
             • Traffic Enforcement
Agenda

•   @MIGO-BORAS sensordomain
•   Sensor networks
•   Typesafe stack
•   Akka Actors
•   Apache Camel Integration
•   Remote Actors
•   Monitoring
•   Testing
•   Deployment
@MIGO-BORAS

•   Koninklijke Marechaussee
•   MTV (Mobiel Toezicht Vreemdelingen)
•   Prevent illegal border crossing
•   Sensor domain
•   Fixed locations
•   Mobile vehicles
•   Cameras, Radars
•   Vehicle properties
•   January 2012
Sensor networks

• Usable for many applications in our field
     •   Distributed along highways and provincial roads
     •   Traffic Enforcement
     •   Traffic Information
     •   Other applications
     •   Roadside systems
     •   Range of sensor types
          – Camera’s, Infrared, Laser, Piezoelectric, Loops, Mobile
            units, …
     • Remotely Configure & Control
Why Scala & Akka

• Less code, less bugs
• Less code, same VM power
• Experienced team (Java, C#, C)
     • 3 experienced Java devs
     • 1 experienced C# dev with no Java experience
• Need to interoperate with existing Java and
  C (JNA)
• Simplify development (C->Java->Scala)
• Ubuntu
Scala 2.9.x

•   Learning curve (Start with simple features)
•   Traits, Tupels, Stackable Traits
•   First Class Functions
•   Scala Collections
       • map, flatMap, partition, foreach, filter, groupBy..
• Option type
       • map.. orElse, foreach,..
• Case classes
• REPL, DSLs, Extension methods
Typesafe Stack

• Current Stack
     • Open Source
     • SBT 0.7.7
     • Scala 2.9.0-1
     • Akka 1.1.3
     • Camel & Camel Components 2.7.0
       (FTP,Mina,Jetty,…)
     • Jboss Netty 3.2.4
• When we started early 2010
     • Akka 0.7, Scala 2.8.0Beta1
Akka Usage

Core
  Actors, Remote, TestKit, Serialization,
 STM, Agents, Dataflow, Async HTTP (Mist),
 FSM, Transactors

Modules
 MicroKernel, Camel, AMQP, Scalaz,
 Spring, OSGi, DataFlow, Persistence,
Akka Actors


      ActorRef    Mailbox      Actor



Message to send



  Dispatcher



                     Threads
Akka Actors


    ActorRef   Mailbox      Actor




Dispatcher



                  Threads
Akka Actors


    ActorRef   Mailbox      Actor




Dispatcher



                  Threads
Akka Actors


    ActorRef   Mailbox      Actor




Dispatcher



                  Threads
Akka Actors


    ActorRef   Mailbox      Actor




Dispatcher



                  Threads
Akka Actors


    ActorRef   Mailbox      Actor




Dispatcher



                  Threads
One-way messaging




                    Shared
                    Dispatcher
Two-way
Two-way with Futures
Camel Actors

• Camel Component integration
• Consumers and Producers
Camel Consumers
Camel Producers
Camel Producers

• Use CamelContext
Dispatchers




ThreadBasedDispatcher
ExecutorBasedEventDrivenDispatcher
ExecutorBasedWorkStealingDispatcher
PriorityExecutorBasedEventDrivenDispatcher
RollYourOwn
Dispatchers

Camel Producers        Local Processing   Camel Consumers




     Heartbeat,                                 Remote Actors
     Cleanup,
     Schedule,
     Long Running,
     Redelivery,
     Remote Error Handling
Messages

• Case classes
     • Simple data containers
     • toProtobuf and fromProtobuf on case class
       and companion object for remoting
• Every msg has a
     • correlation Id to the event
     • Timestamp
• Logging, Tracing, Performance
Event Process Chains




Load Balancer      EndPoint (Consumer/Producer)

Forwarding Actor
Remote Actors

• Client
     • Actor.remote.actorFor(name, host,port)
• Server
     • Actor.remote.register(name, actorRef)


• remoteActorFor: (String, String, Int) =>
  ActorRef = remote.actorFor
Remote Actors Internals

   •   RemoteActorRef                    • RemoteServer
   •   RemoteClient                      • Netty Server
   •   Netty Channels                    • Lifecycle Event
   •   Serialization (Scala,               listeners
       Java, (S)JSON, ProtoBuf           • RemoteProtocol



RemoteActorRef RemoteProtocol ActorRef       Mailbox    Actor




          RemoteClient    RemoteServer
Remote Actors (Akka 1.1.3)

•   JBoss Netty (Channels)
•   Not as transparent as you would like
•   Remote Lifecycle Listeners
•   Closing sockets, reconnect
•   Own Guaranteed Delivery implementation
     – Specific requirements
     – Bases on Idempotent Receiver and Repeating
       messages after reconnect
     – Non-Trivial
     – Heartbeats
     – Exp Backoff
Remote configuration

•   #compression-scheme = "zlib“ #leave out
•   zlib-compression-level = 0
•   client: reconnection-time-window = 2000000
•   client: read-timeout (we use 60)
•   backlog = 4096 # Netty backlog for
    connections, should suffice, increase if
    failures happen
Monitoring

• Application level monitoring
• Listener Actors contain Custom JMX MBeans
• Direct passthrough of msg or translation
Testing with TestKit
Testing one-way Actor Output
Microkernel deployment

• sbt dist (akka-sbt-plugin)
• Creates dist directory
• init.d scripts
Questions?

More Related Content

PPTX
Using Apache Camel as AKKA
PPTX
Building Micro-Services with Scala
PPTX
Developing distributed applications with Akka and Akka Cluster
PPTX
Why akka
PPTX
Scala in the Wild
PDF
Building Asynchronous Applications
PPTX
Scala adoption by enterprises
PPTX
Composable Futures with Akka 2.0
Using Apache Camel as AKKA
Building Micro-Services with Scala
Developing distributed applications with Akka and Akka Cluster
Why akka
Scala in the Wild
Building Asynchronous Applications
Scala adoption by enterprises
Composable Futures with Akka 2.0

What's hot (20)

PDF
Event Driven Architectures with Camel
PDF
Rails 5 subjective overview
PPT
Sbt, idea and eclipse
PPTX
Akka Fundamentals
PPTX
Reactive Streams - László van den Hoek
PPTX
Multi-threading in the modern era: Vertx Akka and Quasar
PDF
Zeppelin meetup 2016 madrid
PDF
Erlang factory SF 2011 "Erlang and the big switch in social games"
PDF
Samza portable runner for beam
PDF
Scaling software with akka
PPTX
Ruby on Rails All Hands Meeting
PDF
Getting Deep on Orchestration - Nickoloff - DockerCon16
PDF
Java 8 in Anger (JavaOne)
PDF
Introduction to Akka
PPTX
Deploying microservices on AWS
PDF
FunctionalConf '16 Robert Virding Erlang Ecosystem
PDF
Lessons learned migrating 100+ services to Kubernetes
PDF
Erlang as a cloud citizen, a fractal approach to throughput
PDF
Erlang factory 2011 london
KEY
High performance network programming on the jvm oscon 2012
Event Driven Architectures with Camel
Rails 5 subjective overview
Sbt, idea and eclipse
Akka Fundamentals
Reactive Streams - László van den Hoek
Multi-threading in the modern era: Vertx Akka and Quasar
Zeppelin meetup 2016 madrid
Erlang factory SF 2011 "Erlang and the big switch in social games"
Samza portable runner for beam
Scaling software with akka
Ruby on Rails All Hands Meeting
Getting Deep on Orchestration - Nickoloff - DockerCon16
Java 8 in Anger (JavaOne)
Introduction to Akka
Deploying microservices on AWS
FunctionalConf '16 Robert Virding Erlang Ecosystem
Lessons learned migrating 100+ services to Kubernetes
Erlang as a cloud citizen, a fractal approach to throughput
Erlang factory 2011 london
High performance network programming on the jvm oscon 2012
Ad

Viewers also liked (14)

PPT
Working with groups 2
DOCX
Computadora precios
PPT
Inleefreis Zambia
PDF
PPTX
Sound cloud
PPTX
Bootstrapping a Scala Mindset (Scala eXchange 2014)
PDF
Manual camara panasonic
PPTX
The Trouble with Naming
PPT
Turning a Crisis into a Drama
PPT
Five Whys - Devoxx UK 2014
PPTX
Akka in-action
PDF
Get Going with Green - Closing the Sustainability Gap
PDF
Functions, Types, Programs and Effects
PDF
Framework for Clean Technologies in China
Working with groups 2
Computadora precios
Inleefreis Zambia
Sound cloud
Bootstrapping a Scala Mindset (Scala eXchange 2014)
Manual camara panasonic
The Trouble with Naming
Turning a Crisis into a Drama
Five Whys - Devoxx UK 2014
Akka in-action
Get Going with Green - Closing the Sustainability Gap
Functions, Types, Programs and Effects
Framework for Clean Technologies in China
Ad

Similar to Real world Scala hAkking NLJUG JFall 2011 (20)

PDF
Akka in Production - ScalaDays 2015
PDF
Typesafe stack - Scala, Akka and Play
PPTX
Developing distributed applications with Akka and Akka Cluster
PPTX
DotNext 2020 - When and How to Use the Actor Model and Akka.NET
PDF
Monitoring Akka with Kamon 1.0
PPTX
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
KEY
Introduction to Actor Model and Akka
KEY
Andy Parsons Pivotal June 2011
PPTX
Clustersoftware
PDF
Actor model in .NET - Akka.NET
PPTX
A tour of Java and the JVM
PPTX
Indic threads pune12-typesafe stack software development on the jvm
PPT
Java withrealworldtechnology
PDF
Agile Lab_BigData_Meetup_AKKA
PDF
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
PDF
Messaging for IoT
PPTX
Building a multi-tenanted Cloud-native AppServer
PDF
System Integration with Akka and Apache Camel
PDF
Implementing End-To-End Tracing With Roman Kolesnev and Antony Stubbs | Curre...
PDF
Reasonable RPC with Remotely
Akka in Production - ScalaDays 2015
Typesafe stack - Scala, Akka and Play
Developing distributed applications with Akka and Akka Cluster
DotNext 2020 - When and How to Use the Actor Model and Akka.NET
Monitoring Akka with Kamon 1.0
Spark Kernel Talk - Apache Spark Meetup San Francisco (July 2015)
Introduction to Actor Model and Akka
Andy Parsons Pivotal June 2011
Clustersoftware
Actor model in .NET - Akka.NET
A tour of Java and the JVM
Indic threads pune12-typesafe stack software development on the jvm
Java withrealworldtechnology
Agile Lab_BigData_Meetup_AKKA
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Messaging for IoT
Building a multi-tenanted Cloud-native AppServer
System Integration with Akka and Apache Camel
Implementing End-To-End Tracing With Roman Kolesnev and Antony Stubbs | Curre...
Reasonable RPC with Remotely

Recently uploaded (20)

PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
cuic standard and advanced reporting.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPT
Teaching material agriculture food technology
PDF
Machine learning based COVID-19 study performance prediction
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
KodekX | Application Modernization Development
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Cloud computing and distributed systems.
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Electronic commerce courselecture one. Pdf
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
The Rise and Fall of 3GPP – Time for a Sabbatical?
Review of recent advances in non-invasive hemoglobin estimation
CIFDAQ's Market Insight: SEC Turns Pro Crypto
cuic standard and advanced reporting.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
Teaching material agriculture food technology
Machine learning based COVID-19 study performance prediction
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
KodekX | Application Modernization Development
Dropbox Q2 2025 Financial Results & Investor Presentation
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Cloud computing and distributed systems.
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Mobile App Security Testing_ A Comprehensive Guide.pdf
Electronic commerce courselecture one. Pdf

Real world Scala hAkking NLJUG JFall 2011

  • 1. Real World Scala hAkking Raymond Roestenburg
  • 2. About me • Java since 1997 • Scala since 2010 • Mostly backend systems • Lead architect Traffic Management at CSC • Akka committer code: http://github.com/RayRoestenburg blog: http://roestenburg.agilesquad.com twtr: @RayRoestenburg
  • 3. Company I work for Traffic Management • Section Control • Weigh in Motion • Traffic Information • Traffic Enforcement
  • 4. Agenda • @MIGO-BORAS sensordomain • Sensor networks • Typesafe stack • Akka Actors • Apache Camel Integration • Remote Actors • Monitoring • Testing • Deployment
  • 5. @MIGO-BORAS • Koninklijke Marechaussee • MTV (Mobiel Toezicht Vreemdelingen) • Prevent illegal border crossing • Sensor domain • Fixed locations • Mobile vehicles • Cameras, Radars • Vehicle properties • January 2012
  • 6. Sensor networks • Usable for many applications in our field • Distributed along highways and provincial roads • Traffic Enforcement • Traffic Information • Other applications • Roadside systems • Range of sensor types – Camera’s, Infrared, Laser, Piezoelectric, Loops, Mobile units, … • Remotely Configure & Control
  • 7. Why Scala & Akka • Less code, less bugs • Less code, same VM power • Experienced team (Java, C#, C) • 3 experienced Java devs • 1 experienced C# dev with no Java experience • Need to interoperate with existing Java and C (JNA) • Simplify development (C->Java->Scala) • Ubuntu
  • 8. Scala 2.9.x • Learning curve (Start with simple features) • Traits, Tupels, Stackable Traits • First Class Functions • Scala Collections • map, flatMap, partition, foreach, filter, groupBy.. • Option type • map.. orElse, foreach,.. • Case classes • REPL, DSLs, Extension methods
  • 9. Typesafe Stack • Current Stack • Open Source • SBT 0.7.7 • Scala 2.9.0-1 • Akka 1.1.3 • Camel & Camel Components 2.7.0 (FTP,Mina,Jetty,…) • Jboss Netty 3.2.4 • When we started early 2010 • Akka 0.7, Scala 2.8.0Beta1
  • 10. Akka Usage Core Actors, Remote, TestKit, Serialization, STM, Agents, Dataflow, Async HTTP (Mist), FSM, Transactors Modules MicroKernel, Camel, AMQP, Scalaz, Spring, OSGi, DataFlow, Persistence,
  • 11. Akka Actors ActorRef Mailbox Actor Message to send Dispatcher Threads
  • 12. Akka Actors ActorRef Mailbox Actor Dispatcher Threads
  • 13. Akka Actors ActorRef Mailbox Actor Dispatcher Threads
  • 14. Akka Actors ActorRef Mailbox Actor Dispatcher Threads
  • 15. Akka Actors ActorRef Mailbox Actor Dispatcher Threads
  • 16. Akka Actors ActorRef Mailbox Actor Dispatcher Threads
  • 17. One-way messaging Shared Dispatcher
  • 20. Camel Actors • Camel Component integration • Consumers and Producers
  • 23. Camel Producers • Use CamelContext
  • 25. Dispatchers Camel Producers Local Processing Camel Consumers Heartbeat, Remote Actors Cleanup, Schedule, Long Running, Redelivery, Remote Error Handling
  • 26. Messages • Case classes • Simple data containers • toProtobuf and fromProtobuf on case class and companion object for remoting • Every msg has a • correlation Id to the event • Timestamp • Logging, Tracing, Performance
  • 27. Event Process Chains Load Balancer EndPoint (Consumer/Producer) Forwarding Actor
  • 28. Remote Actors • Client • Actor.remote.actorFor(name, host,port) • Server • Actor.remote.register(name, actorRef) • remoteActorFor: (String, String, Int) => ActorRef = remote.actorFor
  • 29. Remote Actors Internals • RemoteActorRef • RemoteServer • RemoteClient • Netty Server • Netty Channels • Lifecycle Event • Serialization (Scala, listeners Java, (S)JSON, ProtoBuf • RemoteProtocol RemoteActorRef RemoteProtocol ActorRef Mailbox Actor RemoteClient RemoteServer
  • 30. Remote Actors (Akka 1.1.3) • JBoss Netty (Channels) • Not as transparent as you would like • Remote Lifecycle Listeners • Closing sockets, reconnect • Own Guaranteed Delivery implementation – Specific requirements – Bases on Idempotent Receiver and Repeating messages after reconnect – Non-Trivial – Heartbeats – Exp Backoff
  • 31. Remote configuration • #compression-scheme = "zlib“ #leave out • zlib-compression-level = 0 • client: reconnection-time-window = 2000000 • client: read-timeout (we use 60) • backlog = 4096 # Netty backlog for connections, should suffice, increase if failures happen
  • 32. Monitoring • Application level monitoring • Listener Actors contain Custom JMX MBeans • Direct passthrough of msg or translation
  • 35. Microkernel deployment • sbt dist (akka-sbt-plugin) • Creates dist directory • init.d scripts

Editor's Notes

  • #13: ActorRef is an immutable reference which exclusively gives access to the Actor.Actors run on Dispatchers. A Dispatcher runs a mailbox to process messages.Amount of messages per mailbox run is configurable. (actor.throughput, default 5)
  • #18: One way messaging between two ActorsActors can process messages in parallel
  • #19: One way messaging between two ActorsActors can process messages in parallel
  • #20: !!! Is preferred over !!Futuresalso run onDispatchers.FutureTimeoutException happens onfuture.get. IfonlyonComplete and failure are registered, yougetnoFutureTimeoutException