Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

cluster: Need a way to listen on a port *without* going through master #3856

Closed
isaacs opened this issue Aug 11, 2012 · 7 comments
Closed

cluster: Need a way to listen on a port *without* going through master #3856

isaacs opened this issue Aug 11, 2012 · 7 comments
Milestone

Comments

@isaacs
Copy link

isaacs commented Aug 11, 2012

Let's say you have 8 workers all listening on port 443 or port 80. Great.

Then, you have some sporadic bug. The bug report details show that it's on worker 5, and that worker is in some oddball state. The other workers are fine.

To try to reproduce the error, you have to have a way to make a request to the worker specifically. So, you can have the worker also listen on some specific port, like 10000 + worker.id, with the same connection listener.

However, it's a bit silly to have it request two handles from the master, when one of them is not shared with anything else.

@bnoordhuis
Copy link
Member

However, it's a bit silly to have it request two handles from the master, when one of them is not shared with anything else.

Is that really an issue?

@isaacs
Copy link
Author

isaacs commented Aug 12, 2012

Yes. I'm seeing some issues in production that went away when I made it only have a single server handle shared with the parent.

The problem is that the cluster master process seems to get confused about the worker's connected-ness status when it has two servers shared, and one of them closes. As a result, I had to call worker.disconnect() twice to get it to actually disconnect, and in the worker, even if I closed both servers, the master doesn't see it. It's a bit tricky to reproduce, so I'm still trying to track it down, but making the workers only share a single server made the problems go away.

This hacky workaround is suitable for now, but is pretty ugly:

// https://github.com/joyent/node/issues/3856
cluster.isWorker = false
cluster.isMaster = true
loneServer.listen(lonePort, function () {
  cluster.isMaster = false
  cluster.isWorker = true
  logger.info("Listening on %d", lonePort)
})

@bnoordhuis
Copy link
Member

As a result, I had to call worker.disconnect() twice to get it to actually disconnect, and in the worker, even if I closed both servers, the master doesn't see it.

Okay, so this issue is really a feature request and a bug report. :-)

@piscisaureus
Copy link

I agree that we need this. Didn't we sort of agree upon

server.listen({port: 1234, shared: false})

?
I seem to remember something like this.

@isaacs
Copy link
Author

isaacs commented Apr 10, 2013

@bnoordhuis This is that issue I said we already had when you brought this up yesterday.

Added to v0.12 milestone.

@rmg
Copy link

rmg commented Aug 15, 2014

I may be wrong, but I don't think this is still a candidate for 0.12, is it? Just trying to trim down the milestone.

trevnorris pushed a commit that referenced this issue Sep 3, 2014
Allow cluster workers to listen on exclusive ports for TCP and UDP,
instead of forcing all calls to go through the cluster master.

Fixes: #3856
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Fedor Indutny <fedor@indutny.com>
@trevnorris
Copy link

Fixed by 029cfc1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants