NodeBB / NodeBB

Node.js based forum software built for the modern web
https://nodebb.org
GNU General Public License v3.0
14.11k stars 2.78k forks source link

NodeBB multi-core support #1983

Closed paralin closed 9 years ago

paralin commented 10 years ago

Hi,

Currently on my 8 core server NodeBB is just using one, this is highly inefficient, is there any way to setup NodeBB to use multiple cores using the cluster package perhaps?

Thanks

--- Want to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/3686033-nodebb-multi-core-support?utm_campaign=plugin&utm_content=tracker%2F282529&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F282529&utm_medium=issues&utm_source=github).
julianlam commented 10 years ago

Hi there @kidovate -- multi-core support is on the list of things we want for v0.6.0 :smile:

julianlam commented 10 years ago

In the meantime, you can try running NodeBB with pm2? That'll auto-scale it up to 8 processes for you (with the proper flags, that is... by default, it starts 1 proc)

paralin commented 10 years ago

Hi,

I've not used it, can you give me an example?

Thanks!

On Tue, Aug 12, 2014 at 9:31 AM, Julian Lam notifications@github.com wrote:

In the meantime, you can try running NodeBB with pm2? That'll auto-scale it up to 8 processes for you (with the proper flags, that is... by default, it starts 1 proc)

Reply to this email directly or view it on GitHub https://github.com/NodeBB/NodeBB/issues/1983#issuecomment-51939808.

julianlam commented 10 years ago

I believe it is: pm2 start app.js -i max

Keep in mind, this starts the NodeBB APPLICATION as many times as there are cores. Don't do this on loader.js, that's the process that kickstarts the application, and where we'd probably build our own tool to start additional processes.

jmordica commented 10 years ago

currently using pm2 (8 processes on an 8 core server) works but only for non socket calls. Chat messages don't appear and the connection shows to constantly be lost and re established (from the browser) very rapidly.

Any help on this?

barisusakli commented 10 years ago

Check out this branch https://github.com/NodeBB/NodeBB/tree/cluster

The constant reconnection was fixed with using a RedisStore here

Although some of the realtime functionality is still not working 100% this is because of the function we use to get connected clients namely io.sockets.clients(). This only returns sockets that are connected to that particular worker. And since some of the features in nodebb rely on this to return all connected clients they don't work if the users are sending socket requests to different workers.

We will have to refactor those parts to not use io.sockets.clients(). It might be a good idea to update to socket.io 1.0.6 as well.

julianlam commented 10 years ago

For Mongo installs, I'm assuming there's a MongoStore you can use with socket.io?

barisusakli commented 10 years ago

https://github.com/deedw/mong.socket.io

julianlam commented 10 years ago

Milestone of the cluster branch is now set to 0.5.1. Not merged into that branch yet.

At present refactoring the loader in order to attain feature parity.