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

[Question] Cluster support planned? #11

Open
asciidisco opened this issue Mar 13, 2018 · 12 comments
Open

[Question] Cluster support planned? #11

asciidisco opened this issue Mar 13, 2018 · 12 comments

Comments

@asciidisco
Copy link

Hi there.
First of all, turbo-net & turbo-http are amazing, thank you very much :)

If I´m not mistaken, turbo-http doesn't work in cluster mode yet, as it doesn't implement the same "behind the scenes magick" as the default http module does to "share" an open port.

I´ve just, very naively, tried to map the example from the docs 1:1 - https://nodejs.org/docs/latest/api/cluster.html

So, chances are high that I´m just doing something wrong here, but if not, I´d just simply ask if it is planned to implement cluster compat., or if I should go down the route of forking instances & using a traditional load balancer instead of cluster mode?

@jacktuck
Copy link

If I´m not mistaken, turbo-http doesn't work in cluster mode yet, as it doesn't implement the same "behind the scenes magick"

I think you're right here, just ran into this myself too. So +1

@mafintosh
Copy link
Owner

Yes turbo-net does not do any clustering. I'm not sure what's involved to get that working.

@asciidisco
Copy link
Author

@mafintosh Thank you for the answer, it´s not that critical, as I don't want to use it for a production product yet & I´m just toying around with it.

I´ll see if I can find some clues in the node sources, but I doubt that this is a trivial implementation.

@jacktuck
Copy link

haha @asciidisco i've been doing exactly that and... it's been quite the rabbit hole

e.g. https://github.com/nodejs/node/blob/212de3c5ec429a580d2e79ce3c2516b93b52b8f5/lib/_http_common.js#L264 😱

@asciidisco
Copy link
Author

The way it is implemented in node is quite understandable. It looks like one could create a separate package that could just wrap turbo-http and make it cluster-able.

If I´m not missing any important point, I´d say that if it can be done as a separate package, it should be done this way, as every implementation in turbo-http would have a performance impact of some sort, even if users wouldn't need the functionality.

Therefore I´m fine with closing this. If >1 instances are needed, people could still use the "classic" load balancer approach.

@jacktuck
Copy link

jacktuck commented Mar 13, 2018

@asciidisco

The way it is implemented in node is quite understandable

Can you give me synopsis of how node's doing it? I think your link relates to distributing workers onto 'random' ports rather than any kind of port sharing between the workers. Might be wrong though.

Yeah i also wonder what the performance hit would be

@asciidisco
Copy link
Author

@jacktuck It´s explained in the docs itself (better than I could ever do it): https://nodejs.org/api/cluster.html#cluster_how_it_works

@aichholzer
Copy link
Contributor

aichholzer commented Sep 4, 2018

If you need clustering, you can use @rayo/storm which will basically spawn your worker (server) function over all available CPU cores (you can also limit the number) and even give you a nice (still basic) cluster/worker monitoring service. 👏

Something along the lines of:

const rayo = require('rayo');
const turbo = require('turbo-http');
const server = turbo.createServer();

rayo({ port: 5050, server, storm: {} })
  .get('/', (req, res) => res.end('Thunderstruck by rayo, turbo and storm..!'))
  .start((address) => {
    console.log(`Up on port ${address.port}`);
  });

In this case rayo.js will, essentially, just provide the routing capabilities. Also, in this example, you don't need to require @rayo/storm since rayo already comes bundled with it, you just need to turn it on.

@jfrconley
Copy link

I submitted a pull request to turbo-net that enables cluster support.
mafintosh/turbo-net#16

@IonelLupu
Copy link

Hi. First of all, great work here.
Are there any updates on this?

@dalisoft
Copy link

dalisoft commented May 9, 2019

Any news?

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

No branches or pull requests

7 participants