Running NodeBB on multi core CPU
-
I have a server with 8 cores/16 threads. I was going through the following article and it mentions introducing new port for every CPU core? Is it the only way to scale on CPU?
-
You could reserve a thread or two for your database, but besides that, yeah. Why?
-
Yeah, so run 8 workers and they all will serve requests. That's how nodejs works.
in nginx create records like this (i have 2 cores, so i am running 2 workers:
upstream nodebb { ip_hash; server unix:/sockets/nodebb.sock; server unix:/sockets/nodebb.1.sock; }
and then in "location" just use
proxy_pass http://nodebb;
Innodebb config json you can set several ports/sockets (sockets in my example, as they are way better and safe, then ports, just take care aboout proper access rights)
"port": ["/sockets/nodebb.sock", "/sockets/nodebb.1.sock"],
Voila, your nodebb installation uses all cores.
-
@smartpunter Thanks a ton.
I will try that.
-
@Raj said in Running NodeBB on multi core CPU:
I have a server with 8 cores/16 threads. I was going through the following article and it mentions introducing new port for every CPU core? Is it the only way to scale on CPU?
For the NodeBB process ITSELF, yes. It is single threaded, non-blocking. If you want it on another thread, you would run another instance.
-
@PitaJ said in Running NodeBB on multi core CPU:
You could reserve a thread or two for your database, but besides that, yeah. Why?
Yes, we do this. Couple cores for MongoDB. Couple cores for Nginx. A core for the OS. A core that does nothing but NodeBB. Scales to such a huge extent, no need for more cores!
-
@Raj said in Running NodeBB on multi core CPU:
@PitaJ Thanks. As I have 8 core CPU I want my NodeBB to use all of them. But by default NodeBB is using only one core!
Are you running your reverse proxy, SSL handling, or database on the same box? If so, you definitely don't want all of them for NodeBB.
Even if you aren't, why do you have so many cores, and what are you doing that makes you want to scale like this? How busy is your site? We've topped 191 million hits in a single month on a single core and aren't even working hard.