I'm not entirely sure why this happens to thats why I'm trying my luck here;
Problem description:
Ping increases proportionally with the amount of surrounding entities. It's almost not noticable locally but makes a big difference (up to 500ms) on the VPS.
Test 1 details: 0 mobs on the screen, hosted locally.
time it takes me to initially update the screen and send every packet. - Result: 0.851 ms (dictionary check, "foreach (entity in map)" )
- Ping: 25ms
No surprise here, nothing is around, everything completes in less than a millisecond, ping is at 25ms (it never went below that for some reason?)
Test 2 details: 100 mobs on the screen, hosted locally.
time it takes me to initially update the screen and send every packet. - Result: 0.931 ms (dictionary check, "foreach (entity in map) => SendSpawnPacket" )
- Ping: 43ms
Surprise here, many mobs around, everything completes in less than a millisecond, ping is at 43ms why?
Test 3 details: 100 mobs on the screen, hosted locally.
Average time taken to send/process packets over 30 seconds (Mob Movement, targeting, attacking,... - Result (min, max): 0.431, 0.703 ms
- Ping: 44ms
Test 4 details: 0 mobs on the screen, hosted locally.
Average time taken to send/process packets over 30 seconds (Mob Movement, targeting, attacking,... - Result (min, max): 0.131, 0.244 ms
- Ping: 25ms
The only thing I noticed is the FPS somehow influence the PING. If I'm getting 20fps the ping spikes up.
UPDATE
Updated the Socket System and got 4ms decrease in Ping.
Instead of connection.Send(x) im doing await Task.Factory.FromAsync<int>(connection.BeginSend(b uffer, 0, buffer.Length, SocketFlags.None, null, connection), connection.EndSend); <- ThreadPool? Probably won't scale well..
Unlocked FPS decreases the min. Ping to 12ms.