Imagine a large node.js app with a multi-purpose api for mobile and frontend with a serving static files, with a websocket server, lot of cron jobs and workers. Basically I can horizontally or vertically scale a whole app, use a load balancer and so on.
But from a perspective of a business logic, whole app is one big "bundle" where some parts are used more than others, also some parts have bigger impact on a performance of app than another. For example, mobile API may be used 100x more than some cron which starts 1 time per hour to make some cleanup. So is it necessary to scale whole app?
Isn't it better to scale app to separate modules and scale only needed? For example
- mobile api
- FE api
- crons and workers
- websocket
- whatever...
If so, what is proper way to handle business logic? There is a parts of code I would need in every submodule of application, for example database models, migrations (seeders?), maybe I would need some general functionality, like some specific utils functions or enum definitions. So I can create git submodules for them, but there is risk it will be too much complex to handle 4-6 git repositories with a 2-4 git submodules and handle whole app in multiple environments (dev, stage, uat, prod). Are there some others caveats of this approach? Or is it unusable?
I dived into waters of internet and searched for some resources for example node.js best practice, scaling node.js, scaling node.js, good scaling practice but it not fully answered all my questions.