Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Built-in clustering mode (automatic / flagged) #3672

Closed
waqasmughal opened this issue Nov 5, 2015 · 5 comments
Closed

Built-in clustering mode (automatic / flagged) #3672

waqasmughal opened this issue Nov 5, 2015 · 5 comments
Labels
cluster Issues and PRs related to the cluster subsystem. feature request Issues that request new features to be added to Node.js.

Comments

@waqasmughal
Copy link

why not add built in clustering mode rather than manual . like node auto detect no of cpus and utilize all cpu cores . or better to integrate node-threads-a-gogo as core for hybrid app
https://github.com/xk/node-threads-a-gogo

@Trott Trott added the feature request Issues that request new features to be added to Node.js. label Nov 5, 2015
@mscdex mscdex added the cluster Issues and PRs related to the cluster subsystem. label Nov 5, 2015
@Fishrock123 Fishrock123 changed the title Feature Request Built-in clustering mode (automatic / flagged) Nov 5, 2015
@cjihrig
Copy link
Contributor

cjihrig commented Nov 9, 2015

@waqasmughal what do you envision this looking like? How would you distinguish between the cluster master and workers? I'm wary of introducing too much magic - cluster already does a lot of things under the hood.

Regarding workers, there is an initial PR to add them to core in #2133.

@Fishrock123
Copy link
Contributor

Would this be better as an npm module?

I think there's a larger thing behind this where adding what is most convenient / intuitive to core isn't necessarily what is good or sustainable for Node.js. :s

better docs?

@cjihrig
Copy link
Contributor

cjihrig commented Nov 9, 2015

What would you change in the docs? I don't think this would be a good thing to have in core, but wanted to hear @waqasmughal's thoughts first.

@waqasmughal
Copy link
Author

Hi ,
Thanks for your response . I am new to node.js .
what about if i have request which takes almost 10 sec to resolve and send back response after 10 sec . All remaining request are in queue and server would block even i have callbacks . the solution is parallel processing but that violate node behavior . If we create child process which deal only blocking part also resolve our problem but it's memory limitation issue .(like we have 10000 concurrent requests so 10000 process start ).

For Example
var http = require("http");
var url = require("url");

http.createServer(function(request, response) {

if (url.parse(request.url).pathname == '/long')
{
    function longlong()
    {
        var counter = 0;
        var startTime = new Date().getTime();
        while (new Date().getTime() < startTime + 10000)
        {
            counter++;
        }
        return counter;
    }

    response.writeHead(200, {"Content-Type": "text/plain"});
    response.write(longlong() + '');
    response.end();
}
else
{
  response.writeHead(200, {"Content-Type": "text/plain"});
  response.write(0 + '');
  response.end();
}

}).listen(8888);

@cjihrig
Copy link
Contributor

cjihrig commented Nov 9, 2015

Welcome to Node! We do just about everything asynchronously over here (meaning you don't need to spawn a bunch of server processes like you would in Java). Your long running task should be done asynchronously to avoid blocking your server. Built in clustering wouldn't really help here. The cluster module just spawns child processes, which you've already said isn't an option.

If you want help architecting your project, you might want to ask over at https://github.com/nodejs/help. I'm going to close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cluster Issues and PRs related to the cluster subsystem. feature request Issues that request new features to be added to Node.js.
Projects
None yet
Development

No branches or pull requests

5 participants