Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Cluster of uWeboscket.js#214

Answeredbyghost
emdotem asked this question inQ&A
Oct 23, 2019· 6 comments· 3 replies
Discussion options

Is it possible to have multiple instances of the server and make sure the communication among sockets connected to different instance works?

I'm thinking about having a message broker in the middle for communication

You must be logged in to vote
Answered by ghostOct 26, 2019

You can scale with multiple instances, yes. Either listen to the same port (Linux only) or listen to a set of ports which are then proxied or whatever. You can also scale using DNS, etc.

Replies: 6 comments 3 replies

Comment options

i use nats for that, works well

You must be logged in to vote
0 replies
Comment options

You can scale with multiple instances, yes. Either listen to the same port (Linux only) or listen to a set of ports which are then proxied or whatever. You can also scale using DNS, etc.

You must be logged in to vote
0 replies
Answer selected
Comment options

@emdotem It is works only in Linux, just addNODE_CLUSTER_SCHED_POLICY=rr as ENV to be sure everything will work as expected. And works so fast, i checked

You must be logged in to vote
0 replies
Comment options

NODE_CLUSTER_SCHED_POLICY does not affect uws

You must be logged in to vote
0 replies
Comment options

Sorry to comment this closed issue, I hope you will see it but when you talk about cluster you mean the nodejs cluster modulehttps://nodejs.org/docs/latest/api/cluster.html ?

You must be logged in to vote
0 replies
Comment options

It doesn't matter. I'm pretty sure Workers works also. Or just start separate processes altogether. None of it matters, it is the Linux kernel which does the load balancing. Or use a proxy it doesn't matter

You must be logged in to vote
3 replies
@kuabhish
Comment options

hello
if i start a separate peocess how would we be able to communicate between connections in different process.

if we use a proxy then event loop of the proxy will wait i think so latency wont improve.. please tell me if m wrong

@ezioda004
Comment options

@kuabhish By using a message broker like redis, rabbitmq, or if you're running multiple uws process in the same host using node cluster then you can do IPC.

@johnsonfash
Comment options

@kuabhish By using a message broker like redis, rabbitmq, or if you're running multiple uws process in the same host using node cluster then you can do IPC.

How do i communicate with different process using IPC. the way i do it is using ws with Map() and thats when you have one instance running.

With works, i belive you have one instance but the others ie load are running with all the cores but they share same truth so

const users = new Map<UWSConnection>()

might work, but how to go about this is unknown

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
7 participants
@emdotem@dioptre@dalisoft@yovanoc@kuabhish@ezioda004@johnsonfash
Converted from issue

This discussion was converted from issue #214 on December 09, 2020 05:50.


[8]ページ先頭

©2009-2025 Movatter.jp