Multiple workers vs 1 worker with routes

Complete beginner question, but is there an advantage to using multiple workers as opposed to just one worker with routes (using something like itty router)? When does it make sense to use one use case over the other?
3 Replies
pavi2410
pavi241016mo ago
I also had the same dilemma. Eventually, I just figured out that if exceed the 1MB upload limit. I have to split the routes into multiple workers, otherwise, a single worker works fine.
James
James16mo ago
At a certain size it can make sense to split for maintainability. The micro-frontend architecture follows this kind of mentality: https://blog.cloudflare.com/better-micro-frontends/ My personal recommendation would be to stick with a single worker and something like itty-router or Hono until you find a need to create multiple.
Tin Cap
Tin Cap15mo ago
I've wrestled with the same dilemma. I decided to split into different workers where the functions are very different. I don't want to break functionality A when deploying functionality in B. This has actually been pretty handy in a scenario when I needed backend functionality using a library that doesn't support ESM (lame I know) because I could just use service worker syntax for that worker.
Want results from more Discord servers?
Add your server