
Cloudflare Workers
Cloudflare Workers is a service that lets developers run small programs directly in the worldwide distributed data centers of the company Cloudflare. The code starts right where the visitor happens to be, which is why it responds very quickly.
When you visit a website, some computer somewhere in the world has to process your request and send back a response. Such computers sit in large halls full of technology, which are called data centers. The company Cloudflare operates hundreds of such locations, spread across almost every country. Cloudflare Workers is an offering from this company: programmers upload a small program, and Cloudflare runs it in all of these locations simultaneously. Your request is then handled by the location that is geographically closest to you. This means you no longer need to rent and maintain your own server.
Why short distances on the network matter so much
Data travels through cables, and even light takes time to do so. A request from Berlin to California and back takes roughly 150 milliseconds. That sounds tiny, but a modern website often makes dozens of such requests in a row. A few milliseconds thus add up to noticeable waiting times. If the program runs in Frankfurt instead, the travel time drops to just a few milliseconds.
The second reason is effort. In the past, putting an application online meant choosing a server, setting up an operating system, and installing security updates. With Workers, all of that is eliminated. You write the code, hit publish, and the service takes care of everything else. Experts call this principle serverless, even though servers are of course still involved.
For companies, the billing model is also interesting. You pay per call and per unit of compute time used, not per rented machine. An application with no visitors then costs almost nothing. In the event of a sudden surge of visitors, the system scales up automatically, without anyone having to intervene.
Isolates instead of a dedicated machine
Classic cloud services start a kind of virtual computer for each program. That requires memory and often takes half a second or longer to start up. Workers takes a different approach. The code runs in so-called isolates, small sealed-off spaces within a single programming environment. This environment is called V8 and is the same one that runs JavaScript in the Chrome browser.
A comparison helps: a virtual computer is like an entire single-family house that gets built anew for every guest. An isolate is more like a lockable room in an existing building. The building is already standing, and the room is ready to move into in under a millisecond. That’s why Workers barely suffers from the delay on the first call that plagues other serverless services.
This design has a price. A Worker is only allowed to use limited compute time and memory per request. Long, computation-heavy tasks don’t fit within it. Also, the code doesn’t run in a normal server environment, but in its own, browser-like one. Some existing program libraries therefore don’t work without adjustments.
Where Workers shows up in the web and in AI products
Many users have already interacted with Workers without noticing it. The service is often used for login checks, redirects, A/B tests, or caching content. Entire websites and programming interfaces run on it too. To go along with this, Cloudflare offers matching storage options, such as a database called D1 and a file storage service called R2.
In recent years, an AI connection has been added. Under the name Workers AI, you can call AI models from within a Worker that compute in the very same data centers. Such requests to an already-trained model are called inference. Small chatbots or translation features can thus be run without owning any graphics cards.
In business news, Workers usually comes up in the context of competition with Amazon, Microsoft, and Google. Their competing products are called Lambda at Amazon and Cloud Run Functions at Google. Cloudflare’s argument is proximity to the user, since its own network is already everywhere anyway. When you read the term edge computing, this is exactly the idea being referred to: computing at the edge of the network, close to the people.