Skip to content
This repository has been archived by the owner. It is now read-only.

cluster: introduce `distribute` option #6004

Closed
wants to merge 1 commit into from
Closed

Conversation

@indutny
Copy link
Member

indutny commented Aug 6, 2013

distribute is a user-specified callback for asynchronous balancing of
incoming connections to cluster workers.

fix #6001

/cc @bnoordhuis @isaacs @kaero

if (once)
return;
once = true;
self.handles.push(handle);

This comment has been minimized.

Copy link
@indutny

indutny Aug 6, 2013

Author Member

There's a danger of handle being removed while waiting for user to invoke callback, I'll add code handling it later.

@isaacs
isaacs reviewed Aug 6, 2013
View changes
test/simple/test-cluster-distribute.js Outdated
distribute: function(callback) {
setTimeout(function() {
// Hand-off handles to the first two workers
var i = ~~(Math.random() * (workerCount - 1));

This comment has been minimized.

Copy link
@isaacs

isaacs Aug 6, 2013

Would be better to just switch back and forth, rather than using Math.random()

`distribute` is a user-specified callback for asynchronous balancing of
incoming connections to cluster workers.

fix #6001
@indutny

This comment has been minimized.

Copy link
Member Author

indutny commented Dec 10, 2013

That is a subject for 1.0, not going to the 0.12 because we're not sure about round-robin balancing.

@kaero

This comment has been minimized.

Copy link

kaero commented Dec 10, 2013

@indutny where can i find any discussion about «we're not sure about round-robin balancing»? I'm interested in subject :)

@indutny

This comment has been minimized.

Copy link
Member Author

indutny commented Dec 10, 2013

Haha, I understand your concerns. Let me describe it in detail.

The problem with this is that it relies on existence of balancing in node, and we're not sure that it'll stay here for a long time. Even if it'll stay - the method how it is performed may change or move to the C/C++ without changing public API for users.

But with this distribute API we won't be able to remove it or change it dramatically, because we'll be locked to provide the same methods to users.

I think best approach would be to test round-robin in 0.12 and pull this into the next release.

@kaero

This comment has been minimized.

Copy link

kaero commented Dec 10, 2013

@indutny o-o-okay, thanks for explanation!

@jasnell

This comment has been minimized.

Copy link
Member

jasnell commented Aug 3, 2015

@indutny ... any further progress on this one? Is this still needed?

@indutny

This comment has been minimized.

Copy link
Member Author

indutny commented Aug 3, 2015

cc @kaero ?

@kaero

This comment has been minimized.

Copy link

kaero commented Aug 4, 2015

Requests distribution problem is still here, but for a long time we successfully use dual-layer load balancing. RR at proxy level (nginx/haproxy/...) is used to distribute requests between small groups of workers and on node.js level, we just use default behavior – it works fine.
Dynamic RR between single node.js workers at proxy level is works well too.
So maybe it's not a node.js problem, to provide such a method. ¯\_(ツ)_/¯

@jasnell

This comment has been minimized.

Copy link
Member

jasnell commented Aug 4, 2015

Ok. With that in mind then, I'm going to close this. We can revisit if anything thinks having this in core is necessary.

@jasnell jasnell closed this Aug 4, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.