Choosing the Temporal history shard count

numHistoryShards is set once for a new self-hosted Temporal cluster and cannot be changed later, so it needs a deliberate choice before the first deployment. This page explains what a shard does, what to weigh, and what to confirm.

On this page

Why the Temporal history shard count is a day-one decision

Choose the numHistoryShards value deliberately before the first workflow runs on a new self-hosted Temporal cluster, because the count is fixed once the cluster starts. Treat it as a design decision that belongs in your capacity plan, not as a setting you adjust later. A history shard is a partition of workflow execution state. Each shard holds the mutable state and event history for a set of workflows, and the History service instances divide ownership of those shards among themselves. More shards let that work spread across more History instances, but they also set the size of the partitioning scheme that every running workflow depends on. This decision applies when you stand up a new cluster or rebuild one. It does not apply to routine tuning of a cluster that is already serving traffic.

The persistence store feels the count directly. Each shard has records of its own in the database, so the number affects how state is laid out, how many ownership leases the History services contend for during startup and failover, and how concurrent writes spread across your database. Confirm the production-tested ranges for your chosen engine and version in the Temporal persistence documentation before you commit, since Cassandra, PostgreSQL and MySQL are tested against different version sets. Also confirm how your database team will provision and monitor the tables that the count creates. A count that suits the workload but strains the database is still a poor choice.

Write down the inputs before you set the value. Record the expected number of concurrent workflow executions, the peak rate of workflow and activity starts, the number of History instances you plan to run, and your growth horizon. Ask whether a second cluster is a realistic future option, because migrating workflows between clusters is the usual route when the count proves too small. Review the choice with the team that will run the self-hosted deployment, and record the agreed value and its reasoning in your configuration repository so that no one later changes it on a running cluster without a migration plan.

Every workflow ID maps to one history shard on a History host

The diagram starts at a client request reaching the Frontend service, which routes the request by workflow ID to one of the cluster's history shards. The shards are assigned across the History service hosts, and each shard keeps its state in the persistence database. Read it to see why the shard count is a cluster-wide decision: it sets how many units of work can be spread across hosts, and every host and shard depends on the same database. Check that your persistence sizing covers all shards before you start the cluster.

Requests route by workflow ID to shards, which History hosts own and persist.

Shard count options and when each fits

This table compares three broad shard count options for a new self-hosted cluster, with the fit, trade-off and check for each. Use it to set a sizing direction, since the right value depends on expected load, growth and database capacity. The main takeaway is that the count is fixed once the cluster starts, so confirm it against the Temporal documentation and a representative load test before go-live.

OptionFitTrade-offWhat to confirm
Development or evaluationLearning, demos and tests on a disposable clusterLow resource use, but a count chosen for testing may be too small for productionWhether the cluster will be discarded before any production data exists
Small footprint productionModest, predictable load on a small databaseLower database and history overhead, with little room to grow before a new cluster is neededPeak workflow start rate and history size, measured in load tests
Mid-range count for expected growthWorkloads expected to grow over the life of the clusterMore headroom, with a moderate increase in shard overhead on the databaseGrowth forecast agreed with business owners for the planned life of the cluster
Large count for high-throughput clustersSustained high throughput across many namespacesGreatest headroom, but higher database load and more history capacity to runDatabase sizing, IOPS and connection limits for the chosen persistence store
Final check before go-liveThe last step before the cluster takes production trafficThe count cannot be changed later without building a new clusterCurrent guidance in the Temporal self-hosted documentation and a test at expected peak load

How the shard count affects your persistence database

The shard count shapes what your persistence store carries from the first day: one record per shard, the write load each shard absorbs, the connections history hosts open and how backups are scoped. Each card covers one of these effects, with the check to run before go-live on the store you choose.

Shard metadata records

Temporal keeps one metadata record per history shard in the persistence store, and those records are created when the cluster starts. A larger shard count creates more of them, and the count is fixed for the life of the cluster. Before go-live, confirm in the schema for your chosen store how shard records are created, count them after initialization, and compare the total with the value you set.

Shard ownership writes

History hosts update each shard's ownership record as they acquire and release shards, and those updates are guarded by a range ID. Fewer shards concentrate workflow writes onto fewer records, so a busy shard can see more contention. During load testing, track persistence write latency and conditional write conflicts per shard, and check whether a small number of shards carries most of the traffic.

Connection pool demand

Each history host opens connections to the persistence store for the shards it owns, and the pool size you configure sets the ceiling on concurrent queries. Spreading shards across more hosts divides the load, while the total number of active shard loops still grows with the shard count. Measure open connections per host, pool wait time and the connection limit of your database at expected peak.

