Batch processing with Temporal

Batch processing with Temporal runs large record sets as durable workflows with retries and visible progress. This page covers which pattern fits your volume, how to set it up, and what to confirm before you commit.

On this page

How batch processing with Temporal handles large record sets

If your team must process millions of records and every record has to finish exactly once or be accounted for, Temporal is worth evaluating, but the right design depends on two numbers you should pin down first: how many records you have, and how fast the downstream systems can accept work. In Temporal, a batch job is a workflow whose state lives in the Temporal Service rather than in a worker's memory. That gives you durable progress, retries with configurable Retry Policies, a visible execution history for each run, and resumption on another worker after a crash, so a batch does not restart from zero when a pod is evicted. Those properties matter most when a batch spans hours or days, touches several systems, or must explain exactly what happened to each record.

Cron jobs and queue consumers remain simpler when a run is short, the work is idempotent, and nobody needs to see or pause progress midway. Temporal earns its place when you need a single place to answer whether record 4,218,003 was processed, when you need to pause and resume a run without losing position, or when a failed step should retry on its own schedule while other records continue. The cost is operational: you run a Temporal Service, workers, a persistence store and, for search, a visibility store, and your developers must write workflow code that stays deterministic across changes.

Pattern choice follows from scale and rate limits. A basic fan-out that starts one activity per record suits small sets. Child-workflow fan-out splits work into separate histories, and the Temporal GitHub repository is the place to confirm current release behavior before you rely on any limit. For unlimited sets with rate control, batch iterators and sliding windows keep each execution bounded and throttle calls to downstream APIs. Before choosing, confirm with your own environment the record count per run, the throughput each downstream system tolerates, the acceptable completion window, and whether operators need to pause or reprioritize a run while it is in flight.

Choosing a batch processing pattern in Temporal

This table compares basic fan-out, child-workflow fan-out, batch iterators and sliding windows across what each suits, how it handles history growth, how progress is tracked and its main trade-off. Read each row against your record count, your downstream rate limits and how much you need to resume mid-run. For sets that may grow without a fixed bound, the takeaway is that the child-workflow approach has a practical ceiling that you should confirm for your workload before relying on it.

PatternBest suited toHistory growthProgress trackingMain trade-off
Basic fan-outSmall, bounded sets where each record is one activity and the list fits comfortably in workflow inputGrows with every scheduled activity and its results in one workflow historyActivity results collected in workflow code, visible in the Web UI per executionSimplest to write, but the whole set lives in one history and can hit size limits
Child-workflow fan-outLarge sets split into chunks, each chunk handled by its own child workflow with a separate historyParent history grows with child start and completion events, child histories stay separateParent tracks chunk status, each child is visible by its own workflow IDWorkable up to around 500,000 records (to be confirmed for your workload), and parent history still needs watching
Batch iteratorUnbounded or very large sets read page by page from a source such as a database cursor or APIBounded with Continue-As-New carrying the cursor forwardStored cursor or checkpoint in workflow state, so a restart resumes at the last pageNeeds a stable, resumable cursor from the source, and care that each page is processed exactly once
Sliding windowUnlimited sets where you must cap concurrency and respect downstream rate limitsBounded by keeping a fixed number of in-flight items and rolling history with Continue-As-NewWindow position and in-flight count recorded in workflow stateMost control over throughput, but the most code to design, test and tune
Rate controlWork that calls a shared external API with quotas or fair-use limitsDepends on the base pattern chosen, since rate control is layered on topCounts of completed and throttled items shown through metrics you defineThroughput is set by the slowest downstream limit, so the run takes longer by design

How fan-out, child workflows and sliding windows fit together

The diagram starts with a parent batch workflow that reads one page of record identifiers at a time. Each page becomes a child workflow or activity batch, and a sliding window caps how many run at once, so the parent never holds the whole record set in its history. Workers pull tasks from task queues, retries run inside the activity Retry Policy, and rate limits sit on the queue and the target API. Check the window size, the retry boundary and where the results land before you go live.

