One workflow on all entity lifecycle

Hello everyone, I’m still a newcomer to temporal, and I would like to ask you a few architectural questions. Let’s assume I have a microservice that has an initiating endpoint. This endpoint starts the lifecycle of an entity, which ends after being triggered by some other endpoint. Throughout the lifecycle of this entity, there are updates that can come from other endpoints or from message sources like Kafka. How reasonable is it to encapsulate the entire lifecycle of the entity in a single workflow? Or would it be better to separate each incoming event from different endpoints into their own workflows and manage them individually? Are there any references for implementing the first type of architecture, if it’s even possible and sensible? Right now, I can’t see how to do this without creating an Workflow.await-hell with a lot of variables in the workflow.

It depends on the number of updates per second to that entity. What is the peak rate expected per second?

about 3-4 rps

about 3-4 rps

Then an entity workflow is a great fit for your use case.

Are there any references for implementing the first type of architecture, if it’s even possible and sensible? Right now, I can’t see how to do this without creating an Workflow.await-hell with a lot of variables in the workflow.

Temporal workflows are code. You can use standard programming techniques to model your use case. If the lifecycle of an entity is linear, then Workflow.await makes it very explicit. If not, you might need another technique, such as state machines.