worker state.md
Host ai chat application with Axum: worker execution and job state
Summary
Deploy a ai chat application built with Axum as a public web service plus a dedicated worker process on Ample. ample plan --write discovers both services and their shared database and writes ample.toml; ample up reconciles the topology: a managed PostgreSQL 16 database, a public web microVM and a private worker microVM (kind worker, no public URL), both reading DATABASE_URL. Verified on Axum: a separately deployed worker service (kind worker, no public URL) sharing a declared managed PostgreSQL database with the web service, consuming a jobs table with row locks and marking jobs done once (worker=done attempts=1). Not separately tested: your job payloads, retry policy and scheduling; treat the ai chat application-specific behavior as your application code.
Infrastructure requirements
- Confirmed isolated x86_64 Firecracker microVMs for computing.
- Verified managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when needed.
Prerequisites
- A repository with the web app and the worker as separate service directories.
- Both services read DATABASE_URL at runtime and share one jobs table.
- An Ample account token with servers:write and databases:write.
Exact tested configuration
- template:
ubuntu-24.04 - runtime:
rust - size:
s-1vcpu-2gb - build:
cargo build --release - start:
./$(ls target/release/*.d | grep -v '/lib' | head -n 1 | sed 's/\.d$//')
Steps
- Plan the topology. Run the planner once.
ample plan --write . - Share one database. Keep a single [databases.main] with engine = "postgres".
ample plan --offline . - Apply. Reconcile the manifest in dependency order.
ample up . - Verify. Fetch the web service URL and its worker status route.
ample logs <deployment_id> --kind runtime
Tested examples
- Axum web + worker fixture. A Axum web app and a worker process sharing one managed PostgreSQL database.
Success checks
- Web service responds on its public URL.
- Worker consumed the enqueued job.
Limitations
- Verified on the ubuntu-24.04 template at s-1vcpu-2gb for both services.
- The ai chat application’s behavior and specifics were not separately tested.
- The worker is a single long-running process with no horizontal scaling.
Cost estimate
Estimated 15.00 USD per month.
- web server x1
s-1vcpu-1gb: 5.00 USD - worker server x1
s-1vcpu-1gb: 5.00 USD - managed PostgreSQL database x1
s-1vcpu-1gb: 5.00 USD
Verification evidence
- canary_run on 2026-09-21T02:46:37Z: Axum web service plus a separate Axum worker process deployed on Ample.
Last verified: 2026-09-21T02:46:37Z
Execution binding
MCP tool ample_up, schema hash db7ca0facfe2cd28.