Open SuspiciousLookingOwl opened 3 years ago
Thank you for the suggestion! I will definitely implement this in a pull request. This is my first node.js app ever and I'm learning a TON of things, so I'm grateful you had a look over it, haha! I will have to look over the session issue too. I'll make sure to use the cores. :)
As stated on [Express.js Performance best Practices], it's recommended to use a process manager like PM2 or Strongloop. Using a process manager allows you to run your Node app in cluster mode, making use of multi cores on the server, auto restart if it crashes, and more.
I personally recommend PM2.
To use PM2:
npm i -g pm2
, optionally you can also add it to devDep (npm i -D pm2
)"start": "pm2 start server.js",
(orpm2 start server.js -i max
to run on cluster mode and create node processes as many as the available CPUs, orpm2 start server.js -i 2
to run 2 processes)EDIT: Since you are using stateful session (express-session) running the process on cluster mode won't work (it will work, but you will run into issue where user lost their session and have to login again), you can read more about it here