Could you give lag?

Started by Luis_Labarca, Feb 15, 2017, 07:44 AM

Previous topic - Next topic

Luis_Labarca

Have a doubt this function could give lag on the server?


function onScriptLoad()
{
NewTimer( "Test", 1000, 0 );
}

function Test()
{
for (local i=0; i<GetMaxPlayers(); i++)
{
local player=FindPlayer(i);
if(player)
{
Stream.StartWrite()
Stream.WriteString("Test")
Stream.SendStream(player)
}
}
}
My server RP
IP: 51.222.28.159:8194

jWeb

No. The server sends far more data at smaller intervals.

KAKAN

Quote from: jWeb on Feb 15, 2017, 07:50 AMNo. The server sends far more data at smaller intervals.
Um, well, he's sending strings every 1sec, to every player. Imagine 50 players playing at once for 5 or more hours. I'm pretty sure their home-hosted server's ISP will block them.
oh no

jWeb

#3
Quote from: KAKAN on Feb 15, 2017, 08:21 AM
Quote from: jWeb on Feb 15, 2017, 07:50 AMNo. The server sends far more data at smaller intervals.
Um, well, he's sending strings every 1sec, to every player. Imagine 50 players playing at once for 5 or more hours. I'm pretty sure their home-hosted server's ISP will block them.

Nope. Let's say that you have a string of about 32 characters. Since VCMP is ASCII, that means 32 bytes. Let's do some math:

32 (bytes) * 100 (players) = 3200 bytes sent each second

60 (seconds) * 60 (minutes) = 3600 seconds in a hour

3200 * 3600 = 11,520,000 bytes / hour. Which translates to about 10.986328125 megabytes. meh. let's just round that to 11 megs. And that's how much the server sends to all players together not individually. Individually? That's about 112.5 kilobytes / hour. I'm pretty sure you used more to load this page in a second.

Should we count for bigger strings?

64 = 21.97265625 megabytes / hour.
128 = 43.9453125 megabytes / hour.
256 = 87.890625 megabytes / hour.
512 = 175.78125 megabytes / hour.
1024 = 351.5625 megabytes / hour.
2048 = 703.125 megabytes / hour.
4096 = 1406.25 megabytes / hour. This is the maximum buffer limit which you can send to a client at once.



NOTE: With each string comes a 2 byte overhead for the string size. I've omitted that for simplicity and because it's insignificant. Also, each packet hash it's own overhead. But that applies to internal packets as well. So it's not some special case.



Like I said. The game servers are sending data at smaller intervals. Large chunks of data are not an issue for a server. The small and very frequent packets are going to start making a difference in lag.

If you were to send these every 20-30 milliseconds (or each frame). Yeah, then you'd have an issue.

Luis_Labarca

Quote from: jWeb on Feb 15, 2017, 07:50 AMNo. The server sends far more data at smaller intervals.
Ah ok, thanks bro
My server RP
IP: 51.222.28.159:8194