[英]Redis Pub/Sub Scaling
I've been rewriting my nodejs
game app to read memory from redis
so I could ultimately scale it if it were to ever grow large. 我已经重写我nodejs
游戏的应用程序从存储器中读取redis
,所以我可以最终扩展它,如果它是永远变大。 But, I stopped because I feel like I am going about it the wrong way. 但是,我停下了脚步,因为我觉得自己走错路了。 For example: 例如:
Server 1
is on port 9300 Server 1
位于端口9300上
Server 2
is on port 9301 Server 2
在端口9301上
Now, let's say a player from the Server 1
wants to send a private message
to a player that is on Server 2
. 现在,假设Server 1
的播放器想要向Server 2
上的播放器发送private message
。
Server 2
will send a publish signal to redis, and Server 1
will catch that signal as well, and if that user is on that server, it will send them a notification along with the message. Server 2
将向redis发送一个发布信号, Server 1
也将捕获该信号,如果该用户在该服务器上,它将向他们发送通知以及消息。
1) Wouldn't it be more appropiate to just have Server 2
send a message to Server 1
without publishing to redis
? 1) 仅将Server 2
发送消息到Server 1
而不发布到redis
是否更redis
?
2) Server 2
doesn't keep a track of all the connected clients that Server 1
has, so it wouldn't be possible. 2) Server 2
不会跟踪Server 1
拥有的所有已连接客户端,因此这是不可能的。 Unless, I keep track of all connected clients on every server aswell? 除非,我还要跟踪每台服务器上所有已连接的客户端? That would require the client to connect to multiple servers on each visit. 这将要求客户端每次访问都连接到多台服务器。
3) Let's say I have 10 servers. 3)假设我有10台服务器。 A user on Server 5
wants to send a private message to a user on Server 1
. Server 5
上的用户希望向Server 1
上的用户发送私人消息。 If I send a pub signal through redis
, Servers 4,6,7,8,9,2,3
will all receive that signal as well... which is unneeded? 如果我通过redis
发送发布信号,则Servers 4,6,7,8,9,2,3
也会全部收到该信号...这是不需要的吗? Is that when Peer to Peer connections come into play? 是点对点连接发挥作用吗? Or is that the extra bandwidth that is required for scaling and I'm overthinking everything? 还是扩展所需的额外带宽,而我却过分考虑了一切?
Perhaps you could change concept of your app by adding RabbitMQ instead of redis pub/sub. 也许您可以通过添加RabbitMQ而不是redis pub / sub来更改应用程序的概念。 RMQ would allow smarter message routing. RMQ将允许更智能的消息路由。
Basicly each user can listen its own messages: 基本上每个用户都可以收听自己的消息:
Still that concept will hit the limit if you get large number of users. 如果您拥有大量用户,那么该概念仍然会达到极限。 Connection count to RMQ server will grow intensivly. 与RMQ服务器的连接数将激增。 In that case you can scale RMQ or change connection concept: 在这种情况下,您可以扩展RMQ或更改连接概念:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.