Parent workflow pages through records, starts work under a window, and writes results to the target.

Setting up batch processing with Temporal step by step

This sequence takes a team from an undefined record set to a Temporal batch workflow that resumes safely after failures, has been rehearsed on a copy of the data, and runs under rate control. Each step ends with a check that the next step depends on.

  1. Define the record boundary and idempotency key

    Decide what one unit of work is (one record, one account, one file chunk) and which field uniquely identifies it across retries and reruns. Document the boundary, the source query that enumerates records, and what counts as already processed. Your data owner and an engineer should sign off on this in writing. Done when every record in a sample export maps to exactly one key and a rerun of the same sample would produce the same key set.

  2. Choose the batch pattern from the options table

    Match the expected record count and the required throughput control to one pattern: basic fan-out for small sets, child-workflow fan-out for sets up to the documented limit of around 500,000 records, or batch iterators and sliding windows for unlimited sets that need rate control. Record the choice and the reason in the design document. Done when the team can state why the other patterns were rejected for this volume.

  3. Size batches and set workflow boundaries

    Set the number of records per activity call and the number of activities per workflow run so that payloads stay small and each history stays within limits. Keep large data in the source system and pass only identifiers or cursors between steps. Confirm the size limits for your SDK and server version in the Temporal documentation before fixing numbers. Done when a dry run on the sample shows the planned batch count and the largest payload size is known.

  4. Implement activities with retry policies

    Write the activities that read, transform and write each batch. Make every write idempotent by checking or upserting on the idempotency key, and set a retry policy that marks business errors such as validation failures as non-retryable. Choose activity timeouts and heartbeats for long batches. Done when unit tests show that running the same activity twice with the same batch leaves the target in the same state.

  5. Confirm the workflow is replay-safe

    Review the workflow code for non-deterministic calls such as system time, random values, direct network calls or environment reads, and move them into activities or deterministic APIs. Run the replay test in your SDK against recorded histories. Done when replay passes on the current code and the team has a recorded history from each workflow version to replay against later.

  6. Deploy workers on a dedicated task queue

    Run the batch workers on their own task queue so that batch load does not starve interactive workflows sharing the same namespace. Deploy them in your own infrastructure with the same configuration in each environment. Done when a test run shows batch tasks arriving only on the dedicated queue, and a worker stopped mid-batch is picked up by another worker or restart without manual steps.

  7. Run a staged test on a copy of the data

    Restore a copy of the source data into a non-production environment and run the workflow in stages: a small slice, then a larger slice, then a full run. Kill a worker during the run and confirm it resumes without duplicate writes by comparing record counts and key sets against the source. Done when the comparison shows zero duplicates and zero missing keys for every stage.

  8. Enable rate control before production

    Turn on the rate limits, concurrency caps and backoff that protect downstream APIs and databases, and rerun a stage to confirm the observed rate stays under the agreed threshold. Set alerts on failure counts and workflow backlog. Done when the staged run passes with rate control on, the runbook for pausing and resuming the batch has been rehearsed, and the team has a signed go decision.

Why workflow history size decides the batch design

Every fan-out step adds events to the workflow history. Scheduling each record as an activity writes a command event and a result event, so a batch of many records grows one workflow's history in direct proportion to its size. History size is the constraint that decides how a batch must be shaped, because a single workflow execution cannot grow without limit. Before choosing a design, confirm the history event and size limits that apply to the Temporal Server version you run and to your namespace settings, since these limits have changed across releases and are set by the operator. The Temporal documentation on workflow limits is the place to check the current figures.

There are two common ways to keep history bounded. The first splits the set into child workflows, each handling a slice of records with its own history, so the parent only tracks slice-level results. The second is a loop that processes one page of records per run, carries a cursor forward in its input, and restarts with a fresh history using Continue-As-New. The child workflow approach is simpler to read and to monitor per slice, but the parent still accumulates an event for every child it starts, so it caps how many slices one parent can manage. The cursor loop scales to very large or unbounded sets and keeps history small, but it requires a cursor that is stable across restarts and code that handles the carried state correctly.

