page:recipes:graphql api:spring boot:persistent state
Host graphql api with Spring Boot: Postgres-backed state
Summary
Deploy a GraphQL API built with Spring Boot on Ample using the durable job state pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL. Verified on Spring Boot: a jobs table with a state and attempts counter, processing inside a row-locked transaction, and a second run that is a no-op (job=done attempts=1 idempotent=true). Not separately tested: your job types, payload schema and retry policy; treat the GraphQL API-specific behavior as your application code.
Representative Queries
- Host graphql api with Spring Boot: Postgres-backed state
- Where can I host GraphQL API built with Spring Boot?
- I need a durable state schema and retry/recovery semantics implemented by application code.
Resource Requirements
- Compute: The app runs in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- Postgres: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
Workflow Steps
- Build and start:
./mvnw -q -DskipTests package(or the Gradle wrapper) producing one application jar, thenjava -jaron the jvm-21 template (Temurin JDK 21) with server.port read from PORT. The server must bind 0.0.0.0 on PORT. - Implement the pattern on PostgreSQL: The fixture's module implements durable job state: a jobs table with a state and attempts counter, processing inside a row-locked transaction, and a second run that is a no-op (job=done attempts=1 idempotent=true). Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
- Deploy: Run the synchronous deploy once and read the result (exit 0 live, 1 failed, 2 blocked). Re-running with no change is a no-op. Command:
ample deploy . --name <name> --public - Verify: Fetch the live URL and the pattern self-test route(s) (/p/durable-job-state) from the example; then run your own checks. On failure read
ample logs <your_logs>.
Success Checks
- App responds on its public URL: HTTP GET to
/expectingample canary spring boot patterns. - Durable-job-state self-test: HTTP GET to
/p/durable-job-stateexpectingjob=done attempts=1 idempotent=true.
Limitations
- Verified on the jvm-21 template at s-1vcpu-2gb with the example fixture; other sizes, templates and Spring Boot major versions are not verified.
- The GraphQL API itself was not separately tested; the pattern checks are what was verified.
- Apps auto-pause when idle and wake on the next request; always-on is an operator setting, not a plan feature.
Cost Estimate
- Monthly Amount: $10.00
- Components:
- App Server: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: $5.00
- Managed PostgreSQL Database: s-1vcpu-1gb, Quantity: 1.0, Monthly Amount: $5.00
Examples
- Spring Boot pattern fixture: Multi-pattern Spring Boot app whose durable job state module was checked live; the module is under tests/deploy-canaries/_pattern-modules.
Last Verified At
Last verified on: 2026-09-21T02:34:39Z
Next Actions
- Browse the catalog index: GET
/v1/catalog - Search published recipes: POST
/v1/catalog/search - Prepare a deployment plan: POST
/v1/catalog/plan.