documentation icon indicating copy to clipboard operation
documentation copied to clipboard

Best Practices Guide for Workflow/Activity Writing

Open cretz opened this issue 3 years ago • 1 comments

Is your feature request related to a problem? Please describe.

We don't have a best practices guide for writing workflows and activities.

Describe the solution you'd like

We have docs on what you can do, but we don't have much on what you should do. We need to collect our suggestions/recommendations in one place for easy reference. Some things just off the top of my head:

  • Use activity heartbeats on anything but the shortest activity
  • Consider using schedule to close timeout instead of start to close or you can miss activities that are slow to be picked up
  • Use single-object requests and responses for workflows/activities for future proofing (like gRPC req/resp...also can use proto if need to cross language)
  • In Go, if you set a workflow/activity name when registering for disambiguation, use the string when executing it
  • Don't over-complicate workflows
  • Etc

There are many many more and what I have here may not even be what we recommend.

Consolidating from:https://temporalio.atlassian.net/browse/EDU-1745

A couple users have been uncertain how much to put in a single Activity versus breaking it into multiple Activities.

Describe the solution you'd like

It would be helpful to have a concepts page/section on that architecture decision. The pros/cons of each, and example use cases.

Additional context

https://github.com/temporalio/documentation/pull/882#issuecomment-1035875835

cretz avatar Feb 22 '22 17:02 cretz

Related: Activity length #890

lorensr avatar Feb 22 '22 18:02 lorensr