SlideShare a Scribd company logo
Orchestration DSL
Agenda One-minute Intro to squbs
The Orchestration Use Case
Describing Orchestration in a DSL
Errors & Timeouts
Integrations
https://github.com/paypal/squbs
Standardization for Large number
of Heterogeneous Services
Hooks for Logging &
Operationalization
Programming Patterns
Internet Scale Akka
Orchestration Use-Cases
Orchestrator
Worker
Worker
Worker
Service
Service
Service
Request/Response Message
Orchestration Use-Cases
• Blocking threads while waiting for
tasks
• Highly inefficient use of resources
• Prone to downstream failures and
connection stacking
Synchronous Systems
• Message-oriented
• Never blocking
• Optimal parallelism – with Akka
Asynchronous Systems
Common pattern coordinating workers & services
Synchronous Dispatch Model
Request Thread Pool
AcceptorThread
select
n concurrent requests
n concurrent threads
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Service Calls
Request Thread Pool
Blocked
Service
Client
AcceptorThread
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Service
Client
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Service
Client
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Service
Client
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Service Orchestration
Request Thread Pool
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Request Thread Pool9
Blocked
Orchestrat
e
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Orchestrat
e
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Orchestrat
e
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Blocked
Orchestrat
e
Worker
Logic
JAX-RS
Resource
Servlet
Catalina/
Valves
Orchestration Thread Pool
Blocked
Service
Client
Task
Blocked
Service
Client
Task
Blocked
Service
Client
Task
Blocked
Service
Client
Task
Problem
Summary
Synchronous, thread-holding
Threads blocked from useful
processing
Need for orchestrator to make parallel
service calls
Even more orchestration threads
Heavy resource usage & context switch
Akka Async, message passing middleware
Actors hold state but not threads
Low thread count, low context switch
Resilience & Supervision
Akka Actor Scheduling
12
Dispatcher
Low number of threads (1-2 per CPU)
Actor
Message Received
Run to completion
Multiple messages per dispatch
Actor Scheduled on Thread
Scheduling Actor ≠ Scheduling “task”
Asynchronous Orchestration Model
• Tasks represented by actors and/or services
• Tasks dependent on each others by results of previous task
• Each task can run independent of each other
• Tasks can run as early as the input to these tasks are available
• Tasks may or may not run parallel to other tasks, resource dependent
Before We Start
• Make sure you have the right dependency in your build.sbt
libraryDependencies += "org.squbs" %% "squbs-pattern" % "0.8.0"
Setting up the Orchestrator
class MyTaskOrchestrator(task1Actor: ActorRef, task2Actor: ActorRef,
task3Actor: ActorRef, task4Actor: ActorRef,
task5Actor: ActorRef)
extends Actor with Orchestrator {
expectOnce {
case input: Input => orchestrate(input, sender())
}
def orchestrate(input: Input, requester: ActorRef): Unit = {
// Goodies go here…
}
}
Input Dependencies
task1
task2
task3
task4
task5
Input
Output
val task1F = doTask1(input)
val task2F = doTask2(input)
val task3F = (task1F, task2F) >> doTask3
val task4F = task2F >> doTask4
val task5F = (task3F, task4F) >> doTask5
for { result <- task5F } {
requester ! result
context.stop(self)
}
Describing the Orchestration in an Actor
task1
task2
task3
task4
task5
Input
Output
Orchestrator Characteristics
• Single-use actor, terminates after ONE orchestration
• Keeps orchestration state in Actor as OFuture
• OFuture: Same API as Future, no ExecutionContext
• Runs callbacks on actor message handling thread
• Similar to Java 8 CompletableFuture synchronous API
• Spares users and actors from potential concurrent close-overs
• Future implicitly converts to OFuture in Orchestrator Actor
• Resolves final result from one or more OFutures using for-
comprehensions and sends back to requester
Orchestration Functions
• (in1: T, in2: U, … inN: W) => OFuture[X]
• Mentioned as doTask1, doTask2, etc. in the example
• Usually calls other actors
• May use ask to ask another actor
• Or better performance – tell and receive value with expectOnce
Orchestration Function Examples
def doTask1(input: Input): OFuture[Task1Output] = {
implicit val timeout = Timeout(5 seconds)
(task1Actor ? input).mapTo[Task1Output]
}
def doTask3(input1: Task1Output, input2: Task2Output):
OFuture[Task3Output] = {
val promise = OPromise[Task3Output]
task3Actor ! Task3Input(input1.s, input2.s)
expectOnce {
case o: Task3Output => promise.success(o)
case e: Task3Exception => promise.failure(e)
}
promise.future
}
Be Responsive, Do Timeout
…
val task4F = task2F >> doTask4
val task5F = (task3F, task4F) >> doTask5
for { result <- task5F } {
requester ! result
context.stop(self)
}
import context.dispatcher
context.system.scheduler.scheduleOnce(100 millis, self, Timeout)
expectOnce {
case Timeout =>
requester ! Timeout
context.stop(self)
}
And Handle Your Errors
…
expectOnce {
case Timeout =>
requester ! Timeout
context.stop(self)
}
task2F onFailure {
case e: Task2Exception =>
requester ! e
context.stop(self)
}
More Error Handling…
// Combining Futures
val myFailF =
for {
t1 <- task1F
e2 <- task4F.failed
} yield CombinedException(t1.s + e2.getMessage)
// Recovering Futures
val task3RecoveredF = task3SuccessF.recover {
case e: Task3Exception => Task3Output("It's OK")
}
Orchestration
Summary
High-performance asynchronous
orchestration
Responsive: Respond within SLA,
with or without results
Streamlined error handling
Reduced code complexity
Integrations/Usa
ge
Spray/Akka HTTP:
onComplete + ask
Akka Streams:
mapAsync + ask
Any actor:
ask or tell
As a sub-Orchestrator
when Orchestrator gets complex
Bootstrap & lifecycle control
for http, actors, and streams
Extension model for hooking into
operationalization
Data center aware clustering
Actor registry
Monitoring & console
Many more patterns
What’s more about it?
Q&A – Feedback Appreciated
Asynchronous Orchestration DSL on squbs

