𝗡𝗼𝗱𝗲.𝗷𝘀 𝗔𝗽𝗽𝘀 𝗼𝗻 𝗮 𝟭𝗚𝗕 𝗩𝗣𝗦: 𝗧𝗵𝗲 𝗠𝗮𝘁𝗵
You use a $5 VPS. You want to know how many apps fit. Most guides skip the math. Here is the breakdown.
The OS and PM2 use RAM first.
- Ubuntu: 180MB
- PM2: 30MB
- Available for apps: 790MB
Memory under load matters most.
- Simple bots: 6 to 8 apps.
- REST APIs: 2 to 3 apps.
- Next.js SSR: 1 app.
- AI bots: 1 app with swap.
Settings matter. Use cluster mode for one API. Run 2 instances. Set a 350MB limit. Use fork mode for different projects. Run 1 instance each.
Three rules for stability:
- Create a swap file. It stops crashes during installs.
- Update to Node.js v20. It uses 20% less RAM.
- Watch RSS with pm2 monit. Fix leaks. Do not raise limits.
Quick guide:
- 1 API: Cluster mode, 2 instances, 350MB limit.
- 2 projects: Fork mode, 1 instance each, 250MB limit.
- 3+ bots: Fork mode, 120MB limit, add swap.
- Next.js: 1 app, or upgrade RAM.
Source: https://dev.to/vpsfordev/how-many-nodejs-apps-can-you-run-on-a-2-core-1gb-vps-with-pm2-the-math-ec4