Data layout by shard

Shard-scoped tables use the shard identifier as a key, so the shard count sets how evenly rows spread across partitions on Cassandra and across index ranges on PostgreSQL or MySQL. Uneven spread can produce large partitions or hot index ranges as workflow history grows. Confirm the key layout in the schema for your store and version, then review partition or table sizes and purge timing after a soak test.

Backup and restore scope

A backup captures the rows for every shard, and a restore must bring back the same shard count the cluster was created with. Rehearse restores against a copy that keeps the original configuration, not an ad hoc test cluster. Measure full backup duration, the time to a working cluster after restore and whether point-in-time recovery covers all shards on your store.

Persistence docs

Why numHistoryShards cannot change after the cluster starts

The history shard count is fixed because of how Temporal assigns workflows to shards. Each workflow ID is hashed, and the hash is taken modulo the shard count to choose the shard that owns that workflow's state and history. The owning history service instance holds a lease on each shard, and all of a workflow's events are written through that shard. If numHistoryShards changed, the same workflow ID would hash to a different shard, so existing workflow state would sit on a shard that no longer maps to it. Ownership would break, and running workflows could not be found where the server expects them. This is why the value is treated as a property of the cluster's data, not a tuning knob.

The practical consequence is that the only safe path to a different shard count is a new cluster with the desired value, followed by a migration of workflows from the old cluster to the new one. Planning should therefore happen before the first production workflow runs. Ask the team which workload peaks, how many concurrent open workflows are expected, and how far the company expects to grow over the cluster's expected life. Record the chosen value in the deployment runbook and in the infrastructure-as-code that creates the cluster, so that no later environment is built with a different number by mistake. Treat a migration as a project with its own testing, cutover and rollback plan, not as a configuration change.

Confirm the current behavior before you commit to a number. Check how the persistence documentation describes the shard count and its storage effects, and read the migration guidance for the Temporal version you plan to run, because the supported migration options can change between releases. Ask your Temporal contact or the community channels to confirm whether any in-place resharding path exists for your version. Put that answer in writing in the design record, since it determines how much a wrong initial choice would cost you.

Setting numHistoryShards on a new cluster

This sequence sets numHistoryShards once, before the first start, on a cluster with a supported persistence store and server version. It ends with confirmed shard ownership and a history service that is healthy under the configuration you chose.

  1. Confirm workload and growth assumptions

    The platform owner and the workflow team estimate expected workflow executions, event history volume, peak start rates and growth over the planned life of the cluster. Record these numbers in the design document, since numHistoryShards cannot be changed after the cluster starts. Ask the Temporal team or your partner to review the estimate against the shard guidance in the Temporal documentation. The step is done when the assumptions and the shard count proposed from them are signed off by the people who will run the cluster.

  2. Choose a supported persistence store

    Select the primary persistence store from the versions Temporal documents as tested: Cassandra 3.11, 4.0 and 5.0.4 or later, PostgreSQL 13 to 16, or MySQL 5.7 and 8.0.19 or later. The platform team confirms the chosen database version against the Temporal persistence documentation and checks that its hosting, backups and high availability match the organization's standards. SQLite is for development and testing only. The step is done when the store, its version and its connection details are written into the build record.

  3. Select the advanced visibility store

    Decide which visibility store will serve workflow search and listing. Elasticsearch 7 and 8, OpenSearch 2 or later (from Temporal Server 1.30.1), and MySQL, PostgreSQL or SQLite (from 1.20) are the documented options, and Temporal recommends Elasticsearch or OpenSearch for anything beyond a few workflow executions. Cassandra visibility was removed in 1.24. Confirm the chosen store against the Temporal visibility documentation and size it with the same workload assumptions. The step is done when the visibility store is provisioned and reachable from the planned history and frontend hosts.

  4. Pick the server version and deployment method

    Use the latest patch of the current minor line for a new install. The Temporal Server v1.32.1 release was published on October 8, 2026, and v1.31.4 and v1.30.8 followed on October 12, 2026 for earlier minor lines. Choose one deployment method: Docker Compose, Go binaries, Helm charts on Kubernetes, or a custom Go build. If you use Helm, the chart version must be 0.73.1 or later for server images 1.30 and later. The step is done when the server image tag, the chart or binary version and the deployment method are recorded in the build record.

  5. Set numHistoryShards in server configuration

    Write the chosen value into the server configuration before any service starts, and store the file under version control so the value cannot drift. Make sure every history host reads the same file, because all history services must agree on the shard count. Record the value next to the cluster name and the persistence schema, since changing it later is not a routine change. Review the file with a second engineer. The step is done when the configuration is committed, reviewed and deployed to every planned history host without edits made on the host itself.

  6. Run persistence schema setup

    Create the schema for the chosen persistence store using the schema setup tooling described in the Temporal persistence documentation, before starting the server. Run the setup against the target database with the same connection settings the services will use. Confirm the tables or keyspaces exist and that the schema version recorded in the database matches the server version you chose. If release notes call for a schema upgrade on a later server version, the schema change runs before the server change. The step is done when the database reports the expected schema version and the setup log has no errors.

  7. Start services and verify shard ownership

    Start the frontend, history, matching and worker services with the shared configuration. Watch the history service logs for shard acquisition messages and confirm that the shards are claimed across the history hosts without repeated ownership errors. Check the Temporal metrics that report shard and history service health in your monitoring system, and confirm that they stabilize after startup. Run a test workflow in a test namespace to confirm end-to-end execution. The step is done when every planned history host reports its shards, the metrics are steady and the test workflow completes.

  8. Restrict network access and authorization

    Before any team or application uses the cluster, confirm that the Temporal services run on hosts that are not reachable from the public internet and that network access is limited to trusted internal networks. Configure an Authorizer and a ClaimMapper, since the default noopAuthorizer allows every API request without authentication or access control. Enable mTLS for internode and frontend traffic as your security standards require. The Temporal self-hosted security documentation describes these settings. The step is done when a test call without valid credentials is refused and the security review of the cluster is complete.

