Optimizing resource downloads using a caching proxy

also there’s some ‘MISS’ in the end of request log, 1/7 of ‘HIT’. I had insert ‘proxy_ignore_headers Cache-Control;’ in ‘location /file/{}’ in order to solve that issue and it works. don’t know how it would effect the bandwithds but it shows no ‘MISS’ after all.
Dose ‘proxy_ignore_headers Cache-Control;’ would ignore the cache rule and let player download those assests everytime ?

Hi !

So:

  1. if the cache server is started and enabled on your server, the cache begin when the first player connecting to your server. The caching process start, and take time for each file to cache.

  2. As first player connecting to my server after cache enabling, i’ve must waiting 1h30 before finishing loading screen. In client console we can see “addcacheentry…” line for each file to load from caching server.
    After that, i’ve cleared my game cache and reconnect to my server, less than 2min to finish loading, and all files are taked from cache server. (Can see all files queryed on the cache server with the access log file).

  3. I dont use docker, i’ve installed nginx manually on my debian server so docker is useless for me.

  4. No need to register ymap, ytd, ybn, ytf, ycd, navmesh (…) files. Only ytyp that contain mlo or new textures reference not already in the game (i.e: play cards for casino). Just place it in stream directory of your resource. Streaming system scan stream directory and made the client download it automatically. For vehicle, files are not downloaded until specific vehicle imported are not loaded into the game, so not cached until the vehicle are not called !
    If you want i’ve made script for that: after client connection and loading finished he make LoadModel for all vehicle in vehicle mysql table and wait to be loaded before next vehicle. I can share it if you want.

  5. Example of __resource.lua for a resource contains many vehicles on my server (sounds disabled to limit bandwith needed for small connection (sounds ~= 300Mb, only for vehicle i think is useless to download):

resource_manifest_version ‘77731fab-63ca-442c-a67b-abc70f28dfa5’

files {
‘data//handling.meta’,
'data/
/vehicles.meta’,
‘data//carvariations.meta’,
'data/
/carcols.meta’,
‘data/**/vehiclelayouts.meta’
}

data_file ‘HANDLING_FILE’ ‘data//handling.meta’
data_file ‘VEHICLE_METADATA_FILE’ 'data/
/vehicles.meta’
data_file ‘CARCOLS_FILE’ ‘data//carcols.meta’
data_file ‘VEHICLE_VARIATION_FILE’ 'data/
/carvariations.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘data/**/vehiclelayouts.meta’

files {
–Vehicls
‘vehicles.meta’,
‘carvariations.meta’,
‘carcols.meta’,
‘handling.meta’,
‘vehiclelayouts.meta’,
‘vehiclelayouts_avisa.meta’,
‘vehiclelayouts_longfin.meta’,
‘vehiclelayouts_patrolboat.meta’,
–Weapons
‘vehicleweapons_annihilator2.meta’,
‘vehicleweapons_dinghy5.meta’,
‘vehicleweapons_patrolboat.meta’,
‘vehicleweapons_seasparrow2.meta’,
‘vehicleweapons_submarine.meta’,

–Animations
‘conditionalanims.meta’,
‘clip_sets.xml’,

–Sounds
– ‘sfx/dlc_hei4/brioso2.awc’,
– ‘sfx/dlc_hei4/brioso2_npc.awc’,
– ‘sfx/dlc_hei4/italirsx.awc’,
– ‘sfx/dlc_hei4/italirsx_npc.awc’,
– ‘sfx/dlc_hei4/kosatka.awc’,
– ‘sfx/dlc_hei4/manchez2.awc’,
– ‘sfx/dlc_hei4/manchez2_npc.awc’,
– ‘sfx/dlc_hei4/slamtruck.awc’,
– ‘sfx/dlc_hei4/slamtruck_npc.awc’,
– ‘sfx/dlc_hei4/toreador.awc’,
– ‘sfx/dlc_hei4/toreador_npc.awc’,
– ‘sfx/dlc_hei4/verus.awc’,
– ‘sfx/dlc_hei4/verus_npc.awc’,
– ‘sfx/dlc_hei4/veto.awc’,
– ‘sfx/dlc_hei4/veto_npc.awc’,
– ‘sfx/dlc_hei4/weevil.awc’,
– ‘sfx/dlc_hei4/weevil_npc.awc’,
– ‘sfx/dlc_hei4/winky.awc’,
– ‘sfx/dlc_hei4/winky_npc.awc’
– ‘dlchei4_game.dat151.rel’,
– ‘dlchei4_sounds.dat54.rel’,
}

data_file ‘HANDLING_FILE’ ‘handling.meta’
data_file ‘VEHICLE_METADATA_FILE’ ‘vehicles.meta’
data_file ‘CARCOLS_FILE’ ‘carcols.meta’
data_file ‘VEHICLE_VARIATION_FILE’ ‘carvariations.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehiclelayouts.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehiclelayouts_avisa.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehiclelayouts_patrolboat.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehiclelayouts_longfin.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehicleweapons_annihilator2.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehicleweapons_dinghy5.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehicleweapons_patrolboat.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehicleweapons_seasparrow2.meta’
data_file ‘VEHICLE_LAYOUTS_FILE’ ‘vehicleweapons_submarine.meta’
data_file ‘CONDITIONAL_ANIMS_FILE’ ‘conditionalanims.meta’
data_file ‘CLIP_SETS_FILE’ ‘clip_sets.xml’
data_file ‘AUDIO_WAVEPACK’ ‘sfx/dlc_hei4’
– data_file ‘AUDIO_GAMEDATA’ ‘dlchei4_game.dat’
– data_file ‘AUDIO_SOUNDDATA’ ‘dlchei4_sounds.dat’

files in resource folder:

image.png

And in stream folder we have placed all vehicle files (ytd,yft…).
In example again, files for one vehicle in the resource:

image.png

Same as all folder with [name] in fivem, it’s only a container, not see as a folder for fivem, but just use to “order” your resources files (fivem read stream\nspeedo\files…) but all files are correctly cached when i make a /car nspeedo.

And in logfile of nginx, when a file is requested, you can see that:


First line (MISS) the file is downloaded from server because is not in cache (~5sec added to loading…).
Second line (HIT) the file is take and served from cache (loading instantly).

Hoping to have answered your questions … and sorry for my bad English!

Kind regards,
Bill Ours/Gyzzmo

4 Likes

Thank you so much for your time! It’s my pleasure to have you around, this is very helpful!

You deserve the highest level of respect.

Thank you !!! ^^’

1 Like

Yes, that would be lovely, we need that very much, you’re so kind!
I got more questions if you’d pardon:
1.How many bandwidth do you have for your game server(fxserver) ?
2.Is 10M bandwidth enough to carry more than 50 players for game server(fxserver) with a 3M proxy server on? Our server is experiencing ‘RED words’ of package loss in last 4 hours(3 times at lease per hour), even the log shows there’s someone downloading assets from proxy server, our 10M bandwidth game server seems not enough to carry that much of downloads. I’ll show you the network flow of the game server after 12 hours.

Personally I have fiber at home so my nginx is on an orangepi 3 ($ 40) at home (~ 400Mbps upload). But my server is 100Mbps (kimsufi.com). I think you need to take more bandwidth for the proxy to solve your problems.


this is the proxy server access.log, nothing is MISS, but our fxserver is keep getting loss of packages, the “red words” of trying to reconnect shows on the screen constantly. I don’t know why… :disappointed_relieved:

Have you try profiler commands to see if that your server resources do not do anything?

what kind of ‘profiler’ commands to check that? can you please post some commands about it ? ^^

1 Like

Consult the documentation…oh yes it is true there is none!..

So, if you type “profiler” command on your server, you can show that:

profiler
profiler help
profiler record start | <frames> | stop
profiler save <filename>
profiler status
profiler view [filename]
profiler view [filename]

To see what happend type:
profiler record 500
you can see where is the recording with
profiler status
when it say not in record, you can type:
profiler view
to request the last record. You can also type commands with filename if you prefer.
Profiler view command give a link to show performances profiling in your browser (chrome like).
So, as often the cfx.re address does not work, you can replace it with the address of your server directly in the url if the page displays an error when loading.
I’ll let you try to understand the visual of profiling on your own. It’s not hard but you have to take the time, like everything in FiveM …

1 Like

The reason I’m using a 3M proxy server to caching my resources is because I thought that 3M upload/download bandwithds will only take 3/10 of my 10M game server in order to save more bandwitdth for UDP messages to player… obviously it dosen’t going so well…

1 Like

Thank you so much!
I’ll try to take a 50M bandwitdh server in few days … (bandwidth is expensive in east-asia, even korea…)

How do you think about a 100M upload bandwidth proxy service server with a 50M bandwithd for fxserver? Would the proxy server break the upload bandwidth of fxserver?(due to there’s only 50M upload bandwidth of the fxserver…) Will it take more bandwidth out of the fxserver when it’s caching files?

No, don’t worry ^^ the proxy will only download as much as possible with the fxserver, which will be much more available to it not to redistribute resources to clients. And caching is not done often (without modification on your resources, with my config nginx = 1 year in cache).

I used 100M proxy server to cache resources for my 10M game server a few days ago, and my game server suddenly lost all players (PL 0% Ping 500), the upload bandwidth has been fully taken by the proxy server when it’s caching mods :joy: wish there’s a more decent solution like a different port, you can configure diffrent resource management at least, also this is the most advantage that FiveM has.
I would prefer to use a CDN with BGP link to stream mods with distributed container worldwide(just to buying for bandwitdh not a VM, aka ECO & commercialize/stable).
If we can setup a upfront nginx server to dealing the request first and re-route them with diffrent port/request with diffrent physical server, there will be no limits for my fxserver(we can take 1k-2k online players with one single machine).

All of this is my ‘sweet little dream’ ofcourse :rofl:

lol, not with a 10Mbps fxserver ?! xD

I’m just trying to figure out wether the proxy server would “steal” the bandwitdh from “fxserver” if the proxy server upload bandwitdh was fully taken or not, so I gave a try with 1v2.6Ghz / 4G Memory / 20GB SSD / 100M bandwidth VM to caching mods, maybe I should use it to run my fxserver next time :rofl:.
Consider the most calculation is done by the Client and server only take response for UDP synchronization & message verification.
I had a “Performance Testing” for my fxserver yesterday, the CPU coverage show 12% max/5% average with 4v2.6GHz intel CPU, maybe I could use a more ECO plan with just an VM :rofl:

Hi there, sorry for borthering…
I have some ‘MISS’ and ‘HIT’ logs with different player with same file in the access.log …
I’ve spend a week trying to fix this up, none of the solutions is working in this situation…
Here’s my access.log:


This is my .conf file in the nginx/conf.d:

Can you help me please?

From what you posted as a log, there is nothing fundamentally wrong with that in general. First part of it is you are not seeing the same file requested technically, they are different and looks like the URL’s are both different. Looks like some IP and then the local nginx path.

You also have to realize this is going to be based on how the reverse proxy works:

  • Request is made from client to game server.
  • Game server sends to the file cache server.
  • File cache server asks if it has a copy of this artifact. If it does, it is a HIT and services from the cache.
  • If the file is missing you get a MISS, and it reaches for the upstream host (your game server) to get the file. Once it gets the file, it will service it back to the original requestor as well as cache it locally for others.

The fact that you have off loaded the requests doesn’t eliminate them. If you or the FXServer changes the content, this still can show as a MISS in your nginx log. This is fully expected and normal.

I would say in general for your setup a 10Mbps connection is rather low for 50 slots. You have to figure with the TCP overhead and other congestion factors that could come into play, that would be extremely painful.

could you help me set this up?