More Related Content

PPTX
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Kafka
PPTX
Service Stampede: Surviving a Thousand Services
PPT
Specs2 whirlwind tour at Scaladays 2014
PPTX
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
PDF
Akka Streams and HTTP
PPTX
How to manage large amounts of data with akka streams
PDF
Akka streams
PDF
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Kafka
Service Stampede: Surviving a Thousand Services
Specs2 whirlwind tour at Scaladays 2014
Back-Pressure in Action: Handling High-Burst Workloads with Akka Streams & Ka...
Akka Streams and HTTP
How to manage large amounts of data with akka streams
Akka streams
Understanding Akka Streams, Back Pressure, and Asynchronous Architectures

What's hot (20)

PDF
Modernizing Infrastructures for Fast Data with Spark, Kafka, Cassandra, React...
PPTX
Real-time streaming and data pipelines with Apache Kafka
PDF
Reactive Stream Processing with Akka Streams
KEY
Scaling Twitter with Cassandra
PDF
Journey into Reactive Streams and Akka Streams
ODP
Akka streams
PPT
Spark stream - Kafka
PDF
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
PDF
Reactive programming on Android
PDF
Akka streams scala italy2015
PDF
A dive into akka streams: from the basics to a real-world scenario
PDF
Reactive Streams / Akka Streams - GeeCON Prague 2014
PDF
Stream Processing using Apache Spark and Apache Kafka
PPTX
Developing a Real-time Engine with Akka, Cassandra, and Spray
ODP
Meet Up - Spark Stream Processing + Kafka
PDF
Building Stateful Microservices With Akka
PDF
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
PPTX
Spark Streaming Recipes and "Exactly Once" Semantics Revised
PPTX
To scale or not to scale: Key/Value, Document, SQL, JPA – What’s right for my...
PDF
Native container monitoring
Modernizing Infrastructures for Fast Data with Spark, Kafka, Cassandra, React...
Real-time streaming and data pipelines with Apache Kafka
Reactive Stream Processing with Akka Streams
Scaling Twitter with Cassandra
Journey into Reactive Streams and Akka Streams
Akka streams
Spark stream - Kafka
Build Real-Time Streaming ETL Pipelines With Akka Streams, Alpakka And Apache...
Reactive programming on Android
Akka streams scala italy2015
A dive into akka streams: from the basics to a real-world scenario
Reactive Streams / Akka Streams - GeeCON Prague 2014
Stream Processing using Apache Spark and Apache Kafka
Developing a Real-time Engine with Akka, Cassandra, and Spray
Meet Up - Spark Stream Processing + Kafka
Building Stateful Microservices With Akka
Spark DataFrames: Simple and Fast Analytics on Structured Data at Spark Summi...
Spark Streaming Recipes and "Exactly Once" Semantics Revised
To scale or not to scale: Key/Value, Document, SQL, JPA – What’s right for my...
Native container monitoring
Ad

Similar to Asynchronous Orchestration DSL on squbs (20)

