Polling in workflow vs. Activity?

Polling from workflow is generally a bad idea. By polling, I mean calling some activity in a loop. The problem with this approach is that it adds new events to the history without doing any useful work. And in extreme cases when polling needs to take a long time can exceed the history size limit. So we recommend polling from an activity.

Waiting for a signal is a completely different story. Waiting for a signal doesn’t affect history size and doesn’t introduce any additional latency. So it is a pretty good pattern assuming that the signal can be sent by an external system.

I’m not sure why you called waiting for a signal “polling”. Did you mean Workflow.await statement? It actually doesn’t increase workflow history, but you are not expected to ever put any code that mutates workflow state in any way inside the condition callback. I’ve seen examples of putting activity invocations there, but it is not supported.

5 Likes