How to split big worker into smaller ones to minimize startup time?

Hi all! we've hit a limit recently "- Error: Script startup exceeded CPU time limit. [code: 10021]" when trying to deploy our API worker. https://github.com/AsyncStatus/asyncstatus/tree/main/apps/api. Deploy and commit that introduced this issue https://github.com/AsyncStatus/asyncstatus/actions/runs/17192217490 Deploy and commit that fixed this issue https://github.com/AsyncStatus/asyncstatus/actions/runs/17192500191 (but we would like to add more and more code so it's not really representative but you get the idea). You can see it does a lot of things in just one index.ts (apps/api/src/index.ts) like exporting workflows, durable objects, scheduled handlers, queues and normal handlers (we have API and webhook handlers too). Not sure how to ask this question but I guess to avoid startup time limit error we could split this one worker by the function? Meaning one worker for exporting workflows, one for durable objects, one for "normal" handlers, one for queues etc... Or maybe split by domain? So we'd have like status-update-api or organization-api apps? Or maybe we should just fill out the form to increase startup limit? But we're a small startup so we wouldn't be able to pay +$100 for this request. Also cpuprofile file generated by wrangler check startup is not really useful, it would be great to have more human friendly output. Thank you, Kacper
GitHub
feat: send linear activity · AsyncStatus/asyncstatus@fa4c2af
Async status updates for remote startups. Contribute to AsyncStatus/asyncstatus development by creating an account on GitHub.
GitHub
chore: remove unused handlers · AsyncStatus/asyncstatus@3db5bda
Async status updates for remote startups. Contribute to AsyncStatus/asyncstatus development by creating an account on GitHub.
No description
1 Reply
kacper
kacperOP3mo ago
Looking at it again it seems strange, almost non-deterministic? I didn't change anything in the API but the deploy failed either way here https://github.com/AsyncStatus/asyncstatus/actions/runs/17192874129. When I did remove some unused imports https://github.com/AsyncStatus/asyncstatus/actions/runs/17192936918 it got deployed (API), strange
GitHub
chore: delete unused · AsyncStatus/asyncstatus@0002236
Async status updates for remote startups. Contribute to AsyncStatus/asyncstatus development by creating an account on GitHub.

Did you find this page helpful?