The trade-off is simplicity against scale. A plain fan-out is quick to build and easy to debug for sets that stay well inside the documented limits, and the team should be able to state the record count at which it would need to change. Ask the team to measure the events each record adds in a test run, estimate the peak batch size for the next two years, and compare that with the limits for the chosen version. Plan the cursor loop from the start if the set is open-ended, because converting a fan-out into a loop after launch means changing a workflow that already has running executions.

Rate control and retries that protect downstream systems

A batch that fans out across millions of records can overwhelm the databases, APIs and queues it touches faster than any single error would. The controls below work together: some limit how much work runs at once, some slow retries down, and some stop hopeless records from retrying forever. Each one trades some throughput for safety, so set them against the capacity of the slowest system in the chain.

Concurrency caps in the parent

The parent workflow decides how many child workflows or activities run at the same time, for example by starting work in fixed-size waves or by using a semaphore-style loop. This is the simplest way to bound load on a downstream database or API, and it protects that system even when workers have spare capacity. The cost is throughput: a cap set below what the downstream system could handle leaves time unused. Check the cap against measured downstream latency and error rates, and revisit it when either changes.

Temporal deployment docs

Worker and task queue rate limits

Task queue rate limits cap how many tasks per second a queue dispatches, which limits activity starts regardless of how many workers are connected. Worker-level limits cap what one process accepts, which matters when a fleet is scaled up during a backlog. Both protect a shared dependency from bursts when a large batch is released. The cost is that the batch drains only as fast as the limit allows, so a slow limit can push completion past a business deadline. Confirm the limit settings available in your SDK and server version before designing around them.

Backoff from retry policies

A retry policy sets the initial interval, backoff coefficient, maximum interval and maximum attempts for failed activities. Exponential backoff gives a struggling API room to recover instead of receiving the same request from thousands of records at once. The trade-off is latency: long intervals stretch the tail of the batch, and an unlimited attempt count can keep a stalled record open for days. Set the maximum interval and attempts from the downstream system's documented recovery behavior, not from defaults alone.

Non-retryable business errors

Some failures will never succeed on retry, such as a record that fails validation, a missing account or a rejected payment. Marking these error types as non-retryable stops the activity from burning attempts and backoff time on them, and lets the batch record the failure and continue. The risk is classifying a transient error as permanent, which silently drops records that should have succeeded. Review the error classification with the owners of each downstream system and log every non-retryable failure with its record ID for later reprocessing.

Heartbeats for long activities

An activity that processes a large file or waits on a slow export can run for minutes or hours. Heartbeats report progress to the server while it runs, so a stuck or crashed worker is detected by a heartbeat timeout instead of the full activity timeout. Recording the last processed position in each heartbeat also lets a retried activity resume rather than restart. Heartbeats add traffic to the server and require the activity to check for cancellation, so send them at a sensible interval rather than on every record.

Priority and fairness across batches

When several batches share the same workers and downstream systems, one large job can starve the others. Priority and fairness settings let urgent batches run ahead of bulk backfills, and fairness spreads capacity across tenants or job types. Use separate task queues for workloads with different downstream dependencies so one job's failures do not stall another. The cost is operational complexity: more queues means more workers to size and monitor. Confirm which priority and fairness features your Temporal version and SDK support before committing to a queue layout.

What changes between self-hosted Temporal and Temporal Cloud for batch runs

