How to manage growing code versions with long running workflows and Worker Versioning

Hi all, I am looking for suggestions on how to best manage versions and worker count in our use case.
In summary, we are using temporal for long running workflows, think about human in the loop situations where the workflow can be blocked by client approval for weeks, if not months. At the same time the code base keeps rolling forward, and we find ourselves in a situation where we can’t really terminate workers with old code easily, but we have to keep spinning up new workers for new use cases/breaking changes etc.
Is there anyways to save some compute resources in that situation? How else would you recommend designing the system?

Use a single-version worker pool and use patching (GetVersion in some SDKs) instead.

In that case, we still have to wait for the running workflow to finish, before we can update the worker right?

No, you can update them at any time as the versioning becomes part of the workflow code itself.

Which SDK do you use?

I’m using java

Can I understand it as: the state of the running workflow is persisted, and after worker code patch, it resumes execution on the same worker?

Another follow up question - say I need to make a breaking change in some activity class, it would have to be a “v2” of the same activity, and the change can not be on the same class right? Otherwise it would yield nondeterministic result

See Versioning - Java SDK | Temporal Platform Documentation

Another follow up question - say I need to make a breaking change in some activity class, it would have to be a “v2” of the same activity, and the change can not be on the same class right? Otherwise it would yield nondeterministic result

If the activity API didn’t change, then you can change them at any time, as they are stateless from the workflow point of view. I’m not sure what “breaking change” means in the context of an activity.

yeah I mean when input/output format of an activity changes, I assume that’s what you mean by “Activity API”

Then, I would recommend changing the activity name.

Thank you, this is super helpful!