Super Fast Workflow - JAX Finance · 2018. 6. 21. · •The current Workflow Engine Architecture...
Transcript of Super Fast Workflow - JAX Finance · 2018. 6. 21. · •The current Workflow Engine Architecture...
Daniel Meyer | Camunda
Super Fast Workflow
Request Response
SystemClient
Request
Response
Do some calculation
Client waits for the response
Async Work
SystemClient
Request
Ack
Do some calculationlater
Callback
Overview
• My goal• The current Workflow Engine Architecture• The next Generation Workflow Engine
Architecture
My Goal
• Build a better Workflow Engine
• > 100x better throughput• Horizontally Scalable• Easy to use• Updates without downtime• Data Replication• Simple, Composable Architecture
What we have today
• In the open source space: embeddable Java Workflow Engines Activiti Bonita Camunda JBPM ...
Embeddable WF Engines
• Added as a library to an application (used in-process)
• Can also be used remotely via REST but were not designed for this
Embeddable WF Engines
• Design Choices
Shared Database for Persistence Synchronous / blocking Execution Multi-Threaded Execution
Embeddable WF Engines
• Immediate Consequences (Camunda)
Limited Scalability Optimistic Locking at synchronization points
Still Deadlocks (although very low probability)
Embeddable WF Engines
• Other Consequences (Camunda)
Hard to update without downtime Hard use as a platform Different Api & Usage model for Remote vs. Local
> we can to do better
•How can we make this •a lot faster?
Design Principles
• Brokered Architecture• Replicated, Append only Logs• Single Writer Principle• Sharding• Recative, composable Architecture
Design Principles
• Brokered Architecture• Replicated, Append only Logs• Single Writer Principle• Sharding• Recative, composable Architecture
New Architecture
Client
Broker
TCP/IP
ReqestBuffer
ResponseBuffer
LogBuffer
Log
Worker
poll()
poll()
write()
write() read()
append()
Async Task Protocol
BrokerClient
1. create_task()
2. poll_and_lock_tasks()
3. complete_task()
Async Task Protocol
BrokerClient
1. create_task()
2. poll_and_lock_tasks()
3. abort_task()
State Machines and Logs
• Task Instance State Machine (simplified):
• NEW → LOCKED → COMPLETED
...1NEW
1LOCKED
1COMPLETED
Append next
Continuations
complete()
ack
Continue ?
State Machines, Logs and Contiunations
...7COMPLETED
...1NEW
1LOCKED
1COMPLETED
AsyncTask Instance Log
...7ACTIVE
Flow Node Instance Log
...
...
Result
Camunda 7 New Prototype
Create Async Taskwith 512 Bytes payload
~720 / second ~310K / second (in a burst of 1M Tasks)
On this Laptop: Samusung SSD 250G, Intel(R) Core(TM) i7-3520M CPU 4 cores
What's next?
• Finish • Replication & Distribution
• We need feedback from potential Users• This is a long shot
Thank You
• The name is: Daniel Meyer
• Leading the Runtime Infrastructure and Applications Team at Camunda.org
• Twitter: @MeyerDan
What about User / Human Tasks?
25
=> Just a predefined “Worker” with own DB and Tasklist UI
Broker
Tasklist UI
complete_task()query_tasks()claim_task()assign_task()...
User Task Service poll_and_lock()
complete()
API
User Task DB
UserTaskTable
What about Cockpit and History?
26
=> “Downloads” all topics and stores in a DB, indexed and optimized for Querying
BrokerqueryXX()
History Servicepoll(topic,offset)
API
History DB
Table
offset
Topic“Everything that happened”
0 1Cockpit UI