Run a small self-hosted Temporal Service
A small self-hosted Temporal Service runs three things: one Temporal Server process, one PostgreSQL database, and the Temporal Web UI. The Temporal Server runs its Frontend, History, Matching, and Worker services together in that one process. PostgreSQL stores both Workflow state and Visibility data, so you don't need Elasticsearch, OpenSearch, or Cassandra. This setup has no high availability for the server: if the server process stops, Workflows pause until it restarts.
Use this setup for a small team with a modest, predictable workload that can accept brief planned downtime during upgrades. If you need the service to stay available through a host failure, sustained high throughput, or an uptime SLA, see When to move to a larger deployment.
Your Workers run in your own application whichever way you host the Temporal Service. This page covers only the Temporal Service.
SQLite and temporal server start-dev are for development and testing only, including with --db-filename. Use
PostgreSQL or MySQL for any Temporal Service that holds Workflows you need to keep.
What you run
| Component | What to use | Notes |
|---|---|---|
| Temporal Server | One temporalio/server container, or the temporal-server binary | Runs all four services in one process by default. |
| Database | PostgreSQL 12 or later. A managed service such as Amazon RDS, Google Cloud SQL, or Azure Database for PostgreSQL keeps backups and patching off your plate. | Holds two databases: temporal for Workflow state and temporal_visibility for Visibility. MySQL 8.0.19 or later also works. |
| Web UI | One temporalio/ui container | Lets you browse and act on Workflow Executions. |
| Schema tool | The temporalio/admin-tools image, run as a one-off job | Creates and upgrades the database schemas. It doesn't run continuously. |
Set up the service
-
Create the database. Provision PostgreSQL on a private network that the server host can reach.
-
Choose the History Shard count before the first start.
SetnumHistoryShardsto 512The number of History Shards is fixed when the Temporal Service first starts. You can't change it later without building a new Temporal Service and moving your Workflows to it.
The
temporalio/serverimage reads the value from theNUM_HISTORY_SHARDSenvironment variable and defaults to4, which is meant for development. SetNUM_HISTORY_SHARDS=512before the first start. -
Create the schemas. Run
temporal-sql-toolfrom thetemporalio/admin-toolsimage to create thetemporalandtemporal_visibilitydatabases and their schemas. Use the image version that matches your server version. See Database schema and setup for the commands. -
Start the server and the Web UI. Start from
docker-compose-postgres.ymlin the samples-server repository. It runs onetemporalcontainer with all four services, PostgreSQL for both persistence and Visibility, and the Web UI. To use your own database:- Remove the bundled
postgresqlservice. - Remove the
temporal-admin-toolsservice, which sets up the bundled database. Step 3 already created your schemas. - Remove the
temporalservice'sdepends_onentry fortemporal-admin-tools. - In the
temporalservice, pointPOSTGRES_SEEDS,POSTGRES_USER, andPOSTGRES_PWDat your database and addNUM_HISTORY_SHARDS=512.
Pin the image tags to a specific version.
- Remove the bundled
-
Create a Namespace with a Retention Period. The Retention Period controls how long closed Workflow Executions stay in the database.
temporal operator namespace create --namespace your-namespace --retention 7d -
Keep the server off the public internet. Expose port 7233 only to your Workers and Clients on a private network. To authenticate them, configure mTLS.
Operate the service
- Backups. All Temporal state lives in PostgreSQL. Use your database's automated backups and point-in-time recovery. The server process holds no state that needs a backup.
- Database growth. Closed Workflow Executions stay in the database until the Namespace Retention Period passes. Choose a Retention Period that matches how long you need to inspect closed Workflows. Archival can keep Event Histories longer, but it's experimental and isn't supported when you run Temporal through Docker. On busy deployments, also plan for Visibility index maintenance.
- Monitoring. Set
PROMETHEUS_ENDPOINTon the server container (for example,0.0.0.0:8000) and scrape it. At a minimum, alert when the server process restarts or stops, whenpersistence_latencyorservice_errorsrise, and when database CPU or storage runs high. See Monitoring.
Upgrade the server
Upgrade one minor version at a time, and update the schemas before the server:
- Read the release notes for the next minor version.
- Upgrade to the latest patch release of your current minor version.
- Update the
temporalandtemporal_visibilityschemas withtemporal-sql-tool update-schema, using thetemporalio/admin-toolsimage for the target version. - Change the server image tag to the target version and restart the server.
- Verify the upgrade. Don't start the next version until
numshards_gaugeis back to the full Shard count and the error and latency metrics have settled. - Repeat for each minor version until you reach the version you want.
Don't skip minor versions, and don't deploy the latest tag. Temporal Server guarantees data compatibility only
between consecutive minor versions.
With one server instance, the restart in step 4 is a short outage. Workflows pause and continue when the server is back. See Upgrade the Temporal Server for the full procedure.
What this setup doesn't provide
- Server high availability. The server process is a single point of failure. While it's down, Workers can't poll for Tasks, Timers don't fire, and Clients can't start Workflows or send Signals. No Workflow state is lost, because it lives in PostgreSQL, and Workflows continue when the server restarts. Database availability depends on how you run PostgreSQL.
- Zero-downtime upgrades. Each upgrade restarts the only server instance.
- More instances by adding replicas. Running more than one server instance requires each instance to join the cluster membership with a reachable address. Start from the Helm charts or the multi-role Docker Compose example instead of adding replicas of the single container.
- Paid support. Temporal doesn't offer paid support for self-hosted deployments. Community support is available on the Temporal community forum and Temporal Slack.
When to move to a larger deployment
Plan a larger deployment when you see any of these signals:
persistence_latencyor database CPU stays high under normal load.- Listing and filtering Workflow Executions in the Web UI or CLI becomes slow.
- The service needs to stay available through a server restart or a host failure.
- Your workload is growing toward sustained high throughput.
Next steps, which you can take one at a time:
- Run the services as separate processes so you can scale each one. See Deployment.
- Move Visibility to Elasticsearch or OpenSearch, using Dual Visibility to migrate.
- Work through the production checklist.
Setting 512 History Shards at the start leaves room to scale the same Temporal Service. If you'd rather not run the Temporal Service yourself, Temporal Cloud runs it for you, and your Workers stay on your infrastructure.