Operational and security considerations for the shard decision

The shard count is only one part of a cluster that holds workflow state, so the network, credentials, backups and upgrade path need the same planning. These cards cover the controls that apply once the shard count is fixed and the cluster is in production.

Keep services off the public internet

Temporal's deployment guidance says Temporal services should run on hosts that are not reachable from the public internet, with network access limited to trusted internal networks. History services hold the shard state that the shard count divides, so they should sit behind the same restriction as the database. Check every path from the internet to the frontend, history, matching and worker services, including load balancers and ingress rules, before go-live.

Deployment docs

Persistence credentials and TLS

Every History shard reads and writes through the persistence store, so the database account the cluster uses is a high-value credential. Use a dedicated database user with rights limited to the Temporal schema, store the password in a secrets manager, and encrypt connections to the database. Self-hosted Temporal also supports mTLS with separate settings for internode and frontend traffic, so decide how certificates for each path will be issued, rotated and revoked.

Security docs

Authorization before first traffic

If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. A cluster that is tested without an Authorizer can reach production that way by accident. Plan the ClaimMapper and Authorizer settings, the namespace roles and the OIDC single sign-on for the Web UI before the cluster takes real workflows.

Security docs

Backup coverage of the chosen store

The shard count is written into the persistence store, so a restore must bring back the same shard layout that the database holds. Back up the store that Temporal uses for workflow state, and if advanced visibility runs on a separate store, back that up too or confirm how its contents can be rebuilt. Ask the database team to test a restore into a separate environment and check that the restored cluster starts with the original shard count.

Persistence docs

Supported persistence and visibility versions

Temporal is tested on specific database versions, and the shard count decision should be checked against the database you will actually run. Confirm the exact persistence and visibility versions against the current docs before provisioning, because the supported set changes between Temporal Server releases. Running an unsupported database version can turn a shard decision into an outage.

Persistence docs

One minor version at a time

Temporal recommends upgrading one minor version at a time, moving to the latest patch of the current minor first, because backward compatibility is guaranteed only between two successive minor versions. When release notes call for it, run schema upgrades before the server upgrade. Because the shard count cannot change after start, plan upgrades and rollback steps against the existing shard layout and test them in a non-production cluster first.

Upgrade docs

Questions teams ask before choosing a shard count

Can the history shard count be changed after a Temporal cluster starts?

No. The history shard count is set when a cluster starts and stays fixed for that cluster's life, so a different value means standing up a new cluster and moving workflow state into it. That is a migration project with its own testing, cutover window and rollback plan, so the cost of a wrong first value is much higher than the cost of choosing carefully. Record the chosen value in your deployment design, along with the load range and growth assumptions behind it. Confirm the fixed-value behavior for your Temporal Server version in the self-hosted deployment guide before you commit, since guidance can change between releases.

How do you pick a shard count without load test data?

Start from the expected scale of the workload, choose a value that leaves room for growth, and validate it with a load test before production. Without measurements, the inputs are peak and average workflow starts per second, the number of concurrent open workflows, typical history size per workflow, the number of namespaces, and the growth forecast over the planned life of the cluster. Ask business owners for forecasts in those units, not in general terms. Expect the first estimate to be a range, and document each assumption so the team can revisit it when the first load test or production data arrives. Because the value is fixed, the design review should state that trade-off openly and name who approves the final number.