PDF
Advanced patterns in asynchronous programming
PDF
Building Scalable Stateless Applications with RxJava
PPTX
Async and parallel patterns and application design - TechDays2013 NL
PDF
Activator and Reactive at Play NYC meetup
PDF
Writing Asynchronous Programs with Scala & Akka
PDF
Solr @ Etsy - Apache Lucene Eurocon
PDF
Rhebok, High Performance Rack Handler / Rubykaigi 2015
PPTX
The dark side of Akka and the remedy - bp.scala meetup
PDF
Douglas Crockford: Serversideness
PPT
Server side JavaScript: going all the way
PPTX
Sharding and Load Balancing in Scala - Twitter's Finagle
PDF
Julio Capote, Twitter
PPTX
Developing distributed applications with Akka and Akka Cluster
PPTX
.NET Multithreading/Multitasking
PPTX
Top 10 RxJs Operators in Angular
KEY
Concurrent programming with Celluloid (MWRC 2012)
PPTX
Intro to Reactive Thinking and RxJava 2
PDF
Currying and Partial Function Application (PFA)
PDF
Azure Durable Functions (2019-04-27)
PDF
Introduction tomcat7 servlet3
Advanced patterns in asynchronous programming
Building Scalable Stateless Applications with RxJava
Async and parallel patterns and application design - TechDays2013 NL
Activator and Reactive at Play NYC meetup
Writing Asynchronous Programs with Scala & Akka
Solr @ Etsy - Apache Lucene Eurocon
Rhebok, High Performance Rack Handler / Rubykaigi 2015
The dark side of Akka and the remedy - bp.scala meetup
Douglas Crockford: Serversideness
Server side JavaScript: going all the way
Sharding and Load Balancing in Scala - Twitter's Finagle
Julio Capote, Twitter
Developing distributed applications with Akka and Akka Cluster
.NET Multithreading/Multitasking
Top 10 RxJs Operators in Angular
Concurrent programming with Celluloid (MWRC 2012)
Intro to Reactive Thinking and RxJava 2
Currying and Partial Function Application (PFA)
Azure Durable Functions (2019-04-27)
Introduction tomcat7 servlet3
Ad

Recently uploaded (20)

PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PPTX
Online Work Permit System for Fast Permit Processing
PPTX
ISO 45001 Occupational Health and Safety Management System
PDF
top salesforce developer skills in 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
AI in Product Development-omnex systems
PPTX
history of c programming in notes for students .pptx
PDF
System and Network Administraation Chapter 3
PPTX
Essential Infomation Tech presentation.pptx
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
System and Network Administration Chapter 2
DOCX
The Five Best AI Cover Tools in 2025.docx
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Complete React Javascript Course Syllabus.pdf
PDF
Design an Analysis of Algorithms II-SECS-1021-03
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Upgrade and Innovation Strategies for SAP ERP Customers
Online Work Permit System for Fast Permit Processing
ISO 45001 Occupational Health and Safety Management System
top salesforce developer skills in 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
AI in Product Development-omnex systems
history of c programming in notes for students .pptx
System and Network Administraation Chapter 3
Essential Infomation Tech presentation.pptx
How to Migrate SBCGlobal Email to Yahoo Easily
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
System and Network Administration Chapter 2
The Five Best AI Cover Tools in 2025.docx
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Operating system designcfffgfgggggggvggggggggg
Which alternative to Crystal Reports is best for small or large businesses.pdf
Complete React Javascript Course Syllabus.pdf
Design an Analysis of Algorithms II-SECS-1021-03

