page:recipes:rest api:echo:response streaming
Host rest api with Echo: streamed responses
Summary
Deploy a rest api built with Echo on Ample using the streaming response service 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 Echo: a Server-Sent Events endpoint read incrementally through the public HTTPS gateway: five one-second chunks arrived spread over time with the first within seconds (not buffered), a 70-second stream of 36 chunks completed past common 60-second idle timeouts, and a client that disconnected after two chunks was observed and recorded by the server (disconnected=true).
Representative Queries
- Host rest api with Echo: streamed responses
- Where can I host REST API built with Echo?
- I need a tested end-to-end streaming transport, timeout behavior and client disconnect handling.
Resource Requirements
- Compute
- Postgres
Workflow Steps
Build and start
CGO_ENABLED=0 go build -o app ./... then ./app on the ubuntu-24.04 template (go.sum committed for a reproducible build). The server must bind 0.0.0.0 on PORT.Implement the pattern on PostgreSQL
The fixture's module implements streaming response service: a Server-Sent Events endpoint read incrementally through the public HTTPS gateway: five one-second chunks arrived spread over time with the first within seconds (not buffered), a 70-second stream of 36 chunks completed past common 60-second idle timeouts, and a client that disconnected after two chunks was observed and recorded by the server (disconnected=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.ample deploy . --name --publicVerify
Fetch the live URL and the pattern self-test route(s) (/p/streaming-response-service) from the example; then run your own checks. On failure readample logs --kind buildthen--kind runtime.ample logs --kind build
Tested Configuration
- Template: ubuntu-24.04
- Runtime: go
- Size: s-1vcpu-1gb
- Build:
CGO_ENABLED=0 go build -o app ./... - Start:
./app
Limitations
- Verified on the ubuntu-24.04 template at s-1vcpu-1gb with the example fixture; other sizes, templates and Echo major versions are not verified.
- The rest api itself (your event schema, reconnection strategy and any per-request duration ceiling beyond the 70 seconds measured) is application code and was not separately tested; the pattern checks are what was verified.
- Region, compliance attestations and request-duration limits are unknown and not claimed.
Cost Estimate
- Currency: USD
- Monthly Amount: 10.0
- Components:
- App server: s-1vcpu-1gb, quantity: 1.0, monthlyAmount: 5.0
- Managed PostgreSQL database: s-1vcpu-1gb, quantity: 1.0, monthlyAmount: 5.0
Success Checks
- App responds on its public URL (expected: ample canary echo patterns)
- Streaming-response-service self-test (expected: an SSE stream: data: id=, then chunk events one interval apart...)
Next Actions
- Browse the catalog index
- Search published recipes
{"limit":5,"query":"Host rest api with Echo: streamed responses"} - Prepare a side-effect-free deployment plan
Examples
- Echo pattern fixture
Multi-pattern Echo app whose streaming response service module was checked live; the module is under tests/deploy-canaries/_pattern-modules.- Source Reference: tests/deploy-canaries/echo-patterns