Skip to main content
Watt ServiceNet supports three storage backends. Choose based on your deployment requirements: in-memory for development, JSON file for simple persistent deployments, and PostgreSQL for production workloads that need full durability, encrypted secret storage, and multi-node support.

Comparison

In-Memory (Default)

When you start the node without any storage configuration, it defaults to in-memory storage. All registry state, providers, agents, and submissions exist only for the lifetime of the process.
Or with Docker:
In-memory mode is intentionally stateless. Use it for local development, integration tests, and CI pipelines where persistence is not needed.

JSON File Backend

Set SERVICENET_REGISTRY_FILE to a file path to enable file-backed persistence. The node creates the file and its parent directories automatically if they do not exist. State survives restarts.
The JSON file is read on startup and written after each state-changing operation. This backend is suitable for simple single-node deployments with low write volume. It is not suitable for high-concurrency workloads or deployments that need encrypted auth-context secret storage.

PostgreSQL Backend

PostgreSQL is the recommended backend for production. It provides full ACID durability across all registry, receipt, health, trust, audit, and auth-context tables, and is required for encrypted secret broker storage.
1

Start a PostgreSQL instance

You can use any PostgreSQL 14+ server. For local development, the included Docker Compose file starts one for you.
2

Generate a secret broker key

The PostgreSQL backend requires a 32-byte base64-encoded encryption key for auth-context secrets:
3

Start the node with PostgreSQL config

Docker Compose

The included docker-compose.yml wires up a PostgreSQL 16 container alongside the ServiceNet node. Use it as a reference for your own deployment:
Start the full stack with:
Replace <your-generated-key> with a real key generated by openssl rand -base64 32. Do not commit a real key to source control — inject it via your secrets manager or a .env file excluded from version control.

Running PostgreSQL Integration Tests

To run the integration test suite against a local PostgreSQL instance:
PostgreSQL mode automatically enables provider ownership challenges (SERVICENET_REQUIRE_PROVIDER_OWNERSHIP_CHALLENGES=1). Auth-context secret storage is only available in PostgreSQL mode and always requires SERVICENET_SECRET_BROKER_KEY.

Switching Backends

You can switch backends between restarts, but note:
  • In-memory → file or PostgreSQL: no migration needed; the node starts with an empty registry in the new backend.
  • File → PostgreSQL: existing JSON file data is not automatically migrated to PostgreSQL. You must re-register providers and agents against the new backend.
  • PostgreSQL → file or in-memory: existing PostgreSQL data is not accessible from the other backends.
For all production deployments, choose PostgreSQL from the start to avoid data migration.