Problem
I've been noticing that calling mistral workflows there is a fairly significant latency on the order of several seconds per workflow.
Scenario
In the reproduction we're going to have a "parent" workflow with 3x tasks each calling a "sub" workflow. The sub workflow is going to have a single task that runs a core.local. The command we're going to run core.local is the sleep command.
Reproduction
examples/actions/nick_sub_workflow.yaml
---
description: Run a local linux command
enabled: true
runner_type: mistral-v2
entry_point: workflows/nick_sub_workflow.yaml
name: nick_sub_workflow
pack: examples
parameters:
cmd:
required: true
type: string
examples/actions/workflows/nick_sub_workflow.yaml
version: '2.0'
examples.nick_sub_workflow:
type: direct
input:
- cmd
output:
stdout: <% $.stdout %>
stderr: <% $.stderr %>
tasks:
task1:
action: core.local cmd=<% $.cmd %>
publish:
stdout: <% task(task1).result.stdout %>
stderr: <% task(task1).result.stderr %>
examples/actions/nick_parent_workflow.yaml
---
description: Run a local linux command
enabled: true
runner_type: mistral-v2
entry_point: workflows/nick_parent_workflow.yaml
name: nick_parent_workflow
pack: examples
parameters:
cmd:
required: true
type: string
examples/actions/workflows/nick_parent_workflow.yaml
version: '2.0'
examples.nick_parent_workflow:
type: direct
input:
- cmd
output:
stdout: <% $.stdout %>
tasks:
task1:
action: examples.nick_sub_workflow cmd=<% $.cmd %>
publish:
stdout: <% task(task1).result.stdout %>
stderr: <% task(task1).result.stderr %>
on-success:
- task2
task2:
action: examples.nick_sub_workflow cmd=<% $.cmd %>
publish:
stdout2: <% task(task2).result.stdout %>
stderr2: <% task(task2).result.stderr %>
on-success:
- task3
task3:
action: examples.nick_sub_workflow cmd=<% $.cmd %>
publish:
stdout3: <% task(task3).result.stdout %>
stderr3: <% task(task3).result.stderr %>
Results - Parent
# date --utc --iso-8601=seconds; st2 run examples.nick_parent_workflow cmd="sleep 1"; date --utc --iso-8601=seconds
2017-09-02T01:33:14+0000
...........
id: 59aa0a5aa814c007272e4026
action.ref: examples.nick_parent_workflow
parameters:
cmd: sleep 1
status: succeeded
result_task: task3
result:
extra:
state: SUCCESS
state_info: null
stderr: ''
stdout: ''
tasks:
- created_at: '2017-09-02 01:33:26'
id: c4a6a3bb-b211-40fe-8053-1b540fa2d59b
input: null
name: task1
published:
stderr: ''
stdout: ''
result:
failed: false
return_code: 0
stderr: ''
stdout: ''
succeeded: true
state: SUCCESS
state_info: null
updated_at: '2017-09-02 01:33:27'
workflow_execution_id: ba31c3d6-f9e8-470c-b72c-44f140718d38
workflow_name: examples.nick_sub_workflow
start_timestamp: 2017-09-02T01:33:14.510747Z
end_timestamp: 2017-09-02T01:33:35.810724Z
+-----------------------------+------------------------+-------+--------------------+-----------------+
| id | status | task | action | start_timestamp |
+-----------------------------+------------------------+-------+--------------------+-----------------+
| + 59aa0a5aa814c007272e4029 | succeeded (6s elapsed) | task1 | examples.nick_sub_ | Sat, 02 Sep |
| | | | workflow | 2017 01:33:14 |
| | | | | UTC |
| 59aa0a5ba814c007272e402b | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:15 |
| | | | | UTC |
| + 59aa0a60a814c007272e402d | succeeded (5s elapsed) | task2 | examples.nick_sub_ | Sat, 02 Sep |
| | | | workflow | 2017 01:33:20 |
| | | | | UTC |
| 59aa0a61a814c007272e402f | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:21 |
| | | | | UTC |
| + 59aa0a65a814c007272e4031 | succeeded (5s elapsed) | task3 | examples.nick_sub_ | Sat, 02 Sep |
| | | | workflow | 2017 01:33:25 |
| | | | | UTC |
| 59aa0a66a814c007272e4033 | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:26 |
| | | | | UTC |
+-----------------------------+------------------------+-------+--------------------+-----------------+
2017-09-02T01:33:37+0000
# st2 execution get --detail 59aa0a5aa814c007272e4026
+-----------------+--------------------------------------------------------------+
| Property | Value |
+-----------------+--------------------------------------------------------------+
| id | 59aa0a5aa814c007272e4026 |
| action.ref | examples.nick_parent_workflow |
| context.user | st2admin |
| parameters | { |
| | "cmd": "sleep 1" |
| | } |
| status | succeeded (21s elapsed) |
| start_timestamp | Sat, 02 Sep 2017 01:33:14 UTC |
| end_timestamp | Sat, 02 Sep 2017 01:33:35 UTC |
| result | { |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "workflow_name": |
| | "examples.nick_parent_workflow", |
| | "created_at": "2017-09-02 01:33:14", |
| | "updated_at": "2017-09-02 01:33:20", |
| | "workflow_execution_id": "58e22641-81a1-4dc7 |
| | -998b-fffa14d27e80", |
| | "state": "SUCCESS", |
| | "result": { |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | }, |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "created_at": "2017-09-02 01:33:15", |
| | "updated_at": "2017-09-02 01:33:16", |
| | "id": "6d329e1f-464f-4ac1-948c- |
| | 9d851a0e2d27", |
| | "workflow_execution_id": |
| | "2b7c84e1-0433-46a3-abee-b49fb34755d1", |
| | "state": "SUCCESS", |
| | "result": { |
| | "succeeded": true, |
| | "failed": false, |
| | "return_code": 0, |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "workflow_name": |
| | "examples.nick_sub_workflow" |
| | } |
| | ], |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "id": "5a5b17f5-74f5-4e17-abf5-c10b2d530ce4" |
| | }, |
| | { |
| | "state_info": null, |
| | "name": "task2", |
| | "workflow_name": |
| | "examples.nick_parent_workflow", |
| | "created_at": "2017-09-02 01:33:20", |
| | "updated_at": "2017-09-02 01:33:25", |
| | "workflow_execution_id": "58e22641-81a1-4dc7 |
| | -998b-fffa14d27e80", |
| | "state": "SUCCESS", |
| | "result": { |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "workflow_name": |
| | "examples.nick_sub_workflow", |
| | "created_at": "2017-09-02 01:33:21", |
| | "updated_at": "2017-09-02 01:33:22", |
| | "workflow_execution_id": "fb5d67bb- |
| | f2a6-4bc0-a4ae-c818f905bf1f", |
| | "state": "SUCCESS", |
| | "result": { |
| | "succeeded": true, |
| | "failed": false, |
| | "return_code": 0, |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "id": "474884cc-de3b-49c1-88ea- |
| | 86d5667e6c2a" |
| | } |
| | ], |
| | "stdout": "", |
| | "stderr": "", |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | } |
| | }, |
| | "published": { |
| | "stderr2": "", |
| | "stdout2": "" |
| | }, |
| | "input": null, |
| | "id": "b1246c2d-faee-4b8b-8715-16dca0916457" |
| | }, |
| | { |
| | "state_info": null, |
| | "name": "task3", |
| | "workflow_name": |
| | "examples.nick_parent_workflow", |
| | "created_at": "2017-09-02 01:33:25", |
| | "updated_at": "2017-09-02 01:33:30", |
| | "workflow_execution_id": "58e22641-81a1-4dc7 |
| | -998b-fffa14d27e80", |
| | "state": "SUCCESS", |
| | "result": { |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | }, |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "created_at": "2017-09-02 01:33:26", |
| | "updated_at": "2017-09-02 01:33:27", |
| | "id": |
| | "c4a6a3bb-b211-40fe-8053-1b540fa2d59b", |
| | "workflow_execution_id": |
| | "ba31c3d6-f9e8-470c-b72c-44f140718d38", |
| | "state": "SUCCESS", |
| | "result": { |
| | "succeeded": true, |
| | "failed": false, |
| | "return_code": 0, |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "workflow_name": |
| | "examples.nick_sub_workflow" |
| | } |
| | ], |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr3": "", |
| | "stdout3": "" |
| | }, |
| | "input": null, |
| | "id": "06dd7260-4fe3-483f-84dd-9a5c686aabe1" |
| | } |
| | ], |
| | "stdout": "", |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | } |
| | } |
| liveaction | { |
| | "runner_info": { |
| | "hostname": "stackstorm.maludy.home", |
| | "pid": 1025 |
| | }, |
| | "parameters": { |
| | "cmd": "sleep 1" |
| | }, |
| | "action_is_workflow": true, |
| | "callback": {}, |
| | "action": "examples.nick_parent_workflow", |
| | "id": "59aa0a5aa814c007272e4025" |
| | } |
+-----------------+--------------------------------------------------------------+
Results - Sub Workflow 1
# st2 execution get 59aa0a5aa814c007272e4029
id: 59aa0a5aa814c007272e4029
action.ref: examples.nick_sub_workflow
parameters:
cmd: sleep 1
status: succeeded (6s elapsed)
result_task: task1
result:
failed: false
return_code: 0
stderr: ''
stdout: ''
succeeded: true
start_timestamp: 2017-09-02T01:33:14.846564Z
end_timestamp: 2017-09-02T01:33:20.524351Z
+--------------------------+------------------------+-------+------------+-----------------+
| id | status | task | action | start_timestamp |
+--------------------------+------------------------+-------+------------+-----------------+
| 59aa0a5ba814c007272e402b | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:15 |
| | | | | UTC |
+--------------------------+------------------------+-------+------------+-----------------+
# st2 execution get --detail 59aa0a5aa814c007272e4029
+-----------------+--------------------------------------------------------------+
| Property | Value |
+-----------------+--------------------------------------------------------------+
| id | 59aa0a5aa814c007272e4029 |
| action.ref | examples.nick_sub_workflow |
| context.user | st2admin |
| parameters | { |
| | "cmd": "sleep 1" |
| | } |
| status | succeeded (6s elapsed) |
| start_timestamp | Sat, 02 Sep 2017 01:33:14 UTC |
| end_timestamp | Sat, 02 Sep 2017 01:33:20 UTC |
| result | { |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "workflow_name": "examples.nick_sub_workflow", |
| | "created_at": "2017-09-02 01:33:15", |
| | "updated_at": "2017-09-02 01:33:16", |
| | "workflow_execution_id": "2b7c84e1-0433-46a3 |
| | -abee-b49fb34755d1", |
| | "state": "SUCCESS", |
| | "result": { |
| | "failed": false, |
| | "stderr": "", |
| | "return_code": 0, |
| | "succeeded": true, |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "id": "6d329e1f-464f-4ac1-948c-9d851a0e2d27" |
| | } |
| | ], |
| | "stdout": "", |
| | "stderr": "", |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | } |
| | } |
| liveaction | { |
| | "runner_info": { |
| | "hostname": "stackstorm.maludy.home", |
| | "pid": 1060 |
| | }, |
| | "parameters": { |
| | "cmd": "sleep 1" |
| | }, |
| | "action_is_workflow": true, |
| | "callback": { |
| | "url": "http://0.0.0.0:8989/v2/action_executions |
| | /1d6779dd-ff5b-437b-a900-03485ed17e74", |
| | "source": "mistral_v2" |
| | }, |
| | "action": "examples.nick_sub_workflow", |
| | "id": "59aa0a5aa814c007272e4028" |
| | } |
+-----------------+--------------------------------------------------------------+
Results - Sub Workflow 2
# st2 execution get 59aa0a60a814c007272e402d
id: 59aa0a60a814c007272e402d
action.ref: examples.nick_sub_workflow
parameters:
cmd: sleep 1
status: succeeded (5s elapsed)
result_task: task1
result:
failed: false
return_code: 0
stderr: ''
stdout: ''
succeeded: true
start_timestamp: 2017-09-02T01:33:20.796377Z
end_timestamp: 2017-09-02T01:33:25.647713Z
+--------------------------+------------------------+-------+------------+-----------------+
| id | status | task | action | start_timestamp |
+--------------------------+------------------------+-------+------------+-----------------+
| 59aa0a61a814c007272e402f | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:21 |
| | | | | UTC |
+--------------------------+------------------------+-------+------------+-----------------+
# st2 execution get --detail 59aa0a60a814c007272e402d
+-----------------+--------------------------------------------------------------+
| Property | Value |
+-----------------+--------------------------------------------------------------+
| id | 59aa0a60a814c007272e402d |
| action.ref | examples.nick_sub_workflow |
| context.user | st2admin |
| parameters | { |
| | "cmd": "sleep 1" |
| | } |
| status | succeeded (5s elapsed) |
| start_timestamp | Sat, 02 Sep 2017 01:33:20 UTC |
| end_timestamp | Sat, 02 Sep 2017 01:33:25 UTC |
| result | { |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "workflow_name": "examples.nick_sub_workflow", |
| | "created_at": "2017-09-02 01:33:21", |
| | "updated_at": "2017-09-02 01:33:22", |
| | "workflow_execution_id": "fb5d67bb-f2a6-4bc0 |
| | -a4ae-c818f905bf1f", |
| | "state": "SUCCESS", |
| | "result": { |
| | "failed": false, |
| | "stderr": "", |
| | "return_code": 0, |
| | "succeeded": true, |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "id": "474884cc-de3b-49c1-88ea-86d5667e6c2a" |
| | } |
| | ], |
| | "stdout": "", |
| | "stderr": "", |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | } |
| | } |
| liveaction | { |
| | "runner_info": { |
| | "hostname": "stackstorm.maludy.home", |
| | "pid": 1056 |
| | }, |
| | "parameters": { |
| | "cmd": "sleep 1" |
| | }, |
| | "action_is_workflow": true, |
| | "callback": { |
| | "url": |
| | "http://0.0.0.0:8989/v2/action_executions/af5ead6e-c157-47b5 |
| | -b6ce-df4e94448253", |
| | "source": "mistral_v2" |
| | }, |
| | "action": "examples.nick_sub_workflow", |
| | "id": "59aa0a60a814c007272e402c" |
| | } |
+-----------------+--------------------------------------------------------------+
Results - Sub Workflow 3
# st2 execution get 59aa0a60a814c007272e402d
id: 59aa0a60a814c007272e402d
action.ref: examples.nick_sub_workflow
parameters:
cmd: sleep 1
status: succeeded (5s elapsed)
result_task: task1
result:
failed: false
return_code: 0
stderr: ''
stdout: ''
succeeded: true
start_timestamp: 2017-09-02T01:33:20.796377Z
end_timestamp: 2017-09-02T01:33:25.647713Z
+--------------------------+------------------------+-------+------------+-----------------+
| id | status | task | action | start_timestamp |
+--------------------------+------------------------+-------+------------+-----------------+
| 59aa0a61a814c007272e402f | succeeded (1s elapsed) | task1 | core.local | Sat, 02 Sep |
| | | | | 2017 01:33:21 |
| | | | | UTC |
+--------------------------+------------------------+-------+------------+-----------------+
# st2 execution get --detail 59aa0a60a814c007272e402d
+-----------------+--------------------------------------------------------------+
| Property | Value |
+-----------------+--------------------------------------------------------------+
| id | 59aa0a60a814c007272e402d |
| action.ref | examples.nick_sub_workflow |
| context.user | st2admin |
| parameters | { |
| | "cmd": "sleep 1" |
| | } |
| status | succeeded (5s elapsed) |
| start_timestamp | Sat, 02 Sep 2017 01:33:20 UTC |
| end_timestamp | Sat, 02 Sep 2017 01:33:25 UTC |
| result | { |
| | "tasks": [ |
| | { |
| | "state_info": null, |
| | "name": "task1", |
| | "workflow_name": "examples.nick_sub_workflow", |
| | "created_at": "2017-09-02 01:33:21", |
| | "updated_at": "2017-09-02 01:33:22", |
| | "workflow_execution_id": "fb5d67bb-f2a6-4bc0 |
| | -a4ae-c818f905bf1f", |
| | "state": "SUCCESS", |
| | "result": { |
| | "failed": false, |
| | "stderr": "", |
| | "return_code": 0, |
| | "succeeded": true, |
| | "stdout": "" |
| | }, |
| | "published": { |
| | "stderr": "", |
| | "stdout": "" |
| | }, |
| | "input": null, |
| | "id": "474884cc-de3b-49c1-88ea-86d5667e6c2a" |
| | } |
| | ], |
| | "stdout": "", |
| | "stderr": "", |
| | "extra": { |
| | "state_info": null, |
| | "state": "SUCCESS" |
| | } |
| | } |
| liveaction | { |
| | "runner_info": { |
| | "hostname": "stackstorm.maludy.home", |
| | "pid": 1056 |
| | }, |
| | "parameters": { |
| | "cmd": "sleep 1" |
| | }, |
| | "action_is_workflow": true, |
| | "callback": { |
| | "url": |
| | "http://0.0.0.0:8989/v2/action_executions/af5ead6e-c157-47b5 |
| | -b6ce-df4e94448253", |
| | "source": "mistral_v2" |
| | }, |
| | "action": "examples.nick_sub_workflow", |
| | "id": "59aa0a60a814c007272e402c" |
| | } |
+-----------------+--------------------------------------------------------------+
Observations
As you can see, each "sub" workflow takes 5s to run, even though the single task only takes 1s to run.
These runs are using the following settings in /etc/st2/st2.conf
[resultstracker]
logging = /etc/st2/logging.resultstracker.conf
query_interval = 0.1
thread_pool_size = 20
[mistral]
jitter_interval = 0
Problem
I've been noticing that calling mistral workflows there is a fairly significant latency on the order of several seconds per workflow.
Scenario
In the reproduction we're going to have a "parent" workflow with 3x tasks each calling a "sub" workflow. The sub workflow is going to have a single task that runs a
core.local. The command we're going to runcore.localis thesleepcommand.Reproduction
examples/actions/nick_sub_workflow.yaml
examples/actions/workflows/nick_sub_workflow.yaml
examples/actions/nick_parent_workflow.yaml
examples/actions/workflows/nick_parent_workflow.yaml
Results - Parent
Results - Sub Workflow 1
Results - Sub Workflow 2
Results - Sub Workflow 3
Observations
As you can see, each "sub" workflow takes 5s to run, even though the single task only takes 1s to run.
These runs are using the following settings in
/etc/st2/st2.conf