Asynchronous Orchestration DSL on squbs

  • 2. Agenda One-minute Intro to squbs The Orchestration Use Case Describing Orchestration in a DSL Errors & Timeouts Integrations
  • 3. https://github.com/paypal/squbs Standardization for Large number of Heterogeneous Services Hooks for Logging & Operationalization Programming Patterns Internet Scale Akka
  • 5. Orchestration Use-Cases • Blocking threads while waiting for tasks • Highly inefficient use of resources • Prone to downstream failures and connection stacking Synchronous Systems • Message-oriented • Never blocking • Optimal parallelism – with Akka Asynchronous Systems Common pattern coordinating workers & services
  • 6. Synchronous Dispatch Model Request Thread Pool AcceptorThread select n concurrent requests n concurrent threads Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves
  • 7. Service Calls Request Thread Pool Blocked Service Client AcceptorThread Worker Logic JAX-RS Resource Servlet Catalina/ Valves Blocked Service Client Worker Logic JAX-RS Resource Servlet Catalina/ Valves Blocked Service Client Worker Logic JAX-RS Resource Servlet Catalina/ Valves Blocked Service Client Worker Logic JAX-RS Resource Servlet Catalina/ Valves
  • 8. Service Orchestration Request Thread Pool Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves Worker Logic JAX-RS Resource Servlet Catalina/ Valves
  • 10. Problem Summary Synchronous, thread-holding Threads blocked from useful processing Need for orchestrator to make parallel service calls Even more orchestration threads Heavy resource usage & context switch
  • 11. Akka Async, message passing middleware Actors hold state but not threads Low thread count, low context switch Resilience & Supervision
  • 12. Akka Actor Scheduling 12 Dispatcher Low number of threads (1-2 per CPU) Actor Message Received Run to completion Multiple messages per dispatch Actor Scheduled on Thread Scheduling Actor ≠ Scheduling “task”
  • 13. Asynchronous Orchestration Model • Tasks represented by actors and/or services • Tasks dependent on each others by results of previous task • Each task can run independent of each other • Tasks can run as early as the input to these tasks are available • Tasks may or may not run parallel to other tasks, resource dependent
  • 14. Before We Start • Make sure you have the right dependency in your build.sbt libraryDependencies += "org.squbs" %% "squbs-pattern" % "0.8.0"
  • 15. Setting up the Orchestrator class MyTaskOrchestrator(task1Actor: ActorRef, task2Actor: ActorRef, task3Actor: ActorRef, task4Actor: ActorRef, task5Actor: ActorRef) extends Actor with Orchestrator { expectOnce { case input: Input => orchestrate(input, sender()) } def orchestrate(input: Input, requester: ActorRef): Unit = { // Goodies go here… } }
  • 17. val task1F = doTask1(input) val task2F = doTask2(input) val task3F = (task1F, task2F) >> doTask3 val task4F = task2F >> doTask4 val task5F = (task3F, task4F) >> doTask5 for { result <- task5F } { requester ! result context.stop(self) } Describing the Orchestration in an Actor task1 task2 task3 task4 task5 Input Output
  • 18. Orchestrator Characteristics • Single-use actor, terminates after ONE orchestration • Keeps orchestration state in Actor as OFuture • OFuture: Same API as Future, no ExecutionContext • Runs callbacks on actor message handling thread • Similar to Java 8 CompletableFuture synchronous API • Spares users and actors from potential concurrent close-overs • Future implicitly converts to OFuture in Orchestrator Actor • Resolves final result from one or more OFutures using for- comprehensions and sends back to requester
  • 19. Orchestration Functions • (in1: T, in2: U, … inN: W) => OFuture[X] • Mentioned as doTask1, doTask2, etc. in the example • Usually calls other actors • May use ask to ask another actor • Or better performance – tell and receive value with expectOnce
  • 20. Orchestration Function Examples def doTask1(input: Input): OFuture[Task1Output] = { implicit val timeout = Timeout(5 seconds) (task1Actor ? input).mapTo[Task1Output] } def doTask3(input1: Task1Output, input2: Task2Output): OFuture[Task3Output] = { val promise = OPromise[Task3Output] task3Actor ! Task3Input(input1.s, input2.s) expectOnce { case o: Task3Output => promise.success(o) case e: Task3Exception => promise.failure(e) } promise.future }
  • 21. Be Responsive, Do Timeout … val task4F = task2F >> doTask4 val task5F = (task3F, task4F) >> doTask5 for { result <- task5F } { requester ! result context.stop(self) } import context.dispatcher context.system.scheduler.scheduleOnce(100 millis, self, Timeout) expectOnce { case Timeout => requester ! Timeout context.stop(self) }
  • 22. And Handle Your Errors … expectOnce { case Timeout => requester ! Timeout context.stop(self) } task2F onFailure { case e: Task2Exception => requester ! e context.stop(self) }
  • 23. More Error Handling… // Combining Futures val myFailF = for { t1 <- task1F e2 <- task4F.failed } yield CombinedException(t1.s + e2.getMessage) // Recovering Futures val task3RecoveredF = task3SuccessF.recover { case e: Task3Exception => Task3Output("It's OK") }
  • 24. Orchestration Summary High-performance asynchronous orchestration Responsive: Respond within SLA, with or without results Streamlined error handling Reduced code complexity
  • 25. Integrations/Usa ge Spray/Akka HTTP: onComplete + ask Akka Streams: mapAsync + ask Any actor: ask or tell As a sub-Orchestrator when Orchestrator gets complex
  • 26. Bootstrap & lifecycle control for http, actors, and streams Extension model for hooking into operationalization Data center aware clustering Actor registry Monitoring & console Many more patterns What’s more about it?
  • 27. Q&A – Feedback Appreciated