On self-hosted Temporal, a batch run depends on the persistence store that holds workflow history and the visibility store that answers list and count queries. Both are infrastructure you size, back up and upgrade. Persistence is documented for Cassandra, PostgreSQL and MySQL, with SQLite meant only for development and testing. Visibility runs on Elasticsearch or OpenSearch in current guidance, which the documentation recommends for anything beyond a few workflow executions. A batch of hundreds of thousands of children will put heavy load on both stores at the same time.

  • Persistence choice: Confirm which supported database version your team will run, since the supported ranges differ by engine.
  • Visibility choice: Plan Elasticsearch or OpenSearch capacity for the number of executions the batch creates, not the average day.
  • Helm and server matching: Chart versions below 0.73.1 do not work with server images 1.30 and later, so pin both together.
  • Upgrade order: Move one minor version at a time and run schema upgrades before server upgrades when release notes call for them.
  • Operator ownership: Your platform team carries database backups, scaling, patching and on-call for every store.

Before committing, confirm the store versions, capacity plan and upgrade calendar with your platform team and with the Temporal release notes for the server version you intend to run.

Securing batch runs and the records they touch

How are batch inputs authorized in self-hosted Temporal?

By default, they are not. If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Before a batch job accepts record lists, configure an Authorizer plugin and a ClaimMapper so that only identities holding the right namespace role can start batch workflows, send signals that change batch scope, or query progress. Confirm the exact configuration keys against the security documentation for your server version, and test with an identity that lacks permission to confirm that the request is refused. Treat the batch namespace as its own trust boundary, since anyone who can start a batch can submit records to it. The self-hosted security documentation describes the available options.

How do we encrypt records inside Temporal payloads?

Temporal payloads, including the workflow inputs and activity results that carry record data, are stored in workflow history unless you transform them. Payload encryption is done with a custom data converter codec that encrypts each payload before it leaves the worker, and a codec server that lets the Web UI and CLI decrypt payloads for authorized users. Keep the encryption keys in a key management system your security team already controls, rotate them with a plan for decrypting older history, and limit who can reach the codec server. Decide which fields need encryption before the first run, because changing the codec later affects how existing histories are read. Ask your engineers to test a full batch run with the codec enabled, then confirm that the raw history contains only ciphertext.

Do mTLS and the ClaimMapper apply to batch workers?

Yes. Batch workers connect to the Temporal frontend as clients, so they need a client certificate or a token that the server can map to a namespace role. Self-hosted Temporal supports mTLS with separate settings for internode traffic and frontend traffic, and a ClaimMapper maps JWT or certificate claims to namespace roles. Give each worker deployment its own identity with the minimum role needed to poll its task queue and complete activities, and avoid sharing one credential across batch and interactive services. Certificate rotation for workers is part of the operating plan, and workers that fail to rotate will stop polling. Confirm the exact settings for your deployment, since the mapping rules depend on how your identity provider issues claims.

Where should Temporal services sit on the network?

Temporal services should run on hosts that are not reachable from the public internet, with network access restricted to trusted internal networks. In practice this means the frontend, history, matching and worker-facing endpoints, along with the persistence and visibility stores, sit in private subnets. Batch workers can run in the same network zone as the records they process, so record traffic does not cross an untrusted segment. Restrict database access to the Temporal services only, and place the Web UI and codec server behind your normal access controls with SSO. Ask your network team to review the rules for each port the server uses, and confirm the setup with a scan from outside the trusted network.

How do batch activity logs avoid storing personal data in workflow history?

Keep record contents out of workflow history entirely. Workflow history stores every input, result and failure message, so pass record references such as keys, row IDs or object paths instead of the personal data itself, and have activities fetch and process the record inside the worker. Log summaries like counts, status codes and anonymized identifiers, and write any detailed error text to your own logging system under its retention rules. Make failure messages generic, because exception text can contain fields from the record. Ask your engineers to show a sample history from a test batch and check it for names, account numbers and other personal data before production use. Confirm the retention period for history in your namespace, since personal data that does enter history stays until that period ends.

Can our own team secure a batch deployment, or do we need a partner?

