Can Cloudflare Workers Cron Support a 65-Second Script Running Every 2 Minutes?

I have a Node.js script that I need to run periodically, and I'm considering using Cloudflare Workers with Cron Triggers. Here are the details of my use case: 1. Script execution time: 65 seconds 2. Desired frequency: Every 2 minutes 3. Script overview: - Makes multiple API calls - Processes and compares data - Writes results to a file I've reviewed the Cloudflare Workers documentation, but I'm unsure if my use case fits within the platform's limits. My main concerns are: - The 30-second CPU time limit mentioned for sub-hourly schedules - The overall 15-minute duration limit for Cron Triggers Key questions: 1. Can Cloudflare Workers Cron Triggers reliably support my script running every 2 minutes? 2. If possible, are there any adjustments I need to make to my script to fit within Workers' constraints?
8 Replies
mallets
mallets3mo ago
Your use case doesn't seem CPU bound, it likely spends most of that 65s waiting on http. Why not try it and check the stats.
cycle
cycleOP3mo ago
Just asking cause not used to setting up Workers. Not sure how long it takes to run this test
mallets
mallets3mo ago
The point is that the majority of that time won't count towards your CPU time. You can fetch a file over 5s but it counts it as no more than 1ms. Only you would know what the actual processing part entails in your script.
cycle
cycleOP3mo ago
My script makes approximately 70 HTTP GET requests sequentially: - Each request takes about 77 milliseconds to complete. - The size of each response is around 6.9 KB. - The total time to complete all 70 requests is roughly 40-65 seconds. Is that ok with Cloudflare Workers Cron Triggers on free plan?
mallets
mallets3mo ago
77ms request wait time or process time? If it's the latter, CF Workers is feasible. Not on free plan though, that is limited to 10ms CPU time.
cycle
cycleOP3mo ago
So when I make a HTTP Get request it takes 77 milliseconds for the JSON response to return Basically I send request and am waiting to get JSON back
mallets
mallets3mo ago
That's almost all processing time then. Almost 1s per request and only 0.1s is the http time. CF workers might not be the right platform for something CPU intensive, likely much cheaper to use something like AWS lambda. Your nodejs code will likely work as-is too, workers doesn't have perfect node support.
cycle
cycleOP3mo ago
ok thanks for going over this!
Want results from more Discord servers?
Add your server