Skip to main content

Cloudflare Workers can now accept inbound TCP and gRPC

· Do Minh Tuan · Business Hackers 🚀

Cloudflare Workers can now accept inbound TCP and gRPC

For about eight years, code on Cloudflare Workers had to speak HTTP. Cloudflare has now announced that Workers can accept inbound TCP connections through a new connect handler routed via Cloudflare Spectrum, with gRPC as the first officially supported protocol. Containers on Cloudflare can handle full-duplex gRPC in any language, and edge Workers support unary and server-streaming calls through built-in gRPC-web translation.

I have a mixed reaction. The HTTP rule always felt like a constraint until you tried to build something that genuinely needed a raw socket, at which point it felt like a wall. Removing it opens a category of workloads that had to live on a central server. It also opens a category of operational problems that HTTP kept away, and the announcement is more interested in the first than the second.

Why HTTP was the easy mode

An HTTP request is short and self-contained. It arrives, gets handled, and the connection can close. That is why serverless platforms could scale so aggressively: there was no long-lived state to place or move. TCP is the opposite. A connection stays open, either side can send at any time, and something has to own the session for its whole life.

That is the real change here. Cloudflare is now willing to hold connections open at the edge, in the hundreds of locations it runs. For some products that is the difference between a workable design and a compromise.

What it makes possible

Multiplayer games are the obvious case. A game needs a socket that stays open and pushes state as it changes, and polling an HTTP endpoint every second is a bad substitute. Live financial tickers are similar: you want a stream, not a request every time the price moves. IoT fleets also fit, because a device holding one connection and sending small messages is the natural pattern.

Before this, all of those went to a central cloud region, often on something like EC2, because that was where you could open a port and keep it open. Moving the endpoint to the edge means a player in Singapore connects to a nearby location instead of a data centre in another hemisphere. The gRPC part adds a smaller, binary wire format. The announcement claims payloads can be up to 70 percent smaller than JSON, which I would treat as a best case for the right schema rather than a general rule.

What I would check first

Long-lived connections are harder to operate than requests, and the difficulty does not vanish because the platform is managed. You need to reason about idle timeouts, reconnect storms after a deploy, and what happens when a phone loses signal mid-stream. Those are old problems, and the tooling at the edge is younger than the tooling in a data centre.

The billing model is the second thing I would model. Request-based systems charge per request, which is easy to reason about. Connection-based workloads charge for time and data, and a demo with ten connections tells you nothing about a thousand devices connected overnight. I would want a load test with realistic session lengths before committing.

State placement is the third. If a game room lives at one edge location and the player moves, or the location restarts, you need to know what happens to the session. Some of that is the platform's job. Some of it is yours. The boundary is worth understanding before the architecture is drawn, not after.

Schemas and connection lifecycles

If you adopt gRPC, start with the schema. Define the messages and services in a proto file, generate the client and server types from it, and treat that file as the contract. That is where the real benefit is, because a mismatch fails at build time rather than in production.

For a browser frontend, gRPC-web is the bridge, since browsers do not speak raw gRPC. Built-in translation on Workers removes the need to run your own proxy for the common cases, which is a meaningful simplification. I would still test streaming carefully, because proxy behaviour and browser support are where these setups usually get awkward.

Keep the lifecycle explicit. Timeouts, reconnect with backoff, and a rule for what happens to a slow client. HTTP let a lot of teams forget these. TCP will remind them. I would not put a payment path on this on day one.

If you are building a normal CRUD app, this changes nothing and you should keep using HTTP. If you are building something with a live connection, the edge just became a real option, and the latency argument is worth testing with your own users on your own networks. For a team in Vietnam building a real-time product for the region, terminating a socket nearby instead of far away is a visible difference, and it is cheap to measure with a stopwatch and a phone.

My honest view is that this is infrastructure news that will matter to a minority of teams and be ignored, correctly, by everyone else. The mistake would be adopting it because it is new. The opportunity is for the products that were previously stuck on a central server for one unavoidable reason: they now have a choice.

What I would watch is the first public postmortem about long-lived connections at the edge. Failover during a deployment and the behaviour of timeout defaults will tell you more about readiness than any launch post. That is the document I will be looking for in six months.

Written with AI assistance, reviewed and edited by Do Minh Tuan.