Using workers for a REST API a good idea?

The use case is basically receiving requests, querying a DB, interacting with KV, and parsing JSON in and out.

In principle it sounds like most of the time workers would be waiting for the network which shouldn’t count on execution time. Although I’m worried about JSON encoding/decoding.

How big will an HTTP request be before hitting the CPU time limit?

50ms CPU works fine for 2MB JSON, this is my experience in production.

2 Likes

Woah 2MB is a lot.

What about file uploads? Is it possible to use streams to upload a file to some cloud storage service or into a KV?

I can confirm, 2MB works, but depending on how you use it, it might run out.

I’ve tried using a JSON search index and it works up to 1.5MB, even when combining filters.

1 Like