Does a larger shard count increase the cost of running Temporal?

It can, but the shard count is one input among several. More shards spread the work across more history processing, which can require more service capacity and more load on the persistence database. The costs that move with the count are usually database capacity, compute for history service instances, and the operating effort to monitor them. Ask the sizing partner to show which line items change at each candidate value and which stay flat, such as databases you already run. Compute, storage and database operations recur every month, while the sizing work and the design document are one-time costs. Ask for the cost comparison in writing so the platform and finance teams can review the same assumptions.

How much effort does a shard sizing exercise take, and what drives it?

Effort depends on how much measurement you already have and how many variables you cannot control. A typical exercise covers workload modeling, a documented shard decision, a database capacity check, a load test plan, and a handover of the design to the teams that will operate the cluster. The main drivers are the number of namespaces and workload types, whether a predecessor system provides production history, the number of persistence and visibility backends to check, how many stakeholders must agree on growth forecasts, and whether a non-production environment matches production. Ask any provider for a written list of deliverables, the assumptions behind the estimate, and the factors that would change it. A fixed scope agreed in writing before work starts makes quotes comparable.

Can an internal platform team size the shard count on its own?

Yes, if the team includes engineers who understand Temporal's architecture, database operations and load testing, and if they have time to finish the exercise before the cluster carries production traffic. The hard part is the inputs rather than the calculation: forecasting workload, testing with realistic traffic shapes, and reading database metrics under load. Teams without that experience often underestimate load test work and the persistence capacity review. A useful self-check is whether someone can explain what a shard does for your workload, what symptoms a value that is too low would show, and how the choice would be validated before go-live. If those answers are missing, a scoped review by a partner can close the gap while your team keeps ownership of the decision.

What does a partner need from us before sizing history shards?

A partner needs your workload facts, platform constraints and a named decision owner. Provide expected workflow and activity volumes at peak and on average, typical workflow duration and history size, the planned namespaces and their owners, the persistence database and version you intend to use, the visibility store, the hosting model and network boundaries, and any existing workflow data that must move. Also share the growth forecast for the planned life of the cluster, your availability and recovery targets, and access to a non-production environment for load testing. Ask the partner to confirm in writing which inputs they will verify and which they will accept from you as given, so gaps are visible before the sizing starts.

Which database changes when the shard count goes up?

A higher count changes how much work the persistence layer handles, so check the database and visibility stores before you choose a value. Temporal documents persistence on Cassandra, PostgreSQL and MySQL, and SQLite is meant only for development and testing. Visibility can run on Elasticsearch, OpenSearch or supported SQL stores, depending on the server version. Confirm the supported database versions for your chosen server release in the persistence documentation. Review connection counts, IOPS, storage growth, backup duration and failover behavior under load. Ask the sizing exercise to output database requirements for each candidate value, so the platform and database teams can approve capacity before the cluster is built.

How DeployOpen scopes shard sizing in a Temporal implementation

DeployOpen treats the history shard count as a written decision inside a fixed-scope Temporal engagement, not as a setting to pick during installation. The work starts with a review of workload and growth inputs with the client: expected workflow start rates, typical event history sizes, the number of namespaces and their likely growth, the persistence backend the client already operates, and the peak load the platform must absorb. The output is a documented choice of numHistoryShards with its rationale, the assumptions behind it, and the conditions under which the team would revisit it. Because the value cannot be changed once the cluster starts, the document also records who owns the decision and what evidence would be needed to justify a different count later.

The engagement then plans the load test that confirms the chosen count before go-live. The plan names the scenarios to run, the Temporal and persistence metrics to watch, the database capacity checks, and the pass criteria agreed with the client's platform and database teams. DeployOpen builds and runs these tests in the client's own infrastructure, in the cloud accounts, data centers or air-gapped networks the client controls, so the results reflect the environment that will carry production traffic. Ask the proposal to state which persistence and visibility stores are in scope, which test tooling is used, and whether the client's staff or DeployOpen will run each test. A quote follows from this written scope, so unclear boundaries here move cost.

After go-live, operations support is available through a retainer if the client wants it. A retainer can cover monitoring review, capacity checks as load grows, Temporal server upgrades and the database schema steps that go with them, and retesting if workload changes materially. Because the shard count stays fixed, the practical question is whether the existing cluster will need a new deployment or a migration if growth outruns the original plan, so the retainer scope should say how that contingency is handled. Clients that prefer to operate the cluster alone receive the documentation, runbook and load test results so their own team can carry the decision forward.

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.