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. But, I stopped because I feel like I am going about it the wrong way. For example:
Server 1
is on port 9300
Server 2
is on port 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
.
What I currently do
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.
Some questions
1) Wouldn't it be more appropiate to just have Server 2
send a message to Server 1
without publishing to redis
?
2) Server 2
doesn't keep a track of all the connected clients that Server 1
has, so it wouldn't be possible. 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. A user on Server 5
wants to send a private message to a user on 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? 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?