I just created a simple MMO in unity3d, then me and my friends test it via LAN and the result is very smooth. But when I hosted it in public (100ms ping) the server became unresponsive and causes random disconnection.
Host Setup
- 1gbps
- 32gb ram
- 256 ssd
- off firewall
Server Setup
- max of 100 players
- every 100ms update
- no other updates, just only X and Y location of player by index
- c# sockets w/ async
Server Flow
- when 100ms tick reaches, server sends position of player base on index in a loop.
ex.
if (gtick >= 0.1f) {
for (x < maxPlayers; x++) {
// check ifs
//couples of ifs here...
// send
sendToWorld(x ... player[x].posX ... player[x].posY);
}
// somewhere, gtick = 0, then counts up again...
}
then the result is delay, unresponsive, and random disconnection. maybe it flooding itself, I don't know. but when we test it locally (10+ players), it is very smooth and no problem at all.
My question is, How can I update all players every 0.1 without server flooding itself?