When a Temporal entity workflow fits a long-lived business object
A Temporal entity workflow fits when one account, subscription or device has state that changes over months or years, and every change must be applied in order and checked against current state. In that model, each entity gets one long-running workflow whose workflow ID identifies the entity, and that workflow is the single place where its state is changed. The workflow holds the entity's current state in memory, receives change requests as signals or updates, and calls activities for side effects such as charging a card, provisioning a device or writing to an external system. Because a single workflow processes its inbound messages one at a time, two concurrent events for the same account are serialized without a separate database lock, which is the property most teams are actually buying.
The fit is narrower than it looks. Before committing, check whether the entity's state really needs to be owned by the workflow, or whether it is a record in your system of record that the workflow only coordinates. Ask how many events per entity you expect over its life, how long the workflow must stay open, and whether callers need an answer synchronously. Entity workflows accumulate event history, so the plan must include Continue-As-New to restart the workflow with carried-over state before history grows large. Confirm the current history limits and Continue-As-New guidance in the Temporal documentation for your SDK and server version, since those values are configuration and release dependent. If most entities are short-lived or the state is mostly relational queries, a plain database with a Temporal workflow only for the long process steps is usually the simpler design.
How events reach one entity workflow
The diagram starts at the API or event source, which sends a signal or update addressed by the entity ID to one workflow execution. A worker running the workflow and activity code receives the work, and activities call the downstream systems that hold the real side effects. When history grows, the run ends with Continue-As-New and a new run starts with the carried state. Check that the entity ID is the same on every path and that each update handler and activity is safe to repeat.
Signals and updates reach one workflow per entity, which hands side effects to activities.
Entity workflow or another Temporal pattern, by situation
This is the situation an entity workflow is built for: one account, subscription or device that changes state many times over months or years, where each change must be applied in order and the current state must be queryable at any time. One workflow ID maps to one business object, external events arrive as signals, and callers that need a checked answer use updates. Because the history of such a workflow grows with every event, plan for Continue-As-New from the start rather than adding it after the first incident.
- Stable identity: Use the business key (for example, an account number) as the workflow ID so every message for the same object reaches the same execution.
- Signals for changes: Send state changes as signals and keep the handler logic small and deterministic.
- Updates for validated replies: Where a caller needs a synchronous, validated answer, use an update instead of signal-then-poll.
- History bounds: Carry state forward with Continue-As-New on a defined event count or schedule, and test it under load.
- Ordering and duplicates: Decide how duplicate and out-of-order messages are handled, since signals are not deduplicated by default.
Check the sibling pages on Continue-As-New for long-running workflows, Signal-With-Start for create-or-update flows and request and response with Updates before committing to the design.
Many teams start with a workflow per entity when the work is really one bounded process: an order that is paid, shipped and closed within days, or a single onboarding run. For bounded work with a clear end, a standard workflow per run is usually simpler than a long-lived entity workflow. It has a finite history, straightforward retries and no need to keep a process alive between events. Choose this when the entity does not need a permanent, always-running handler for future changes.
- Finite lifetime: The workflow starts, does its steps and completes, so there is no history to bound.
- Activities for side effects: Payment, notification and record-writing calls run as activities with retry policies.
- Human steps: If the process waits on a person, the approval pattern covers signals carrying the decision and timeouts.
- Child workflows for sub-steps: Split out a reusable sub-process when it has its own history and ID needs.
- Idempotent starts: Use a deterministic workflow ID so a repeated request does not create a second run.
Confirm with your team whether any event can arrive after the process should have ended, because that answer decides whether a long-lived entity workflow is needed after all. Read the sibling pages on human approval workflows and child workflows and fan-out next.
When the same operation must run across a large set of entities, such as re-rating every subscription after a price change, the right unit is usually the batch, not one long-lived workflow per entity. A coordinating workflow reads the records in pages, starts work in bounded groups and tracks progress. Entity workflows are a poor fit because starting one per record for a full sweep creates many executions at once and mixes a one-time job with permanent lifecycle state.
- Batch coordination: Use a parent workflow that iterates through pages or sliding windows of records.
- Rate control: Limit concurrency and downstream calls so the sweep does not overload the systems it touches.
- Resumable progress: Store the cursor in the workflow so a restart continues from the last completed page.
- Separation from live state: Keep the bulk run from altering entity workflows directly, or route its changes through the same signals as live traffic.
- Volume limits: Check the history and fan-out limits for the expected record count before choosing child-workflow fan-out.
Read the batch processing page for unlimited record sets and the page on rate limiting downstream APIs before setting concurrency. Confirm the record count and the downstream capacity with the system owners before the design is fixed.
Sometimes the concern is not the lifecycle of one object but serializing access to a shared resource, such as a device that many workflows want to command or an account that several processes update. A workflow can act as a lock: callers queue requests, the lock holder performs its work and the next request proceeds only when the previous one finishes. This is different from an entity workflow that owns the full state history, because the lock's job is mutual exclusion over a short window.
- Single holder: Only one workflow holds the lock at a time, so concurrent updates cannot collide.
- Explicit release: Define how the lock is released on success, failure and timeout so it cannot stay held forever.
- Timeouts for stuck holders: Set a bound on how long a holder may keep the lock.
- Throughput cost: Serialization limits throughput per resource, so measure the expected request rate per resource first.
- Idempotent work inside the lock: Make the protected operation safe to retry.
Read the locking shared resources page before building this pattern. Confirm with the resource owners how long a lock hold can take and whether the resource can tolerate queued requests.
Design options for entity workflows and when each fits
This table compares the main design choices for one long-running Temporal workflow per business object, such as an account or device. Read each row as a decision: the option, what it costs you, and the conditions under which it is the better fit. The main takeaway is that most entity workflow problems come from choosing the wrong granularity or the wrong way to carry state, so settle those two before writing code.
| Decision | Option | Trade-off | Choose it when |
|---|---|---|---|
| Workflow granularity | One workflow per entity | Gives a single place to serialize changes to one account or device, but every entity keeps a live workflow and its history grows with each change. | Changes to one entity must be ordered and the entity has a stable identity over a long life. |
| Workflow granularity | One workflow per business process | Keeps histories short and processes easy to reason about, but concurrent processes touching the same entity can collide without extra locking. | Each process has a clear start and end, and entity state is read or written only by short steps. |
| Change delivery | Signals | Fire-and-forget messages that are cheap and ordered per workflow, but the sender gets no confirmation that the change was valid or applied. | Changes are notifications, and the caller does not need a validated answer before continuing. |
| Change delivery | Updates | The caller receives a validated, synchronous result, which suits state changes with an answer. Updates add latency and must be designed for handler code that can run while the workflow is busy. | A change must be validated and the caller needs to know whether it was accepted before proceeding. |
| State location | Carry state in workflow input and fields | Fast reads inside the workflow and no external lookup on each step, but the state lives in history and grows, and large values must stay small. | The state is small and bounded, such as status, limits or a short list of pending items. |
| State location | Fetch state from a store through activities | Keeps workflow history small and lets other systems read the same records, but every read and write becomes an activity with its own retries and failure modes. | The entity holds large or shared data that other services own, and the workflow mainly coordinates changes. |
| History bounding | Continue-As-New on history length | Keeps history under server limits without manual intervention, but the trigger must be tuned so a run is not restarted in the middle of a critical step. | The workflow runs indefinitely and each run accumulates many events from signals and updates. |
| History bounding | Continue-As-New on event count or a fixed schedule | Makes restarts predictable and easy to test, but a count can be reached at a bad moment unless pending signals and updates are drained first. | Traffic per entity is steady enough that a predictable restart point is easier to operate than a size check. |
| Fit check | Entity workflow | Suits a long-lived object whose changes must be serialized and whose state is small. Confirm the expected number of entities and the change rate with your team before committing. | The object has one owner in the workflow, changes arrive in order, and the business needs a durable record of each transition. |
| Fit check | Database row with an activity-based workflow, or a plain service | Simpler for entities that change rarely or are read far more than written. Temporal adds operational load that a database transaction would not need. | Changes are simple reads and writes, no long waits or external steps are involved, or a single transaction already keeps the data consistent. |
How to build and test an entity workflow in sequence
This sequence takes an entity workflow from a business key decision to a load-tested workflow in a non-production namespace, with a check at each stage so that state handling, history growth and replay safety are confirmed before production use.
Define the business key and workflow ID rule
The architect and the domain owner agree on the business key that identifies one entity, such as an account number or device serial, and write a rule that maps it to a workflow ID with a fixed prefix, for example
account-followed by the key. The rule covers normalization, such as case and whitespace, and states who may create an entity workflow. The step is done when the rule is written down, reviewed by the team that owns the entity records, and checked against a sample of real identifiers to confirm each one maps to exactly one ID. Ask the team to confirm whether the entity identifier can be reused after deletion, because a reused ID collides with the history of the old workflow.Model entity state and handlers
Developers define the state the workflow holds in memory, such as status, plan, and last-changed values, and decide which changes arrive as signals (fire and forget) and which arrive as updates (validated, with a reply). Each handler is kept small, validates its input, and changes only workflow state. The step ends when every state change has a named handler, every handler rejects invalid input without partial changes, and a short design note lists the handlers, their inputs, and the states they can move between. The check is a review of that note against the entity's business rules to confirm no state can be reached that the rules forbid.
Add activities for external calls
Developers move every call to a database, payment provider, device API or other system into activities, which the workflow calls and which Temporal retries. Workflow code stays free of network calls, clock reads that differ between runs, and random values, so the same history always produces the same decisions. Each activity is idempotent where it changes an external system, using a key derived from the entity ID and the operation. The step is complete when each activity has a documented timeout and retry policy and a test confirms that a repeated call does not duplicate the external change. Confirm with the owners of each external system whether they accept an idempotency key.
Implement Continue-As-New with state carried forward
Developers add a Continue-As-New path that starts a fresh run of the same workflow ID when history grows large or the number of handled messages passes a threshold chosen by the team. The new run receives the full current state as its input, and any pending signals or updates are drained before the switch so none are lost. The step is finished when a test drives the entity through more messages than the threshold and confirms that state, the workflow ID, and in-flight handler results all survive the transition. Check the Temporal documentation for the current history limits that apply to your server version before setting the threshold.
Test replay and determinism
Developers record histories from representative runs, including runs that cover signals, updates, activity failures, and Continue-As-New, and replay them against the current workflow code. A replay failure means a code change altered decisions made in earlier runs, so the change must be versioned or reverted before deployment. The step is done when all recorded histories replay cleanly in the continuous integration pipeline and every workflow code change for an existing entity type passes replay as a gate. Store the histories as test fixtures so future changes are checked against them, and ask the SDK team which replay test helpers the chosen language provides.
Run the workflow under load in a non-production namespace
The platform team creates a non-production namespace on the Temporal Service that matches the production retention and visibility settings as closely as the environment allows, then runs a load test that creates many entity workflows, sends signals and updates at the expected rate, and forces activity failures. The team watches history size, task latency, worker memory, and visibility query results during the run, and confirms that Continue-As-New fires as designed. The step is complete when the measured results are recorded against the agreed targets and any gap is assigned an owner. Ask the platform team to confirm the target load figures from the business, since no sizing is assumed here.
Confirm SDK-specific test work on the SDK pages
The test harness, mocking approach, and replay helper calls differ by language, so the detailed unit and integration test steps belong on the SDK development pages for the language your team uses. This step confirms that the team has chosen its SDK, read the matching test guidance, and mapped each check in this sequence to a test in that SDK. The output is a short test matrix listing each check, its SDK test location, and its owner, which the team reviews before promoting the entity workflow to production planning.
How Continue-As-New keeps entity history bounded
An entity workflow that lives for years keeps appending events to its history: every signal received, every update handled, every timer fired and every activity completed adds to the event log of one run. Temporal workflow histories have size and event count limits, and a long-lived account or device workflow will reach them if it never restarts its history. Continue-As-New closes the current run and starts a new run with the same workflow ID and a fresh, empty history, passing the state the entity still needs as its input. The entity keeps its identity for callers, but the history that must be replayed on worker restart stays short. Plan for this from the first build, because retrofitting it onto a workflow already in production means carrying state through a cutover you have not tested.
The cutover has to be designed around in-flight messages. Signals and updates that arrive while the run is closing can be lost or rejected if the workflow ends without handling them, so the workflow should stop accepting new work, drain the signal and update handlers it has already started, and only then call Continue-As-New. Confirm in the SDK documentation for your language how pending handler completion is awaited and how updates that arrive during the close are answered, and write a test that sends a signal and an update across the boundary. Decide which state is carried forward explicitly (balances, status, device configuration, pending timers) and which is rebuilt from an external store, since anything not in the input is gone after cutover.
For the trigger conditions, the state carried forward and the storage effects, see the sibling page on Temporal Continue-As-New for long-running workflows. Here, the point to carry into design is ownership: someone on your team must decide the threshold for restarting history, own the carried-state schema, and verify in staging that a run cut over under load still produces the same entity state as one that never restarted.
Security and operational controls for entity workflows
Entity workflows keep business state alive for months or years and accept commands from many services, so every signal and update is a write to a record someone may rely on. The cards below cover the controls that decide who can change that state, what the state contains at rest, and where the Temporal services can be reached from.
Replace the default noopAuthorizer
Self-hosted Temporal uses the noopAuthorizer by default, which allows every API request with no authentication or access control. Any client that can reach the frontend could start an entity workflow, send it a signal or call an update. Configure an Authorizer plugin before any production namespace receives entity traffic, and confirm the setting in the authorization section of the self-hosted security docs.
Self-hosted security docsMap roles to namespace permissions
A ClaimMapper turns JWT or certificate claims into namespace roles, so the authorizer can separate services that may send a signal to an account workflow from services that may only read it. Decide which service identities may signal, which may run updates that change state, and which may only query. Write that matrix down per entity type and test each denial, not only the allowed path.
Security configurationRestrict signals and updates by design
Authorization decides who may call an operation, but the workflow code decides what the call may change. Validate update inputs in the validator before the handler mutates state, reject signals for entities in terminal states, and keep state transitions in one place. Review each signal and update name as part of the entity's public contract, since every caller depends on it.
Encrypt personal and financial payloads
Workflow inputs, signal arguments and state held across Continue-As-New are stored as payloads in Temporal persistence. For personal or financial fields, plan a custom payload codec with encryption keys held outside the Temporal database, and run a codec server so the Web UI and CLI can still decode events for authorized operators. Confirm the key rotation process before the first entity is created.
Payload encryption docsKeep services off the public internet
The Temporal deployment docs say services should run on hosts not reachable from the public internet, with network access limited to trusted internal networks. Frontend, internode and database traffic should stay inside private networks, and the Web UI should sit behind SSO and internal access paths only. Verify the exposure with an external scan after each network change, since a single exposed frontend port bypasses the authorization work above.
Enable mTLS between services
Self-hosted Temporal supports mTLS with separate settings for internode and frontend traffic. Entity workflows carry the most sensitive state, so encrypt both paths: workers and clients authenticate to the frontend, and services authenticate to each other. Record the certificate issuer, rotation interval and renewal owner, because an expired certificate stops signals and updates for every entity at once.
mTLS settingsQuestions teams ask before building entity workflows
What drives the cost of building an entity workflow on Temporal?
The cost depends mainly on how many entity types you model, how many state changes each one accepts, and how many external systems the workflow must call. Each entity type needs its own workflow definition, signal and update handlers, activities for side effects, and tests that replay recorded histories. Costs that recur include running the Temporal Service, workers, persistence and visibility storage, and upgrades. If you use Temporal Cloud, pricing is metered by actions and storage, and the Temporal pricing page lists the current rates. Ask any partner for a quote that separates design, build, testing, infrastructure and ongoing support, and that states which items are one-time and which recur.
How long does a first entity workflow take to deliver?
Duration depends on the number of entity types, the state machine complexity, the integrations involved and how much of the platform is already running. A first entity workflow usually takes longer than the workflow code itself because the team must settle identifiers, replay-safe versioning, retention and the Continue-As-New policy before production use. If the Temporal Service is not yet deployed, add time for infrastructure, persistence and access controls. DeployOpen agrees timelines in a written scope before work starts, so ask for milestones tied to specific deliverables rather than a single end date.
What skills and infrastructure must our team provide?
Your team needs engineers who can write workflow code in one Temporal SDK, understand determinism rules, and operate workers in your environment. You also need a place to run the Temporal Service, such as Kubernetes or Docker-based hosts, and a supported persistence database. The Temporal deployment docs say services should run on hosts that are not reachable from the public internet. Plan for an identity provider, secrets handling, monitoring and a named owner for upgrades. Confirm these requirements with the vendor documentation for the SDK and server versions you intend to run.
Can our in-house team build and run entity workflows without a partner?
Yes, many teams do, provided they have engineers with Temporal experience or time to learn it on a real project. The harder parts are rarely the first handler. They are workflow versioning, replay testing, history growth under Continue-As-New, and operating the service after go-live. Assess your team against those skills and against the number of entity types you need. A partner can cover design review, the first build, or retesting, while your team keeps ownership of the code and the runbooks.
Does a self-hosted Temporal Service need access control before go-live?
Yes. If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Before production, configure mTLS for internode and frontend traffic, a ClaimMapper for roles, and an Authorizer. The self-hosted security documentation describes these settings. Entity workflows often hold customer account or device data, so also decide how payloads are encrypted and who can read workflow histories through the Web UI and API.
When is an entity workflow the wrong tool?
An entity workflow fits an object with a lifecycle that must survive restarts and accept changes over time. It is a poor fit when the object needs to be queried in bulk by many attributes, since visibility search is limited to what your visibility store supports and Elasticsearch or OpenSearch is recommended beyond a few workflow executions. It is also a poor fit for simple create-and-read records that a database handles well, for entities that are rarely changed, or for designs that would keep one workflow open for every object ever created with no retention plan. Illustrative example: a device registry with millions of rarely changed records is usually better served by a database with workflows only for devices in active provisioning.
What should we ask for in a quote for entity workflow work?
Ask for a written scope listing each entity type, its states, its signals and updates, the external systems it calls, and the environments covered. Request separate line items for design, build, tests, deployment, knowledge transfer and any retainer for upgrades. Ask how Continue-As-New and workflow versioning will be verified, which evidence you will receive, and what happens when requirements change mid-build. Confirm whether the quote includes infrastructure, Temporal Cloud or self-hosted operation, and who pays for licenses or vendor support.
How DeployOpen scopes and delivers Temporal entity workflows
DeployOpen plans, builds, documents and supports entity workflows for accounts, subscriptions or devices inside infrastructure you control. Each engagement starts with a written scope that fixes which business objects get a workflow, which signals and updates change their state, and how history is bounded.
How we scope
- Inventory the business objects and decide which ones truly need one long-running workflow each
- Define the signals and updates that change each entity, with the validation and expected responses
- Agree in writing how Continue-As-New, retention and workflow ID conventions will be handled, with fixed-scope deliverables
How we build
- Implement entity workflows with deterministic code, versioning rules and replay tests before any production traffic
- Deploy self-hosted Temporal Server and workers in your infrastructure, with persistence and visibility stores chosen from documented options
- Test state changes, history growth and worker restarts against the agreed scope, then fix and retest findings
How we hand over
- Deliver design records, runbooks for signals, updates and Continue-As-New, and namespace and authorization configuration
- Walk your engineers through the workflow code, replay testing and the upgrade steps for Temporal Server
- Document the decisions where an entity workflow was ruled out, so future teams know when to choose another pattern
How we support
- Offer ongoing support, upgrades and continuous testing as a retainer after handover
- Plan Temporal Server upgrades one minor version at a time, with schema changes applied before server changes
- Review new workflow versions and history growth on a schedule agreed in your support terms

