Coder Social home page Coder Social logo

Comments (15)

 avatar commented on May 3, 2024 11

I will keep that in mind anyways, there needs to be an example using the cluster feature.

from uwebsockets.js.

dalisoft avatar dalisoft commented on May 3, 2024 7

@alexhultman any news? i can't make it work, on linux too. on osx/macos too.
any example and/or guide here available?

from uwebsockets.js.

 avatar commented on May 3, 2024 1

Nope. Nothing Node.js-specific is going in here, this is its own server which just happens to work in Node.js. Probably it will work just fine though, there will definitely be support to move sockets over threads.

from uwebsockets.js.

 avatar commented on May 3, 2024

Yes ofc you can do that. How would it look like if a server only could use 1 thread in 2018? The graphs are single threaded to show that spent CPU time is equal for all software. You can, or will be able to, use Linux REUSE_PORT and similar.

from uwebsockets.js.

lukeed avatar lukeed commented on May 3, 2024

Are you planning to expose it thru native cluster module? Typical http clustering setup is here: https://nodejs.org/api/cluster.html#cluster_cluster

from uwebsockets.js.

lukeed avatar lukeed commented on May 3, 2024

Sounds good. It doesn't work as of now, but you're probably aware already πŸ˜€

Looking forward to this!

from uwebsockets.js.

 avatar commented on May 3, 2024

This looks like a problem - I guess cluster worked before because before uws was using the Node.js Http server which obviously works with the cluster module. You're just trading one hacky solution for another one really. Before it was very hacky to work with Node.js Http server and now it's hacky to work with cluster module.

Best would probably be to have a complete replacement or just skip this for Node.js

from uwebsockets.js.

 avatar commented on May 3, 2024

One possible solution is to use net.Server to listen and accept, and then import the FD to the uWS.App and have it do everything else.

That's kind of the same as old uws, but instead of using the HTTP server of Node.js it only makes use of the very minimal net.Server thing.

It will make it slower though, at least for short lived connections

from uwebsockets.js.

 avatar commented on May 3, 2024

Nope, not going to work

from uwebsockets.js.

 avatar commented on May 3, 2024

Technically, all you need to do really is to call Unix fork syscall in the listen callback. That would enable some kind of clustering. More work can be done to even the distribution and balan e connections but this fork call should be enough to have basic clustering. What Node.js does is some kind of non-Unix-Windows-compatible black magic hack that I simply cannot support. Standard Unix fork should do it (along with similar Unix features). Windows is what it is..

from uwebsockets.js.

 avatar commented on May 3, 2024

I'm pretty much sure V8 is properly compatible with Unix fork but Node.js itself might very well break I don't know

from uwebsockets.js.

 avatar commented on May 3, 2024

Well quick tests show that it is at least possible to have SOME kind of clustering with Node.js, all you need is SO_RESUSEPORT and it works decently actually. 120k up to 380k. It doesn't seem to be very round-robin ish though, but all instances gets loaded fully at least for this load test

from uwebsockets.js.

zorro-fr24 avatar zorro-fr24 commented on May 3, 2024

It doesn't seem to be very round-robin ish though, but all instances gets loaded fully at least for this load test

If you are still using Cluster in any capacity to achieve this, then by default node lets the OS decide how to route connections - you can change the behaviour with:

Cluster.schedulingPolicy = Cluster.SCHED_RR;

before forking.

from uwebsockets.js.

 avatar commented on May 3, 2024

https://nodejs.org/api/cluster.html#cluster_cluster_schedulingpolicy

Interesting. Round robin is possible to achieve with SO_REUSEPORT with just a few changes - currently it is undefined behavior. Very promising, then clustering will work at least on Linux which is the main platform anyways

from uwebsockets.js.

 avatar commented on May 3, 2024

I'm closing this, will be up to uSockets to solve. Will work nicely on Linux, other platforms might be supported at some point.

from uwebsockets.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.