Your team can do this if it has engineers who know Temporal's security settings and a security reviewer who can test them. The work includes an authorization design, a codec and key plan, worker identity and certificate rotation, network placement and a review of history contents. Most organizations find the testing and evidence gathering takes the most effort. DeployOpen can plan and implement these controls in infrastructure you control, and can test the setup and prepare evidence for your compliance reviewers. Scope and timing are agreed in writing before work starts, and the quote follows from that scope. Ask any partner to show how they will verify each control with a test, not only configure it.

Limits to confirm before you commit to a batch volume

A batch design is only as sound as the limits under it. The cards below cover the server, storage, and vendor constraints that decide whether a fan-out or iterator design holds at your record count. Confirm each one against your own version and environment before you commit to a volume or a delivery date.

History and event limits for your version

Every child workflow and activity result adds events to a workflow history, and history size bounds how many records one parent can fan out. Look up the history and event limits documented for the exact Temporal Server version you run, not the version in a blog post. Confirm whether your SDK applies its own payload or count thresholds before the server does, because those thresholds set the practical ceiling for a batch design.

Self-hosted deployment docs

Visibility store for batch progress queries

Dashboards that count completed records or find failed batches depend on advanced visibility, which is separate from workflow execution storage. Elasticsearch or OpenSearch is recommended for anything beyond a few workflow executions, so a batch of hundreds of thousands of children needs that store sized and tested. Confirm the visibility backend and its version support for your server release before you design progress reporting around it.

Visibility docs

Supported persistence versions

The persistence store holds the event histories your batch produces, so its version support is a hard constraint. Temporal documents testing on specific Cassandra, PostgreSQL and MySQL versions, and SQLite is for development only. Check that your chosen database version appears in the current list, and plan the store's capacity for the history volume of a full-size run rather than a sample.

Persistence docs

Server upgrade order

A long batch that spans a server upgrade needs a known upgrade path. Temporal guarantees backward compatibility only between two successive minor versions, so you may need to step through intermediate minors and run schema upgrades first when release notes require it. Confirm the path from your current version to the target before scheduling a large run near a maintenance window.

Upgrade guide

Temporal Cloud action limits and pricing

On Temporal Cloud, every workflow step and activity counts as an action, so a million-record batch consumes actions in proportion to its design. Pay-as-you-go pricing is published per million actions, but your total depends on retries, child workflows, timers and storage retention. Ask the vendor for the account action limits and throughput limits that apply to your namespace, and model the action count for your design before you approve the budget.

Temporal Cloud pricing

Child-workflow record count in your tests

The volume a child-workflow fan-out can handle is a property of your workflow code, payload sizes and server, so it must be measured rather than assumed. Run a load test at increasing record counts with production-like payloads and record the history size, memory use and completion time at each step. Use the measured ceiling as your design limit, and keep a safety margin for growth in the record set.

What batch processing on Temporal costs and needs from your team

What drives the cost of batch processing on Temporal?

The cost has three parts: infrastructure for self-hosted Temporal, actions and storage if you use Temporal Cloud, and engineering effort for design, testing and handover. On a self-hosted deployment you pay for the servers, the persistence database and the visibility store, plus the worker capacity that runs your activities. On Temporal Cloud, pay-as-you-go pricing starts at 50 US dollars per million actions, with active storage at 0.042 dollars per GB-hour and retained storage at 0.00105 dollars per GB-hour, according to the Temporal pricing page. A fan-out over millions of records generates many actions, so the number of records, activities per record and retry volume are the main levers. Engineering effort usually costs more than the platform itself. Ask any partner for a quote that separates these three components.

Is the cost of batch processing on Temporal one-time or recurring?

Design, build and testing are one-time costs, while infrastructure, Temporal Cloud usage and support are recurring. The build covers the batch pattern, worker code, retry and failure handling, and load testing against your record volumes. After go-live, costs recur for compute and database capacity, storage of workflow history and visibility data, upgrades of Temporal Server, and any support plan. Cloud support add-ons are priced per month: Business starts at 500 US dollars per month, according to the Temporal pricing page. Ask for the recurring items to be listed separately in any quote so you can budget for them after the first release.

