Production Deployment Checklist
A pragmatic checklist for shipping FlowOrchestrator to production. Walk through every section before go-live; bookmark this page for the first incident review.
For changing a flow once it is in production, see Versioning Flows.
1. Storage and Persistence
FlowOrchestrator writes to fourteen tables. The auto-migrator
(FlowOrchestratorSqlMigrator) creates them idempotently on startup.
| Table | Holds |
|---|---|
FlowDefinitions |
One row per registered flow (id, name, version, manifest JSON). |
FlowRuns |
One row per TriggerAsync invocation (status, trigger data, timestamps). |
FlowSteps |
One row per step instance per run (status, inputs, output). |
FlowStepAttempts |
Per-attempt history for retried steps (attempt number, error, durations). |
FlowOutputs |
Step outputs keyed by (RunId, StepKey). |
FlowStepDispatches |
Idempotent dispatch ledger — supports the Dispatch many, Execute once invariant. |
FlowStepClaims |
Exclusive execution claim per step (the "Execute once" half). |
FlowStepLeases |
Owner, fence and expiry of each claim taken under a lease, so a crashed worker's step is taken over (2.0). |
FlowRunControls |
Cancellation, idempotency key, run timeout. |
FlowIdempotencyKeys |
Idempotency dedupe at trigger time. |
FlowSignalWaiters |
Parked WaitForSignal steps. |
FlowScheduleStates |
Recurring-trigger sync state. |
WebhookReplayNonces |
Seen webhook timestamp/nonce pairs for replay protection (TTL-expired). |
WebhookRejections |
Webhook hardening DLQ + recent-deliveries log (rejected and accepted). |
Warning
UseInMemory() is not for production. All run data is stored in-process and
lost on restart. The runtime is supported only for development and tests; the
manifest's Getting Started page
already calls this out, but it bears repeating here.
SQL Server
- Use a case-insensitive collation (the default
SQL_Latin1_General_CP1_CI_ASis fine). Step keys are matched as-is and a CS collation will surprise developers. - Indexes are created by the auto-migrator. If you sharpen them, do it under a separate review — the engine relies on them for the dispatch-ledger fast path.
- Enable point-in-time recovery (PITR) — every table is part of the operational record and a 24 h gap is hard to reconstruct.
PostgreSQL
- Tune
max_connectionsagainst the Hangfire worker count (see §5 Hangfire worker tuning for the default) plus dashboard / API traffic. - Leave autovacuum on. The dispatch ledger is hot under high throughput; bloat shows up as
EXPLAINplans falling off index scans. - Logical replication or
pg_basebackupfor backups — both work, just have a tested restore drill.
Hangfire on PostgreSQL
Hangfire.PostgreSql (the community job storage for the Hangfire runtime) keeps its distributed locks as
rows in its lock table. Hangfire.SqlServer uses session-scoped sp_getapplock instead. A row survives
the process that wrote it, and only stops counting once it is older than DistributedLockTimeout. Hangfire
takes a job's job:{id}:state-lock for each state change. So when a replica is killed during one, a
surviving server re-fetches the job after InvisibilityTimeout and then waits on the orphaned lock.
Crash recovery takes the longer of the two timeouts, and each re-fetch in between parks another worker.
While the step waits, it has a dispatch-ledger row, no claim and no status row: it is delayed, not lost.
- Keep
DistributedLockTimeoutat mostInvisibilityTimeout. The package defaults (30 min invisibility, 10 min lock timeout) satisfy that. If you shortenInvisibilityTimeoutto recover faster, shorten the lock timeout with it, or recovery stays at 10 min.UseHangfire()logs a warning at startup (EventId 3160) when the lock timeout is the longer one. - Do not set the lock timeout below the longest time a lock is legitimately held. Once a lock is older than
the timeout, another server takes it over. FlowOrchestrator's step jobs hold no Hangfire locks beyond
Hangfire's own (state changes, the schedule poller, the recurring-job scheduler), which are held for
milliseconds to seconds. A
[DisableConcurrentExecution]job of your own holds its lock for the whole job. - A replica killed while holding the schedule poller or recurring-job lock delays every scheduled step
(
Pendingre-polls, delayed dispatches) or every cron trigger, cluster-wide, for up toDistributedLockTimeout.
builder.Services.AddHangfire(c => c.UsePostgreSqlStorage(
o => o.UseNpgsqlConnection(pgConnStr),
new PostgreSqlStorageOptions
{
InvisibilityTimeout = TimeSpan.FromMinutes(5),
DistributedLockTimeout = TimeSpan.FromMinutes(1), // <= InvisibilityTimeout
}));
Orphaned lock rows can be listed with
SELECT resource, acquired FROM hangfire.lock ORDER BY acquired;. Use your own schema if you set
SchemaName. A …:job:{id}:state-lock row more than a few seconds old was almost certainly left by a
killed process, because state changes take milliseconds.
Backup recipe
Full backup + transaction-log / WAL replay covers every table above. Step inputs and outputs are persisted in FlowOutputs, so restoring is restoring state, not just configuration.
2. Multi-Instance Deployment
FlowOrchestrator's core invariant — Dispatch many, Execute once — is what makes horizontal scale safe.
IFlowRunStore.TryRecordDispatchAsyncis an idempotent INSERT intoFlowStepDispatches. Multiple workers may try; only one row lands. Backed bySqlFlowRunStore(source).TryAcquireStepLeaseAsync(the claim guard) ensures only one runtime instance executes a given step attempt; the others exit silently. The claim is a lease (RunControl.StepLeaseDuration, default 60 s) renewed by the instance running the step: if that instance is killed or loses its database, the lease expires and another instance takes the step over (the runtime's redelivery, orFlowStepLeaseHostedService's sweep every half lease). A step interrupted by a crash therefore runs again — make handlers with external side effects idempotent. Recovery after a kill takes roughly the lease duration plus up to half of it; lower the lease to recover faster, but keep it at least three times your database's worst round trip, or a stalled-but-alive instance loses its step to another one (its late result is then rejected by the lease's fence).- Cron triggers under the Hangfire runtime use
IRecurringJobManager, which fires each schedule on exactly one server. The ServiceBus runtime fires cron via self-perpetuating scheduled messages on a queue — Service Bus's exactly-once-per-tick delivery handles cross-replica coordination without leader election. No extra coordination needed in either case.
Warning
InMemory runtime + multi-instance is not supported. The dispatcher is a Channel<T> inside one process — instance B has no way to observe a job that instance A enqueued. Always combine UseInMemoryRuntime() with a single instance. For multi-replica deployments use UseHangfire() (with shared Hangfire storage) or UseAzureServiceBusRuntime() (with shared SB namespace). Benchmark the Service Bus runtime against your own ingress rate before choosing it for a high-volume workload — see issue 192: against the local emulator its trigger throughput was ~20x lower than the other runtimes with a 470x p50/p95 spread, and that has not yet been measured against a real namespace. Watch flow_step_dispatch_duration_ms{runtime="service_bus"} while you load-test: a p95 close to your trigger-latency p95 puts the tail on the send, a small one puts it elsewhere.
Important
Disabled flows (v1.22+). Toggling IsEnabled = false on a flow record (via dashboard
or API) starts no run on ANY trigger path — manual, cron, webhook, re-trigger. Cron jobs are
additionally pulled from the scheduler. In-flight runs are not
cancelled; use the dashboard's Cancel run action for live work. Watch EventId 1010
TriggerRejectedDisabledFlow to track how often disabled-flow triggers are still being
attempted (a webhook producer or external cron not yet aware of the disable).
The refusal is now visible over HTTP. /trigger and /rerun answer 409 Conflict, the
webhook endpoint 403 Forbidden, all with disabled: true and no run id. Previously every one of
them answered 200 OK carrying a run id that no run backed, so a caller had no way to tell a
disabled flow from a started one. If you alert on non-2xx trigger responses, expect 409s where
you previously saw silent successes — that is the bug being fixed, not a new failure.
Blue-green deployment
- Pause every cron trigger (dashboard → trigger pause toggle).
- Wait for
GET /flows/api/runs/activeto drain to[]. - Cut over traffic to the new version.
- Resume cron triggers.
The dispatch ledger means an interrupted run will be re-driven by FlowRunRecoveryHostedService on the new instance — no manual replay step required. A step that was executing on an instance you stopped hard is taken over once its lease expires (see above).
3. Monitoring
Logs
Every log line emitted by the engine includes the RunId and step key (when
applicable). Forward the following correlation fields if your aggregator strips
unknown ones:
RunId(Guid)FlowId(Guid)StepKey(string)Attempt(int)
OpenTelemetry traces and metrics
Enable via options.Observability.EnableOpenTelemetry = true and wire up via
AddFlowOrchestratorInstrumentation() — see Observability.
| Span | Covers |
|---|---|
flow.trigger |
TriggerAsync from receipt to first step dispatch. |
flow.step |
One step end-to-end (expression resolution + handler). |
flow.step.poll |
One poll attempt of a PollableStepHandler<T>. |
| Metric | Type | Tags |
|---|---|---|
flow_runs_started |
counter | flow_id, trigger_key |
flow_runs_completed |
counter | status |
flow_step_duration_ms |
histogram (ms) | flow_id, step_key, status |
flow_step_poll_attempts |
counter | flow_id, step_key |
flow_step_dispatch_duration_ms |
histogram | runtime, mode, outcome |
flow_step_claim_lost |
counter | flow_id, step_key |
The full instrument list lives in Observability — What is emitted.
Suggested alerts
- Stuck runs.
count(active_runs WHERE status='Running' AND age > 1h) > 0— usually a missing handler or external dependency timeout. - Failed-run rate.
rate(flow_runs_completed{status="failed"}[5m]) > 1— tune to your volume. - Cron lag.
now() - last_recurring_fire > 2 × schedule_interval— Hangfire server unhealthy or paused inadvertently. - Queue depth. Hangfire's own
enqueuedcounter; FlowOrchestrator inherits it. - Crashed workers. EventId 5050 (a step whose lease expired was redelivered) and 3030 (a delivery took over an expired lease) mean an instance died or lost its database while running steps. A few around a deploy or a node loss are expected; a steady rate is not. EventId 3031 (an attempt lost its lease) means an instance was alive but could not renew for longer than
StepLeaseDuration— a database or network stall.
Health-check endpoint
Wire up the bundled health check so the load balancer can drop traffic when storage is unreachable:
builder.Services
.AddHealthChecks()
.AddFlowOrchestratorHealthChecks(); // probes IFlowStore reachability
var app = builder.Build();
app.MapHealthChecks("/health");
The check resolves IFlowStore from DI on every probe, so SQL Server, PostgreSQL,
and in-memory all work without re-registration. The probe budget defaults to 5
seconds and is configurable:
.AddFlowOrchestratorHealthChecks(timeout: TimeSpan.FromSeconds(2));
Verify it:
curl -f https://app.example.com/health
# Healthy
GET /health HTTP/1.1
HTTP/1.1 200 OK
Content-Type: text/plain
Healthy
The response degrades to 503 Service Unavailable with body Unhealthy when the
flow store throws or the probe budget elapses — point your load balancer at it.
4. Secrets and Credentials
- Connection strings. Never in source. Use environment variables,
appsettings.{Environment}.jsonoutside ofmain, or a managed secret store. - Webhook secrets. Each webhook trigger carries a
webhookSecretinput. Rotate it like any shared secret; supply a new value in the manifest and pause-resume the trigger so the routing table refreshes. - Webhook hardening pipeline (v1.25). Treat the dashboard webhook endpoint as a public attack surface. Recommended rollout:
- Set
WebhookSecurityOptions.EnforcementMode = Auditfor one release. The pipeline fires the IP allow/deny, rate-limit, HMAC signature and replay gates, logsEventId 4001/4002/4003/4005for failures, and writes the DLQ — but the endpoint still returns 200. Note the body-size cap is enforced ahead of the pipeline and returns 413 in every mode, includingAudit. Use the dashboard "Webhooks" tab to confirm legitimate traffic still validates. - Flip to
Enforceoncewebhook_rejected_totalis dominated by traffic you actually want to reject. - Set
webhookHmacKeyon every webhook trigger;webhookHmacKeyPreviousis your zero-downtime rotation slot. Successful matches against the previous key emitEventId 4010so you know when to revoke it. - Lock down source IPs. The matcher accepts CIDR (
10.0.0.0/8), inclusive ranges (10.0.0.10-10.0.0.42), wildcards (10.0.*.*), single addresses, and curated presets — mix-and-match inwebhookIpAllowList(array OR comma-delimited string). Bundled presets:github,stripe,shopify,twilio,square,atlassian/bitbucket,slack,mailgun,zoom, pluslocalfor RFC 1918 + loopback. Combine multiple presets viawebhookIpAllowListPresets(plural). SetWebhookSecurityOptions.ForwardedHeaderDepthto your actual reverse-proxy depth — never higher. - For multi-replica deployments, swap the in-memory replay/DLQ stores for SQL Server (
AddSqlServerWebhookHardening) or PostgreSQL (AddPostgreSqlWebhookHardening). The in-memory stores are single-process and will let a replay through on the second replica. See Webhook hardening for the full per-publisher cookbook.
- Set
- Dashboard sign-in. Basic Auth is one shared account with no roles — fine for scripts and an internal-only surface behind a VPN, insufficient for anything people sign in to from the internet. Configure
FlowDashboard:Authorization(OpenID Connect, e.g. Keycloak) so users get SSO, MFA and viewer / operator roles; Basic Auth can stay on alongside it for automation. See Securing the dashboard. The dashboard logs EventId4100/4101at startup when Basic Auth is the only protection outside Development or uses a weak password. With no authentication at all it is read-only outside Development (EventId4103, Error);FlowDashboard:AllowAnonymousOperators: truere-opens it to anonymous operators (EventId4104, Error) and should only be used behind another access control. - PII in step inputs/outputs. Step inputs and outputs are persisted in
FlowStepsandFlowOutputsand are visible in the dashboard's run detail view. Treat them as logs. If you need to ingest PII, redact before the step boundary and pass an opaque token instead.
5. Capacity Planning
Storage cost per run
A single run typically writes:
- 1 row in
FlowRuns - N rows in
FlowSteps(one per step) - N rows in
FlowOutputs(one per step that produced output) - N rows in
FlowStepDispatches(one per dispatched step — the idempotent dispatch ledger) - N rows in
FlowStepClaims(one per executed step; deliberately not released on terminal status, since the row is what makes execution exactly-once) - N rows in
FlowStepLeases(one per leased step; retired, not deleted, when the step ends, so its fence keeps rising; only live leases are in its filtered index) - M rows in
FlowStepAttempts(one per attempt — usually 1, more with retries) - 1 row in
FlowSignalWaitersperWaitForSignalstep - 1 row in
FlowIdempotencyKeysper trigger carrying an idempotency key
For a 5-step flow with retries off, that is ~25 rows per run. At one million runs per month, expect tens of GB per year before retention.
Note
FlowStepDispatches and FlowSignalWaiters were omitted from the sweep before the fix for
#188 and grew without bound. If you
have been running retention, rows belonging to already-purged runs are orphaned and the sweep
cannot reach them — see the one-time cleanup in
Observability — Retention.
Retention
Turn it on:
options.Retention.Enabled = true;
options.Retention.DataTtl = TimeSpan.FromDays(30);
options.Retention.SweepInterval = TimeSpan.FromHours(1);
Pick DataTtl against your audit requirements, not your storage budget — storage is cheap and a forensics request always wants a longer window than you set.
Hangfire worker tuning
The default WorkerCount = Environment.ProcessorCount * 5 is fine for most
FlowOrchestrator workloads (steps are typically I/O-bound). Increase only if
metrics show queue depth growing while CPU stays low. For background-CPU-bound
steps, lower it to avoid thrashing.
6. Upgrade Path
Within a major version (1.x → 1.y)
FlowOrchestratorSqlMigrator runs on every startup and applies pending DDL idempotently. Releases note any table or column additions; rolling deploys are safe.
Across major versions (1.x → 2.x)
A major bump may rename or split tables. The release notes include the migration path; run it in a non-production environment first and verify with a smoke run (see below).
Owning DDL changes
FlowOrchestratorSqlMigrator is always registered by UseSqlServer(connectionString)
and runs automatically on startup — there is currently no built-in opt-out
(the overload takes only the connection string).
If your operations team must own DDL changes, you have two options:
- Point the app's connection string at a database where its principal lacks
DDL rights. The migrator's
CREATE TABLE … IF NOT EXISTSstatements become no-ops once the schema already exists; if the schema is missing, startup fails loudly rather than silently creating tables. - Apply the schema yourself (DDL published in each release / reproduced from
FlowOrchestratorSqlMigrator) under your own deployment pipeline before the app starts, so every guardedIF NOT EXISTSblock is already satisfied.
Smoke-run verification
After any deploy:
- Trigger a manual run of a no-op flow (the simplest one in your manifest).
- Assert the run reaches
Status = Succeededwithin the SLA you expect. - Hit
/healthand check the response isHealthy.
If any of those fail, roll back before letting business traffic resume.
Tip
Running FlowOrchestrator in production? Tell us about your deployment in the GitHub Discussions — patterns and pain points feed directly into the roadmap.