So I recently started using netcode to allow playing my game online, together with unity lobby. It works fine and all, I haven’t had a lot of issues with it. However, since the start I noticed very high constant network usage on the Relay graphs. It reads around 22 KiB per minute at all times. I’ve optimized every single bit of data that is sent across server/client, but it still remains at least 22 KiB per minute. I just tried disabling pretty much all game objects in the scene, but no change. I added a debug print to every RPC, but nothing is being spammed. 22 KiB per minute is like 350 bytes being sent every single second, and there is seemingly nothing I can do to reduce it. Does the lobby use so much data? Or could it be something else? It’s too much data to be ignored. Because of my optimization, each player should use just around 150 KiB per hour if they constantly move, and 0 if they stand still.
EDIT: Okay, so I may just have found a clue. I changed the log level of my NetworkManager to Developer, and every second it says “[Netcode] Syncing Time To Clients” in the console. Could this be the cause of high network usage? I’d think that sending, likely a long, with overhead and all, every single second should be extremely costly?
You may already know about this, but you can use the network profiler to get a detailed view of what is being sent (and what causes it to be sent). Another thing that comes to mind is the heartbeat timeout (under the Unity Transport component). If set very low (and if there’s no other traffic), it could end up consuming a fair amount of bandwidth. You can try increasing the value and see if it makes any difference.
350 bytes per second is very little traffic in my opinion. Divide this by the tick rate (30?) - that‘s 12 bytes per tick. And yes, connected clients and the server need to regularly sync time and probably more, like saying „yeah i‘m still connected“ and all that.
350 bytes per second doing absolutely nothing. Thats 1.3MB an hour. That is too much from just being idle in my opinion. Why exactly would I need time sync? Isn’t data in packets just called as soon as the client recieves it? I see no need to sync client and server in that way in my game at least.
I’ve tried editing the heartbeat with no visual difference. The network profiler shows nothing at all.
Edit: Okay, I just did some testing and it seems like the heartbeat was the issue after all. I’ve been messing with it before but it’s kind of difficult to get readings as there is quite a long delay on the Relay overview. I guess it was that simple Thank you for your response.
Again, I don’t think those 350 bytes per second or 2.8 kbps is a lot, or very relevant for that matter unless you run a game where you expect players to be idle 90% of the time - meaning: this isn’t the use-case you should optimize for or worry about.
Here’s a paper that has some bandwidth stats of mostly fast paced games, and they’re all in the 50-200 kbps area, and it is said the aggregated traffic (which I assume is server inbound+outbound traffic) is not exceeding 1600 kbps. Even though these games are old, I wouldn’t expect the traffic requirements to be very different compared to today’s games.
You may also want to run traffic analysis for a game that is similar to the one you’re developing, so you can realistically estimate what cumulative inbound/outbound traffic to expect for a single client and extrapolate that to server traffic by multiplying with (expected) number of connected clients.
As an indie game developer with very limited resources, I have to cut down wherever I can. Bandwidth isn’t free. I’ve done a pretty good job at optimizing the game, so there is hardly any network used even as a 3D game up to 4 players. I’ve done some new tests, and a game of four players should, even when all players are very active (I have thresholds and stuff), not use more than 1MiB per hour in total (250 KiB per player ish). In that case, it’s not very motivating when some background data which I can’t control eats up 1.3MiB per player, pretty much multiplying the network usage by 5. Anyway, changing the heartbeat lowered the usage by about 75%, so it’s much better now. I don’t think I need to do much more now as it is much lower. The time sync could be tweaked as well to lower it even more, but since all values and methods are private it’s not an easy job to do. I still wish they added the functionality to do so.
Are you running self-hosted servers? If so, traffic should be free / unlimited. Any other deal is just a rip-off IMO.
If not and you’re using Photon Fusion for example, have you calculated how many players you have to have in order to go over the 20 CCU free plan’s limit of 60 GB per month?
Or the alternative calculation: the number of purchases that must have been made for this much traffic to be generated in a month, and whether at this point you won’t be like <f*** it i don’t care>?
Bandwidth isn’t free but it is effectively free in most situations. For example Photon provides a bandwidth buffer of 3GB per CCU per month which works out to be 100MB per day which sounds low but is difficult to hit unless you’re just going nuts with data usage.
Which is too low to consume the bandwidth pool provided by Photon.
Using Unity Relay and Lobby I have no ability to self host at this time. I hope to make some money with my game in the future, and hosting won’t be an issue, but right now the game is out for free to gain traction so that is not the case. I know the cost won’t be insane, since it’s like $0.5 per GiB after the free 5Gib, plus a cost for CCUs, but since I am trying to keep expenses minimal I have to avoid wasting traffic.
Edit: I’ve already had 10 players logged in at the same time, and I just recently released the game, so Photon’s free plan which allows 20 people logged in concurrently won’t do it for me.
Ah. Everything has become much more clear now. You’re reading the wrong lines. Cloud saves are $0.50 per GB after the first 5GB but Lobby and Relay have different numbers. Below is a screenshot of the actual section. You have much more free data than you’re thinking.
My math from my previous post concerning Photon applies here too since the numbers are identical. You’re going to run into CCU limits long before you run into bandwidth limits.
Ah, that makes sense I guess. I might have read some old posts talking about prices as well, since I know people were concerned with the prices. I remember seeing a $119 price tag per 100 CCU, so that worried me as well. I guess they adjusted it over time. Or I misread. Nevertheless, optimizing isn’t a bad thing. But I might increase the tick rate a little
Edit: Found the post. It was just old news. I won’t worry too much then