Self-Hosted
Design notes for running Celerity applications, and Celerity itself, on your own infrastructure with a fully open source backing stack
Design notes
Self-hosted deployment is a future idea, beyond the vision, and is not available. These notes set out an early design for how it is likely to work. Nothing here is committed, and the design will change if self-hosted deployment is built.
A self-hosted target would run Celerity applications, and the Celerity control plane that deploys them, on infrastructure you run yourself, with no cloud provider involved. Every engine in the default backing stack is open source, under the Apache 2.0, BSD, MIT or PostgreSQL licences, so a self-hosted deployment can run indefinitely without depending on any vendor's licensing.
It would complete Celerity's portability: the same blueprint and handler code run in local development, on your own hardware and on any supported cloud.
Tiers
Self-hosted deployment would come in two tiers, using one new containerised deploy target, self-hosted. There is no serverless variant. The tier is chosen in the deploy configuration with selfhosted.compute.orchestrator.
| Tier | Orchestrator | For |
|---|---|---|
| Tier 1 | Docker Compose (compose) on a single node | Small deployments, homelabs and single servers. One command on one machine. |
| Tier 2 | Kubernetes (kubernetes) | Larger deployments that need high availability and horizontal scaling. |
Tier 1 is the primary focus and stands on its own; Tier 2 would follow it. Tier 1 is not highly available, and its documentation would say clearly where that boundary is.
Local development, sometimes called Tier 0, is unchanged by this design.
Backing Services
Each resource type would map to an open source engine. Defaults favour engines with permissive licences that are unlikely to change, and some resource types have an alternative engine you can opt into in the deploy configuration, such as selfhosted.datastore.engine set to scylla or selfhosted.bucket.engine set to garage. Some opt-in engines have different licences: ScyllaDB is source-available, Garage and the bundled Grafana stack are AGPL, and OpenBao is MPL 2.0.
| Resource type | Default engine | Opt-in alternative | Tier 1 (Compose) | Tier 2 (Kubernetes) |
|---|---|---|---|---|
celerity/api, celerity/handler, celerity/handlerConfig | Celerity runtime container | A service per application behind Traefik | A Deployment, Service and HorizontalPodAutoscaler | |
celerity/consumer | Celerity runtime polling loop | A service | A Deployment, with KEDA as a later option | |
celerity/schedule | The runtime's own scheduler, with a Valkey lock so that each schedule fires once across replicas | In-process | In-process | |
celerity/workflow | Celerity workflow runtime | A service | A Deployment | |
celerity/sqlDatabase | PostgreSQL 17 | MySQL, alongside MySQL support on other targets | A container with a volume | The CloudNativePG operator, for high availability, backups and point-in-time recovery |
celerity/datastore | A PostgreSQL-backed driver in each SDK | ScyllaDB Alternator | Reuses PostgreSQL | Reuses PostgreSQL |
celerity/cache | Valkey | A container | Sentinel-based high availability | |
celerity/queue | NATS JetStream | A single node with one replica, writing to disk on every message | A three-node cluster with three replicas | |
celerity/topic | NATS JetStream subjects | The same NATS server | The same NATS cluster | |
celerity/bucket | SeaweedFS | Garage | A container | SeaweedFS's Kubernetes charts, or any S3-compatible endpoint, such as Ceph with Rook |
celerity/config | A PostgreSQL-backed encrypted store | OpenBao | Reuses PostgreSQL | Reuses PostgreSQL |
celerity/vpc | A Compose bridge network per application | A network | A namespace with NetworkPolicies | |
| Ingress and TLS | Traefik, with ACME or self-signed certificates | A Traefik container | The Traefik ingress controller, with cert-manager | |
| Observability | Any OTLP endpoint | A bundled Grafana stack, chosen when the stack is set up | ||
| Control plane | The Bluelink deploy engine, with PostgreSQL for state and a CNCF Distribution container registry | Containers alongside the applications | In the cluster, or external |
A minimal Tier 1 deployment would run PostgreSQL, Valkey, NATS, SeaweedFS, Traefik, the runtime containers and the deploy engine. WebSocket messages would be delivered across runtime replicas over NATS, the same engine used for queues and topics. Valkey's only jobs are the cache and the schedule lock; it isn't used for messaging.
Data stores
The default data store is a PostgreSQL-backed driver in each Celerity SDK. The datastore SDK operations are written as high-level operations rather than a pass-through to any one cloud's API, so the SDK is where a self-hosted data store plugs in. Each language's SDK gets its own driver, and all of them use one data layout.
The data model maps naturally onto PostgreSQL. Each data store is a table keyed by partition and sort key, with the item stored as JSON:
- Querying within a partition is a range scan on the primary key, which is the same access pattern as DynamoDB.
- Indexes are expression indexes on the JSON, and they are strongly consistent.
- Conditional and atomic writes are PostgreSQL transactions.
- Change events for consumers come from a change table fed by triggers, or from logical decoding.
- Time to live is a background sweep.
PostgreSQL already serves SQL databases, config stores and the deploy engine's state, so the data store driver adds no containers. The trade-off is that a single PostgreSQL node doesn't scale writes horizontally by partition key. A well-provisioned node covers what most self-hosted deployments need, in the range of tens of thousands of operations a second and hundreds of gigabytes, and ScyllaDB Alternator is the opt-in for more. ScyllaDB is designed to own a whole machine, which makes it a poor neighbour for other services on a single Tier 1 server, so it isn't the default.
Schema management already knows each data store's keys and indexes, so it would create the PostgreSQL tables and indexes from the same schema files.
ScyllaDB Alternator has two caveats. It is source-available rather than open source, with limits on its free tier. And it has no multi-item transactions, so atomic writes are not supported on it. Atomic writes are used in handler code rather than declared in the blueprint, so the build would record their use and refuse to deploy to ScyllaDB rather than fail at runtime.
Messaging
Valkey streams were considered for queues and topics, to reuse the cache's engine, but they fall short in three ways. With Valkey's usual persistence settings and asynchronous replication, a failover can lose messages that were already acknowledged. A stream is a single key on a single shard, so a busy queue can never grow past one node. And a stream's backlog is held in memory, so a stalled consumer pushes the server towards running out of memory.
Queues and topics use NATS JetStream:
- JetStream's acknowledgement timeout and redelivery behave like a queue's visibility timeout.
- Its maximum delivery count and advisories provide dead-letter behaviour.
- Topics use subjects, with a durable consumer per subscriber, so fan-out to several queues needs no intermediary.
JetStream stores messages on disk and, with three replicas, acknowledges a write only once a quorum has it, so an acknowledged message isn't lost when a node fails. Moving from Tier 1 to Tier 2 is a change to the replica count, not a different design.
Local development keeps using Valkey for queues and topics, as it does today. Celerity doesn't rely on running the same engine everywhere for consistent behaviour: local Valkey already differs from SQS and SNS on AWS. Instead, each messaging driver is held to a shared contract by conformance tests, and a NATS driver would be held to the same tests.
Config and secrets
The default config store keeps values encrypted in PostgreSQL. Reads are fast, and the runtime resolves values at startup and caches them with a refresh, as it does with cloud secret managers. PostgreSQL's LISTEN/NOTIFY can also push changes to running instances straight away.
The difference from a cloud secret manager is where trust is rooted. A cloud secret manager encrypts with keys held in a KMS or HSM, so compromising the database alone doesn't reveal the secrets. The PostgreSQL store's master key lives in a file or environment variable on Tier 1, where everything on the machine shares the same fate anyway. On Tier 2 it lives in a Kubernetes Secret or a sealed key. The store keeps versions and an append-only audit table; it doesn't automate rotation. Teams that need a separate root of trust, dynamic secrets or a PKI can opt into OpenBao.
Buckets
SeaweedFS is the default because it is Apache 2.0 licensed, mature and well integrated with Kubernetes. MinIO, which local development has used, is no longer maintained as open source, and newer alternatives such as RustFS are less proven. Garage is the opt-in for very small footprints and for deployments spread across several sites. Any S3-compatible endpoint can be used instead, since the bucket driver speaks S3.
Deploying
Self-hosted deployment would include the whole platform, not just the applications. The Bluelink deploy engine and its PostgreSQL state run alongside the applications, or outside the cluster on Tier 2.
The new pieces of work are:
- A
newstack-cloud/self-hostedprovider plugin for Bluelink. Kubernetes publishes an OpenAPI schema for every resource kind, so the Tier 2 provider can largely be generated from those schemas, in the same way as resource coverage for the cloud providers. - Additions to the Celerity transformer for the
self-hosteddeploy target. - A
celerity self-hosted initcommand that sets up the stack.
Links between resources are much simpler to build than they are on cloud providers. There is no IAM and no service-specific event plumbing, so a link comes down to environment variables, network attachment (Compose networks, or NetworkPolicies on Kubernetes) and a small set of intermediary resources for a fixed set of engines.
Deploy configuration options would use the selfhosted. prefix, following the same conventions as the aws. options, with defaults driven by the app environment.
Operating
On a cloud provider, much of the day-to-day work of running applications happens in the provider's own console and tools: seeing what is running, reading logs, checking a database's health and restoring backups. A self-hosted deployment has no provider, so Celerity would need to cover that work itself.
The baseline would be an expanded celerity self-hosted command set, built on the deploy engine's API, so that it works over SSH on a server with no display and can be scripted:
| Command | Purpose |
|---|---|
init | Sets up the stack on a new machine or cluster. |
status | Shows the applications and versions that are running, the health of each backing service, and resource headroom such as disk and memory, which matters most on a single Tier 1 server. |
upgrade | Upgrades Celerity and the backing engines, checking versions and running any migrations they need. |
backup and restore | Backs up and restores the stack's data. PostgreSQL holds SQL databases, data stores, config stores and the deploy engine's state, so one backup covers most of it; buckets and message streams are backed up separately. |
logs | Shows an application's logs, without needing to know the names of the containers Celerity created. |
secrets | Sets, rotates and audits values in the PostgreSQL-backed config store, which has no console of its own. |
A web dashboard served by the deploy engine could build on the same API, showing applications, deployments, health and logs. Changes would still be made through blueprints and the CLI. Metrics and traces would stay in the observability stack rather than being repeated in the dashboard.
Last updated on