Why such high CPU times?

Here’s a sampling of my Cloudflare workers:

Ironically, the lightest one (2.3 KB) has by the far the highest median CPU time of 162.9 ms. That doesn’t look right. The only thing I can think of is this worker uses crypto.subtle.encrypt() to return some AES-GCM encrypted strings – is it normal for encryption to be this expensive?

Hi, thanks for the great response! I will look into caching some of the encrypted strings.

If you’re encrypting multiple items, consider batching them together to reduce the overhead of encryption calls.

Could you please provide some guidance on how to batch them? I looked on MDN but couldn’t find anything related to batch-encrypting strings.

UPDATE: After implementing caching with a 3600 TTL, my worker’s CPU time dropped dramatically…

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.