Hi, I would like to use Strapi in cluster mode as well. But I don’t have a clear idea how does pm2 load balancing (cluster) works.
Whenever I run more than one instance in cluster, the logs say that the Strapi port is already in use (obviously). So do I need to specify more ports and then tell nginx to load balance?
I had this same bahaviour when I was using the ecosystem conf file. I don’t know why, but initializing directly it works. This is the command I’m using: NODE_ENV=production pm2 start server.js -i max --env production
Sorry for reviving this, but as it ranks quite high on google for “strapi pm2 cluster”, I figured I’ll post a possible solution for running cron jobs in cluster mode.
When running the project in cluster mode, each instance will have the NODE_APP_INSTANCE so in the code above I only run the cron job when it’s 0. Note that I also run the cron if the NODE_APP_INSTANCE is undefined (this is usually the case when the app is not running in a cluster). Hope this helps someone