AWS SWF Signal during vs Decision after Timer best practice?

836 views Asked by At

I have a set of business processes that I think are a good fit for AWS SWF.

Several of these processes include wait periods, that could be anything from a week to 3 months. A (brief and not fully explained) example might be along the lines of "If a user signs up to a particular service, if they are still subscribing after 4 months, send them some form of reward".

I'm looking at modelling this by having the sign up process start off a workflow that then set a timer for the 4 month wait period.

The problem exists with the fact that if the subscriber cancels their subscription within that 4 month period, we don't want to send the reward.

I can see two ways of doing this: Have a "cancel" signal upon cancellation (that would stop the "sleeping" workflow), or having a "check subscription" decision before the "send reward" step (ie, after the workflow "wakes up"). (Obviously I could also do both, for a "belt & braces" approach)

Are there any recommended best practices here? There is the potential for there to be several tens of thousands of these various business processes that could be active or sleeping at any one time.

1

There are 1 answers

0
Maxim Fateev On

I would go with both approaches. Cancelling workflow through a signal or the RequestCancelWorkflowExecution and checking for subscription validity (using separate activity) before calling "send reward" activity. Implementing just latter approach is simpler but you end up paying for outstanding workflows that are technically cancelled. SWF certainly can handle tens of thousands of open workflows without problem.