Skip to content

Persistence Configuration

Fleans supports two persistence providers: SQLite (default, for local development) and PostgreSQL (for production and load testing). The provider is selected at startup via configuration — no code changes are required to switch.

Set Persistence__Provider (case-insensitive: Sqlite or Postgres) on every fleans-* workload via your deployment tool. For PostgreSQL, also provide a connection string via ConnectionStrings__fleans. The runtime key is documented in Configuration / Persistence.

The release pipeline publishes the compose bundle with PostgreSQL as the provider (fleans-postgres ships in the bundle). To switch to SQLite (single-host debug), or to point at an external Postgres, drop a docker-compose.override.yaml next to the bundle’s docker-compose.yaml:

services:
fleans-core:
environment:
Persistence__Provider: Postgres
ConnectionStrings__fleans: "Host=my-external-pg;Database=fleans;Username=fleans;Password=secret"
fleans-management:
environment:
Persistence__Provider: Postgres
ConnectionStrings__fleans: "Host=my-external-pg;Database=fleans;Username=fleans;Password=secret"
fleans-mcp:
environment:
Persistence__Provider: Postgres
ConnectionStrings__fleans: "Host=my-external-pg;Database=fleans;Username=fleans;Password=secret"
fleans-worker:
environment:
Persistence__Provider: Postgres
ConnectionStrings__fleans: "Host=my-external-pg;Database=fleans;Username=fleans;Password=secret"

docker compose up -d from the bundle directory merges the override automatically. The override file is not regenerated by the post-processor, so it persists across aspire publish re-runs.

If you’re running silos outside Compose or Helm (bare-VM systemd units, ECS task definitions, hand-crafted Kubernetes manifests), set the same runtime keys directly. Either via appsettings.json:

{
"Persistence": { "Provider": "Postgres" },
"ConnectionStrings": {
"fleans": "Host=postgres;Database=fleans;Username=fleans;Password=secret"
}
}

Or via environment variables (.NET configuration precedence puts env above appsettings.json):

Terminal window
Persistence__Provider=Postgres
ConnectionStrings__fleans="Host=postgres;Database=fleans;Username=fleans;Password=secret"

Accepted values for Persistence__Provider (case-insensitive): Sqlite, Postgres. Default: Sqlite.

SQLite requires no extra configuration for local development. The default connection string points to a temp-directory database.

Configuration KeyDescriptionDefault
ConnectionStrings:fleansSQLite connection stringDataSource=fleans-dev.db
ConnectionStrings:fleans-queryOptional read-side connection stringSame as primary

Startup behaviour: SQLite uses EnsureCreated() — schema is created from the EF Core model on first run. There is no migration runner for SQLite.

PostgreSQL requires an accessible Postgres instance and a connection string.

Configuration KeyDescriptionRequired
ConnectionStrings:fleansPrimary PostgreSQL connection stringYes
ConnectionStrings:fleans-queryRead-replica connection stringNo

Example appsettings.json:

{
"Persistence": {
"Provider": "Postgres"
},
"ConnectionStrings": {
"fleans": "Host=localhost;Database=fleans;Username=fleans;Password=secret"
}
}

Startup behaviour: PostgreSQL uses MigrateAsync() — EF Core migrations are applied automatically on Fleans.Api startup. Fleans.Web and Fleans.Mcp share the same database but do not run migrations.

Read replica: When ConnectionStrings:fleans-query is provided, the query DbContext connects to the replica. The replica must be provisioned separately (e.g. a PostgreSQL standby). The chart provisions only the primary fleans database; read-replica wiring is tracked in issue #170.

  • Configuration — runtime configuration keys for Persistence__Provider and ConnectionStrings__fleans
  • Observability — health checks, metrics, logging, tracing, dashboards, alerting
  • Deployment — how to wire the ConnectionStrings__fleans / ConnectionStrings__fleans-query env vars into Docker Compose, Kubernetes, and bare-VM deployments.
  • Self-Hosting on Kubernetes — bring-your-own Postgres on the Helm chart.