Performance impact on storing pure number data

So this is more of a technical question that I’m looking more at deep-level performance knowledge for.

Say theoretically, I stored a table on the server with the proper cleanup implementations for players leaving/dying/joining, and within that table I stored the state of every weapon in the game. For example:

[Player1] {
    [Gun1] {
        [Damage] = 10,
        [Mag] = 8,
        [Ammo] = 30,
        [Firemode] = "Single"
    },
    [Gun2] {
        [Damage] = 15,
        [Mag] = 12,
        [Ammo] = 20,
        [Firemode] = "Burst"
    }.
},
[Player2] {
    [Gun1] {
        [Damage] = 10,
        [Mag] = 14,
        [Ammo] = 30,
        [Firemode] = "Single"
    },
    [Gun2] {
        [Damage] = 15,
        [Mag] = 5,
        [Ammo] = 20,
        [Firemode] = "Burst"
    },
    [Gun3] {
        [Damage] = 7,
        [Mag] = 26,
        [Ammo] = 35,
        [Firemode] = "Auto"
    }
}

What would the impact on server performance be for a scale of 200 players in a single game instance?
In addition, are there any better ways to accomplish this while still keeping the numbers easy to reference, cleanly stored and secure?

1 Like

I’m not going to be able to give you any exact figures on this, but here are a couple of suggestions.

Caching the values in a table, as you are doing, will be much more efficient than relying on datastores or memorystores, even if it does have a higher memory cost (although as these aren’t complex types it is still pretty low cost).

Would the gun data for each player be different? For example if two players have a pistol, would they both have the same fire rate, mag size etc (not ammo obviously). As you could use a reference to a table of static gun data rather than replicating it into each player profile, then just record modifiers and ammo.

Yeah, gun stats would be static barring Ammo, it’s just thinking up a solution of keeping all the data centralised for easy access, such as updating UI information. Though, thinking about it, I could just keep static info stored in a ModuleScript alongside gun functions (to mitigate events) and have Ammo stored in a table for UI update referencing. Just wanted to get a little feedback in regards to how performant caching data into a table would be server-side.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.