Comments (15)
I will keep that in mind anyways, there needs to be an example using the cluster feature.
from uwebsockets.js.
@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.
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.
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.
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.
Sounds good. It doesn't work as of now, but you're probably aware already π
Looking forward to this!
from uwebsockets.js.
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.
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.
Nope, not going to work
from uwebsockets.js.
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.
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.
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.
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.
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.
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)
- Allow for dynamically-generated certificates, keys, etc. HOT 1
- Parameter routes routing issue HOT 2
- There is a way to get the number of client connections from Node.js? HOT 2
- Consider queueing headers on `HttpResponse.setHeader` call HOT 3
- Underscores in HTTP header key silently drops request HOT 4
- H3App: segmentation fault HOT 1
- Setting idleTimeout to a big value crashes the process HOT 3
- How to reduce real-time audio and video stream forwarding delayοΌ HOT 4
- Windows binaries don't build
- WriteStatus function
- req.getQuery() is returning undefiend insteated of empty string HOT 2
- HttpRequest that survives past async functions HOT 19
- Auto compression for HTTP and use zstd HOT 2
- NODE_MODULE_VERSION 93 in:uNetworking/uWebSockets.js HOT 5
- uWebSockets.js can't be installed using npm install uNetworking/uWebSockets.js#v20.43.0 HOT 1
- U can setup base middleware system smth like this: HOT 1
- listen_unix no working
- HttpResponse onData method HOT 3
- security question: Can i disable `Uwebsockets` header? HOT 1
- node 22 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uwebsockets.js.