How long does a fixed-scope batch processing build take?

Duration depends mainly on the pattern you choose and the number of systems the batch touches. A basic fan-out over a bounded record set is the shortest path. Child-workflow fan-out for sets up to around 500,000 records adds history and ID design, and a sliding-window iterator for unlimited sets adds rate control and checkpointing. Each downstream API you call, and each record source you read from, adds integration and test work. No researched duration applies to every case, so ask for a timeline in the written scope, tied to named deliverables such as the workflow design, the worker build, the load test and the runbook.

What must our team provide before a batch processing build starts?

Plan to provide read access to the record source, a non-production environment that mirrors its schema and volume, and a named owner for each downstream API the batch calls. Record access settles how records are selected and checkpointed. A test environment is needed to measure throughput and failure behavior before production runs. Downstream owners set the rate limits, maintenance windows and acceptable error rates, which shape the sliding-window design. You will also need a decision on where Temporal runs, whether self-hosted in your infrastructure or on Temporal Cloud, and who approves access to production data.

Can our internal team build batch processing on Temporal without outside help?

Yes, if your team already runs services and has engineers comfortable with the Temporal SDK, retry policies and testing of workflow code. The hardest parts are usually not the first fan-out but the operational work: sizing workers, controlling concurrency against downstream systems, handling non-deterministic changes during deployments and upgrading Temporal Server one minor version at a time. Temporal documents that backward compatibility is guaranteed only between successive minor versions. If none of your engineers has run a Temporal service in production, a fixed-scope partner engagement can cover design, load testing and a handover, leaving your team to operate the result.

What goes wrong most often in large batch runs on Temporal?

The most common failures come from unbounded history, overloaded downstream systems and unsafe retries. A single workflow that loops over millions of records grows its history until it hits limits, so the design must split work into child workflows or use Continue-As-New. Unthrottled workers can overwhelm an API that was never sized for the burst. Activities that are not idempotent can write duplicate records when retried. Verify each of these in a load test before the first production run, and confirm that your persistence and visibility stores are sized for the number of executions you expect.

Does running batch processing on self-hosted Temporal need security work?

Yes. The Temporal self-hosted security documentation says that if no Authorizer is configured, the default noopAuthorizer allows every API request with no authentication or access control. A production deployment therefore needs mTLS, an Authorizer, a ClaimMapper and network restrictions, and the Temporal deployment documentation advises running services on hosts not reachable from the public internet. Batch jobs often read sensitive records, so also plan payload encryption through a custom codec and a codec server. Confirm these controls with your security team before the first production batch.

How DeployOpen scopes and delivers batch processing on Temporal

DeployOpen approaches batch processing on Temporal as a written, fixed-scope engagement covering the workflow design, worker deployment and the Temporal service it runs on. The work is delivered inside infrastructure you control, with testing, documentation and handover agreed before the build starts.

How we scope

  • Confirm the record source, record count, and whether the set is bounded or continuous before design begins.
  • Agree the fan-out limit, batch size, rate targets and failure handling in the written scope.
  • Define which downstream systems are called per record and what rate limits they impose.

How we build

  • Build the chosen pattern (basic fan-out, child-workflow fan-out, batch iterator or sliding window) with idempotent activities and tested retry policies.
  • Deploy self-hosted Temporal and workers in your infrastructure, with persistence and visibility stores you approve.
  • Test replay, restart and partial-failure behavior against representative record sets before production use.

How we hand over

  • Deliver workflow code, worker configuration and deployment artifacts in your source control.
  • Document operating runbooks for starting, pausing, resetting and monitoring batch runs.
  • Walk your platform and data teams through the design, limits and known trade-offs before handover.

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 batch workflows included in regression testing.
  • Review batch volumes and rate settings with your team as record sets and downstream limits change.

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.