How to lower network ping usage

Hey Devs,
I was recently wondering how I can lower my sent and received network pings since they see rather high about 500+. How do games like pet sim keep theirs so low considering they are a huge game?

1 Like

I’d say the first thing you should check is remote event/function spam. Calling them at high rates will cause the pings and network usage to ramp up very quickly.

Same goes if you send HUGE pieces of data through them

2 Likes

Latency is not the same thing as bandwidth.

Is there any modules I can use to help lower it since my game heavily relies on remote events and all that stuff

You could try using networking libraries like Packet.

I don’t really use modules like that, I basically just reduce event calls to be reactive* and only send the strict minimum

Another way you can reduce bandwidth usage/Remote calls is by using Attributes where possible or even instances/Value objects and listening to their ChangedSignal

* What I mean by Reactive is listening to updates instead of constantly polling/requesting information on a loop.

A little diagram to help them understand better:

Latency: The time between two points (think of it like ping pong - the time it takes for the ball to go from your paddle to your friend’s paddle)

Bandwidth: the maximum range of frequencies [aka, the size of the internet tube] (also think of it like ping pong - it’s how big the table is. The wider the table, the more balls can bounce on it)

1 Like

Oh, you mean being ‘Lazy’? Lazy is a term used when things only run when they’re called. (Or, computed/initialised when they’re needed)

Eg, you have a variable ‘FruitBearingTree’. It doesn’t have any value initially. Only when you check if it has fruit, then it’s given a value.

“Lazy Loading” is a different concept where, as you mentioned, you only load/initialize the module when it’s being used for the first time. This concept mostly only applies to how modules are loaded in (there are exceptions when it comes to APIs when you load an object and you don’t necessarily want to load all sub-object within your object, it’s makes it more lightweight to retrieve, and then you can lazy load them which makes an additional query to the database to retrieve it when you use it). This is more something I think you’d find in web applications or APIs rather than Roblox

Actually reading back on what I said above, I think your example could qualify, but simply updating values dynamically wouldn’t fall as Lazy

Being reactive means doing something like this:

AI summary, surprisingly not bad

-- Server
local function SomethingIsUpdating()
    -- Example of sending the strict minimum, instead of sending all the values,
    -- we only send what changed
    SendUpdate:FireClient(ModifiedValues)
end

-- Client
SendUpdate.OnClientEvent:Connect(function(ModifiedValues)
    -- Update UI, client state, or something based on the modified values
end)

This contrast to polling, which could look something like this:

AI summary still providing decent summary

-- Client
while true do
    task.wait(1) -- Polling delay
    NewData = GetData:InvokeServer() -- Sent whether or not it changed
end

My example is client-side, but this would be equally as bad if the server sent data like that

1 Like

Latency is not really something you can easily reduce but would recommend looking into how to make data small and compact.

Less bandwidth generally means smaller chance of data getting lost on the way and needing to be resend again.
Try using buffers or making your own data types.

Buffers let you use 8-bit, 16-bit and 32-bit numbers, with some work arounds 24-bit too.
Ideal for cutting off bits that you won’t use.

If you’re sending numbers that will never exceed 256, you store them in 8-bit integers.
16-bit numbers go up to 65.536.
Find ways to combine or pack data together using buffers when relevant.

If I recall, buffers also come with a built-in lightweight compression which can slightly reduce data usage further.
Shrinking bandwidth usage just generally puts less stress on connections.

There’s no way to fully eliminate latency though, it really depends on how far away and how stable connections are.
If you can predict things like player movement or projectile movement, try predicting what their possible “future position” could be, it makes a game feel more responsive.

this amount is impossible to be made with remoteevent, since you are talking about pet simulator, i guess you talking about visualizing pets
i guess you are moving each pet on server, that causes huge network receive, you should always move visuals like that to client
so on serverside, you will only store data about each player and his equipped pets, while on clientside you will use that data to construct pets models and make them follow player