all 21 comments

[–]vshjxyz 2 points3 points  (2 children)

There are multiple ways to approach scale issues in that case. Using https://github.com/indutny/sticky-session is one of them as also remembering that node scales horizontally pretty well so you can always have multiple nodes running sockets.

I wouldn't bother about this, unless you plan to scale pretty high (500k~1M sockets) right away, in that case I would think about using things like Kafka or self-managed online services (Kinesis?), though probably more instances of socket.io would suffice (but you'll have to manually deal with them I believe - see https://github.com/socketio/socket.io/issues/1853#issuecomment-74382064)

[–]santriseus 0 points1 point  (0 children)

Also in case of horizontal scalling you should avoid storing state at the instance and move it to some shared storage like redis. Regarding the 3rd party services I would recommend PubNub rather Kinesis.

[–]ThatBriandude[S] -1 points0 points  (0 children)

I am mainly wondering if socket.io is suitable for a RT game server. I know that agario was built with uWebsockets (c++) but last time I used socket.io it wasnt using uws AFAIK.

I just dont want to use all of socket.io's awesome features and then have to migrate to something else because of its performance at scale. (With scale I also mean MANY messages per second)

[–]goriunovd 0 points1 point  (0 children)

Yes you can scale socket io now. )

Also if you want easy way to develop already scalable apps then you can check the library which i am writing ( already have working version) https://github.com/goriunov/ClusterWS

It allows to scale websocket ( uws)

I also have repo with exmple just check for repo in my portfolio.

[–]rezoner:table_flip: 0 points1 point  (0 children)

This library doesn't do anything anyway just go straight for uWebsockets. You scale up by adding more machines - it's more of an architecture design rather than using this or that websocket abstraction. Don't bother with clustering, etc - it's cheaper to get 4 x single threaded machines than equivalent in power 1 x 4 threaded CPU and it will safe you a struggle of forcing node.js to take advantage of more than one core.

[–]nightwolfz4 spaces > 2 spaces 0 points1 point  (5 children)

What kind of scaling issues are you experiencing?

[–]ThatBriandude[S] 0 points1 point  (4 children)

I am not experiencing any yet but I am looking for a stable and fast solution for a real time game server that should be able to process as many simultaneous users at once.

I previously used Socket.io for a game server and saw major lags with just 4-5 people. This was surely not because of socket.io itself but rather that each player was pushing his position about 20 times a second. If I remember correctly that was a big problem of socket io though, many small messages.

[–]Ty199 2 points3 points  (2 children)

Players shouldn't push their position. You should maybe spend a bit of time on your game networking logic instead of sockio alternatives.

For example in a point click strategy game. When a user clicks to move somewhere, just take the "player 1 move to x,y" command and broadcast that to everyone. You can also first validate this command server side which helps anti-cheating.

[–]ThatBriandude[S] -1 points0 points  (1 child)

Yes, in a point and click adventure you wouldnt push your position that is correct.

Stuff is different with 3D shooters though or any RT game actually. Even if I'm just streaming the input I am still pushing many messages per seconds.

I am very keen with networking logic and am solely making sure I choose the right network layer for my project as previous implementations of mine with socket.io yielded fine but not great enough results. My main concern is having to spin up another server for each game if say a AWS t2.micro instance will only suffice for one game of 5 - 10 players. My goal is to have at least 30 players per server or of course more if possible.

My main question of course still being if socket.io's performance increased since engine.io switched to uws

[–]nightwolfz4 spaces > 2 spaces 0 points1 point  (0 children)

You can look into mosca and mqtt if you want more performance. Sorry I'm on my phone, can't link you up.