Where to Host a Long-Running AI Agent With WebSockets
The short answer
Use Cloudflare Durable Objects when each user, room or session is its own agent; use Fly.io or Railway when you want an ordinary long-running server with no time limits; use Netlify Server if your app already lives on Netlify and your agent runs fit inside its 30-minute (Pro: 2-hour) request window. Render is a solid alternative to Fly.io and Railway with WebSocket support on web services. Limits and prices were read from each vendor’s documentation on November 22, 2026.
The comparison
| Netlify Server | Cloudflare Durable Objects | Fly.io | Railway | Render | |
|---|---|---|---|---|---|
| Model | Long-lived Node.js process per instance | Stateful object per ID, with SQLite storage | Firecracker VM (“Machine”) | Container service | Web service / background worker |
| WebSockets | Yes; ~couple of hundred per instance | Yes, with hibernation API | Yes | Yes | Yes |
| Max request / connection | 30 min; 2 h on Pro, Business, Enterprise | No wall-clock cap on connections; CPU time per request is limited | None | None | Long-lived connections supported |
| Scale | Up to 3 instances (1 on Free/Personal) in Early Access | Millions of objects | Autostop/autostart, scale to zero | Replicas (Hobby 5, Pro 42) | Autoscaling on Pro |
| Cold start | Scales to zero after 5 min idle; 20 s to send headers | Milliseconds | Machine start on request | Sleeps on Free only | Paid instances stay up |
| Price | Free during Early Access; GA on GB-hour + vCPU-hour | Workers Paid $5/mo min; $0.15/M requests, $12.50/M GB-s | From $2.19/mo (256MB); $6.70/mo (1GB) | Hobby $5 min, Pro $20 min + per-second usage | Pro $25/mo + compute |
| Best for | Netlify sites adding an agent | Per-user agents, chat rooms | Always-on servers, any language | Fast deploys with databases | Teams wanting managed PaaS |
Why agents outgrow functions
An agent loop calls a model, waits seconds for it, calls a tool, waits again, and streams progress to the user the whole time. Netlify’s own launch post sums up the problem: a function spending ten seconds waiting on a model “occupies an entire instance for those ten seconds while doing almost nothing,” it cannot hold a WebSocket open, and state does not survive between invocations. A long-lived process serves many waiting requests from one event loop and keeps connection pools, caches and SDK clients warm.
Platform notes
Netlify Server (Early Access, launched November 10, 2026). A single entry file at netlify/server/index.ts — or an existing Express, Hono or Fastify app — becomes a server that deploys atomically with your frontend, with a server environment for every Deploy Preview. Instance sizes handle 32, 64 or 128 concurrent requests; open WebSocket connections are counted separately. Instances are replaced every 8 hours and get 90 seconds to drain on shutdown, and outbound connections close after 60 seconds idle — design clients to reconnect. Lifecycle hooks (onStart, onHealthCheck, onShutdown) let you warm up and drain job queues. It needs Netlify CLI 27.17.0 or later and a credit-based or Enterprise plan.
Cloudflare Durable Objects. Each object is a single-threaded actor with its own SQLite storage, addressed by ID — a natural home for “one agent per user”. Duration is billed in wall-clock time only while an object is active and not eligible to hibernate; with the WebSocket Hibernation API an idle connection costs nothing in compute, and incoming WebSocket messages are billed at a 20:1 ratio. Duration billing assumes 128MB per object. The Agents SDK builds on it — see best platforms for building and deploying AI agents.
Fly.io. Billed per second with no platform fee: $2.19 a month for a shared-cpu-1x 256MB Machine, $6.70 for 1GB, $13.39 for 2 CPUs and 2GB (Ashburn prices). Stopped Machines cost only $0.15 per GB of root filesystem, and autostop/autostart gives you scale to zero. Run Python, Go or anything in a container.
Railway. Pay per second for memory ($0.00000386 per GB-second) and CPU ($0.00000772 per vCPU-second), with the plan fee counting as usage credit. Hobby allows up to 48 vCPU and 48GB per service; Pro adds 42 replicas and a 99.99% availability target. Railway also sells isolated sandboxes for untrusted agent code.
Render. Web services accept inbound WebSockets and background workers suit queue-driven agents. Plans run Hobby $0, Pro $25 a month and Scale $499 a month, each plus compute.
Decision rule
- Per-user state, many concurrent sessions, edge latency: Cloudflare Durable Objects.
- Agent runs longer than 2 hours, or not in Node.js: Fly.io, Railway or Render.
- Frontend already on Netlify, Node.js backend, runs under 2 hours: Netlify Server — but note it is Early Access with a 3-instance cap and unannounced GA pricing.
- Durable multi-hour workflows that must survive restarts: add a durable execution engine — see best durable execution platforms for AI agents.
For streaming the agent’s output to the browser, see how to stream LLM responses: SSE vs WebSockets.
Last verified: November 22, 2026.