2.4 KiB
2.4 KiB
Containers patterns
Choose instance identity based on the workload: per-user/session or per-job identities for affinity, one shared identity for a singleton, and interchangeable instances for stateless requests. Read scaling and routing for current helpers and scaling behavior before implementing that choice.
| Task | Documentation |
|---|---|
| Distribute requests across stateless instances | Stateless instances example |
| Forward WebSocket connections | WebSocket example |
| React to lifecycle changes | Status hooks example |
| Handle shutdown and persist data across restarts | Container lifecycle and Container interface |
| Keep long operations active or schedule callbacks | Activity renewal and scheduling |
| Start containers on a cron schedule | Cron container example |
| Route requests to multiple ports | Request methods and utility functions |
| Access Workers bindings from the container | Connect to Workers and bindings |
Workflows and Queues
For multi-step orchestration, combine the Workflows Workers API with the Container API. For queue-driven jobs, read the Queues consumer API and acknowledgement and retry behavior alongside the Container API. These pages document the component APIs; they are not end-to-end Container integration examples.