linnovate / meanio

meanio core module
MIT License
54 stars 73 forks source link

Add socket.io with multiple cluster's support #93

Closed bertho-zero closed 8 years ago

bertho-zero commented 8 years ago

For activate socket.io compatibility in production mode, or with multiple clusters, set clusterSticky to true in your config file.

haduythuan commented 8 years ago

Hi @bertho-zero ,

I had applied your solution but I got an error "Assertion failed: ((consumed_) == (false)), function Consume, file ../src/stream_base.h, line 203." Then workers went die.

Did you get the same issue?

timelf123 commented 8 years ago

@haduythuan people have similar issues here, might want to subscribe for a fix: https://github.com/nodejs/node/issues/3072

timelf123 commented 8 years ago

This fix worked for me, thanks!

emps commented 8 years ago

@bertho-zero hii friend, nice work but u must add count of cpu - 1 in sticky options cause in this way it is running extra cluster, cause as u run gulp it runs mean.serve that runs sticky all cpu cores so it is result with x cores + 1 so easy way to fix this i suggest to use sticky options

in ExpressEngine.js

let cpuCount = require('os').cpus().length,
stickyOptions = {
        num: cpuCount - 1
};

and replace both lines of sticky with

sticky(stickyOptions, http*

but this is type of cosmetic fix for this problem cause here are 1master cluster + cpu.count - 1 i will look for real solution

ps u can even notice that while stating up with production u see extra cluster worker id

timelf123 commented 8 years ago

@bertho-zero are you able to integrate these changes from @emps? If not I will re-roll this PR as it was essentially to get our app working in production on heroku

To take advantage of our already used CPU_COUNT env var, I'd do:

let cpuCount = process.env.CPU_COUNT || require('os').cpus().length,
stickyOptions = {
        num: cpuCount - 1
};
timelf123 commented 8 years ago

Thanks @bertho-zero and @emps this has landed in 0.6.X / master