# Websocket Scalability w/ Player Skills

About 8 months ago, I asked this question, and received a lot of valuable information from the community.

I have switched to nodejs, since then, and am finishing up my game. I am deeply concerned about networking issues pertaining to the usage of WebSocket data being sent through my current architecture; especially since my game uses an authoritarian server, and doesn't utilize peer to peer.

My game is a Diablo 2 inspired action RPG. As we know, for action RPGs, players utilize a lot of skills, and if games are instanced based, all players in the game need to be notified.

I am worried about scalability. Here is an example:

Shooting a fireball has a 0.5 second cool-down. This is how the data is sent:

• Client [Skill id, Skill rotation] -> Server
• Server [Checks cooldown, notify's players skill is being used]
• Client [If fireball hits monster, send attack signal] -> Server
• Server [Checks cooldown, player's range to mob, calculates damage, etc & spits out damage numbers to all players]

All this happens in less than 1 second. The WebSocket server is not even sending out the Monster AI update packets to do damage to the player, nor the monster's fireballs. So now, basically double the amount of data is being sent through the WebSocket and to all player's in a game. It gets worse; imagine if 20 players are online attacking monsters. My nodejs server will be on fire.

This method is not even 100% cheat proof, as I'm waiting for the fireball to hit the monster on the client-side to send the attack signal, instead of doing all that on the server. The problem is, I would have to be running a physics engine on the server, which would bog down nodejs's event loop even more. I'm using the P2 Physics engine from Phaser, and not simple AABB; otherwise, I could just check for collisions server-side.

To close, when a player moves around the map, the server notifys everyone else in the same game. The same goes for when a player drops an item, or when loot is generated from a monster. I just feel like I'm clogging my WebSocket server up, and am doing something wrong with all this data being sent across the pipe.

So with all this said,

• Am I worrying too much about the amount of data being sent across WebSockets?

• Is this data being sent normal for a games that utilizes an authoritarian server?

• Would a Redis Pub Sub system be an ideal solution to my problems?

• Are you sure you even have a problem? Did you test it in a profiler with 20 automated players? All of this sounds like premture optimization to me. – Philipp Nov 19 '15 at 9:59
• Client [If fireball hits monster, send attack signal] -> Server This is suboptimal and the first hooking point for cheaters. The client sends the attack signal and the server checks if fireball hits the monster. – monty Nov 19 '15 at 13:13
• @NiCkNewman Doing regular performance tests during development can be very useful. The earlier you catch a problem the easier it will be to fix it. But it is important that you test first and fix when you have proven that there is a problem. Otherwise you risk wasting time on solving problems you don't actually have. – Philipp Nov 19 '15 at 13:33
• You might implement some of the optimizations I discussed in this article: gamasutra.com/blogs/AlessandroAlinone/20131127/205705/… – Alessandro Alinone Nov 19 '15 at 17:09
• @AlessandroAlinone Thanks alessandro, I found your presentation as well, as well. This is amazingly good stuff. – NiCk Newman Nov 19 '15 at 17:22