Cloudflare Workers review for APIs that run at the edge

Cloudflare Workers review for APIs that run at the edge

Dreamstack Team
Dreamstack Team
· 5 min read

Disclosure: Dreamstack offers competing cloud hosting. This AI-assisted review evaluates provider documentation and published pricing. The last-seat example was tested locally with Miniflare. Pricing uses an illustrative workload.

A concert has one seat left. Thousands of people may look at its seating plan, but only one customer should receive a confirmation for that seat. Cloudflare Workers is an appealing place to serve the public reads. The quality of the deployment decision depends on what you do with the final write.

Workers runs request handlers on Cloudflare’s network. It suits an API that does a modest amount of computation, waits on other services, and returns a fairly small response. Its pricing and storage choices make more sense when the public schedule and the reservation are treated as separate operations.

The schedule can be a little stale. The reservation cannot.

Workers KV is useful for heavily read information such as venue descriptions or a published seating chart. Its reads may be cached in different locations. After an update, another location can continue seeing an older value for 60 seconds or more. A read of “one seat remaining” is therefore a poor basis for confirming that the last seat belongs to a particular shopper. How Workers KV handles reads and writes

One design is to route reservation attempts for a given performance to the same Durable Object. Its attached storage is strongly consistent and supports transactions. Put the availability check and reservation write into one atomic operation. Store a request identifier with the result so that retrying after a lost response returns the original decision. You could also keep an existing transactional database as the authority if it already owns inventory. Durable Object identity and storage

The design has a cost of its own. One extraordinarily popular performance can concentrate work on one object. Dividing responsibility by performance helps across different shows. Splitting one show by seat block makes operations such as “reserve four adjacent seats” more complicated. Send a concentrated burst to one popular show as a separate load test.

A worked Workers bill for the read path

On the published Workers Paid Standard model, the base subscription is $5 a month and includes 10 million requests and 30 million CPU milliseconds. Additional million requests cost $0.30 and additional million CPU milliseconds cost $0.02. Assume the billing account has no other Workers usage. Workers pricing

Illustrative monthly API trafficCalculation
12 million dynamic requests at 4 ms of CPU each48 million CPU ms
Requests above the allowance2 million × $0.30 = $0.60
CPU above the allowance18 million ms × $0.02 per million = $0.36
Base plus these two overages$5.96

That figure covers the Worker request and CPU lines in this example. KV operations, Durable Objects, origin services, and other products have their own charges. Waiting for an upstream response doesn’t count as active CPU time. It still affects what a customer experiences. Asset requests served directly as static assets also follow different billing rules from requests that invoke the Worker. CPU and runtime limits · Static asset billing

What happened in a local last-seat test

We used Miniflare, Cloudflare’s local Workers simulator, to give each test performance its own SQLite-backed Durable Object. Inside one storage transaction, the handler looked up the seat, inserted the request ID if it was available, and returned the existing decision on a repeat request. For each of ten performances we sent two concurrent requests with different IDs, then retried the winner. All ten trials produced one reservation, one rejection, and the original confirmation on retry. This checked the handler’s logic locally. Regional latency and throughput still need a hosted trial. Cloudflare’s local simulation documentation

Workers belongs on the shortlist for a read-heavy API like this one. Before choosing it for the reservation path, time a cold and a cached schedule lookup from your users’ regions, then put a burst against a single performance. Your customers will notice both the wait for the seating plan and whether the ticket you promised really exists.

Top comments (0)

❤️ 0
🦄 0
🔥 0
🙌 0