Serve business and admin routes from one backend process
This commit is contained in:
@@ -8,27 +8,28 @@ Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has i
|
||||
|
||||
Notion describes sharding online PostgreSQL block data by workspace and feeding a downstream S3 data lake from PostgreSQL changes. Bedrock currently supports selecting a configured SQL cluster and using its read replicas. Workspace sharding, S3 object storage, and data-lake ingestion are future work. [Notion's PostgreSQL sharding](https://www.notion.com/blog/sharding-postgres-at-notion) · [Notion's data lake](https://www.notion.com/blog/building-and-scaling-notions-data-lake)
|
||||
|
||||
## Web backends
|
||||
## Web backend
|
||||
|
||||
The workspace has two independently started Axum services. Run the packages
|
||||
with `cargo run --locked -p backend` and `cargo run --locked -p admin_backend`
|
||||
in a development environment.
|
||||
Run the Axum service with `cargo run --locked -p backend`. One process owns
|
||||
the database connection, loads one deployment configuration, and serves
|
||||
separate routers on the business and optional admin listeners.
|
||||
|
||||
| Package | Listen setting and default | Routes |
|
||||
| Listener | Setting and default | Routes |
|
||||
|---|---|---|
|
||||
| `backend` | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` |
|
||||
| `admin_backend` | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status` |
|
||||
| Business | `BEDROCK_BACKEND_LISTEN`, default `127.0.0.1:8080` | `GET /healthz`, `GET /readyz` |
|
||||
| Admin | `BEDROCK_ADMIN_LISTEN`, default `127.0.0.1:8081` when enabled | `GET /healthz`, `GET /readyz`, `GET /admin/v1/status` |
|
||||
|
||||
Both services use the `BEDROCK_DB_CONFIG` setting described below. The business
|
||||
service opens storage at startup and verifies access to the current deployment
|
||||
revision in its readiness handler. The admin service resolves the deployment
|
||||
configuration at startup. Its status endpoint reports the configured deployment,
|
||||
storage driver, read-only mode, and optional `BEDROCK_CONFIG_VERSION`.
|
||||
The business readiness probe checks access to the current deployment revision.
|
||||
Set `BEDROCK_ADMIN_TOKEN` from a private credential source to enable the admin
|
||||
listener. Send it as `Authorization: Bearer <token>` for the status endpoint.
|
||||
Keep the admin listener on loopback or behind an internal TLS endpoint.
|
||||
|
||||
Set `BEDROCK_ADMIN_TOKEN` from a private credential source before starting
|
||||
`admin_backend`. Send it as `Authorization: Bearer <token>` for the status
|
||||
endpoint. Keep the admin listener on loopback or behind an internal TLS endpoint.
|
||||
The root `bedrock` binary remains the one-shot storage initializer.
|
||||
The `admin_backend` library reports the deployment, storage driver, read-only
|
||||
mode, and optional `BEDROCK_CONFIG_VERSION` for the instance that served the
|
||||
request. It reads the same resolved configuration that the process used to open
|
||||
the database. Give every replica the same config file and version label through
|
||||
your deployment process. The root `bedrock` binary remains the one-shot storage
|
||||
initializer.
|
||||
|
||||
## Database configuration
|
||||
|
||||
|
||||
Reference in New Issue
Block a user