Repository navigation
|
Hi, I’m evaluating Durable Workflow V2 for a long-running trading bot and I’m trying to understand whether it supports one particular execution model. I have a long-running Strategy Workflow representing the lifecycle of a market. During its execution, there are several independent external processes/events:
The important part is that these processes are independent. For example: T+0 T+0 T+20 The RTDS result must immediately trigger an Activity and, once that Activity completes, the Strategy Workflow must continue: RTDS pre-resolution At the same time:
There may also be multiple external events/signals during the lifetime of the workflow. For example:
The workflow therefore needs to support something conceptually like: while at the same time: and: The critical requirements are:
I initially tried to model this using Signals, timers and concurrency primitives, but I’m not sure whether V2's execution model supports this combination directly. My main question is: What is the recommended Durable Workflow V2 pattern for this kind of problem? More specifically, does V2 provide a native way to have multiple concurrent long-lived event consumers/processes, each receiving external signals with payloads, while allowing the main workflow to react to one result without waiting for all other consumers? I’m not necessarily looking for a specific implementation. I’d like to understand what execution model V2 is designed to use for this scenario, and whether there are any fundamental limitations I should be aware of before building the system around it. |
Replies: 1 comment 1 reply
|
Thanks for laying out the timing and failure requirements this clearly. They expose an important boundary in the current v2 prerelease. The short answer is: not as one native workflow construct today. V2 has the underlying pieces: durable external signals, payload-bearing messages, timers, activities, child workflows, and deterministic parallel groups. The current parallel primitive is an all-members join barrier. It does not start several durable branches, return when the first selected branch resolves, and leave the remaining branches under explicit lifecycle control. Workflow code is also logically single-threaded and replayed in a deterministic order. Activities may execute concurrently on workers, and an external event that arrives while an activity is running is durably recorded rather than lost, but a sequential workflow does not run a second mutable event handler in parallel with the unresolved activity. Recommended model with the current prereleaseI would use a coordinator plus independently durable resolver workflows:
If resolver work must continue after the Strategy has advanced or completed, use independently started top-level workflows rather than relying on a detached-child behavior. Start the Strategy and resolver workflows together from the client or control process. That keeps the T+180 deadline independent of whatever the Strategy is currently waiting on. External payloads should use the portable payload value set, or an external payload reference for large/application-owned data. Give each inbound event a stable idempotency key so repeated delivery can be deduplicated by source identity. Activities remain at-least-once work, so trade execution also needs a business or activity-execution idempotency key at the exchange boundary. This topology is durable across worker replacement and replay, but it is more manual than the single-workflow model in the question. Should the native model grow?Yes, I think the missing abstraction is worth adding. It should be structured durable concurrency, not arbitrary background threads:
That is a protocol and replay feature across the runtime and SDKs, not merely a convenience helper. I would not suggest provisional syntax until those lifecycle and replay semantics are defined. For the current prerelease, the coordinator plus independent resolver-workflow topology above is the safe design boundary. |
Thanks for laying out the timing and failure requirements this clearly. They expose an important boundary in the current v2 prerelease.
The short answer is: not as one native workflow construct today.
V2 has the underlying pieces: durable external signals, payload-bearing messages, timers, activities, child workflows, and deterministic parallel groups. The current parallel primitive is an all-members join barrier. It does not start several durable branches, return when the first selected branch resolves, and leave the remaining branches under explicit lifecycle control.
Workflow code is also logically single-threaded and replayed in a deterministic order. Activities may execute concurrent…