I'm coding a very simple game Rust/Dayz like with Unity, and I'm using Forge Networking as network library.
A few days ago, I started to code the Loot system. The Loots in my game are Items that are instantiated in the game world (in other words, the items that are on the ground) and I was implementing the system that send and receive Loot data from and to the server (the server is fully authoritative).
I also created a LootSpawnManager class that contains, in a list, all the Loot spawned in a certain Loot spawn spot (so there is a LootSpawnManager for every spawn point of the Loots object).
In my game the server checks if a player is in a certain range from the Loot gameObject. If it is, then the server sends the Loot data through the network to the client, and the client with that data creates a Loot object and instantiates it in its world (scene).
For optimization (because checking if there are players in an area is a bit expensive), the LootSpawnManager has a list, with all the players nearby, that is refreshed every 4/5 seconds. So, for example (in the server) if a Loot is added to a LootSpawnManager (or a Loot already in the LootSpawnManager list has changed its properties) the server sends the data to the players that are in the LootSpawnManager's players list.
So far no problems. The issues come when a Loot doesn't belong to a LootSpawnManager. In the game there will probably be hundreds if not thousands of Loots that don't belong to a LootSpawnManager, so every single Loot would have to do its check every 4/5 seconds, and this will certainly kill server performance.
A solution to this problem could be to group near solitary Loots in a class similar to LootSpawnManager that has the player list for that zone. But I don't think that this will help, because there will be few cases in which a lot of Loots are near, although in the majority of cases there will be maximum 2-3 Loots. So the question is: are there any good performance solutions for this problem?
EDIT :
I didn't mentioned that the client doesn't have instantiated all the Loots that are in the server, and the players have instantiated only the Loots in a certain range from them. If they are too far from a Loot they delete it (I'm talking about the single client side, so deleting means deinstantiating the object, not removing it in the server) and, like I explained before, if they are nearby a certain range from a Loot, then the client has to wait for the server checks.
P.S. I hope my English is understandable (it's not my mother language) and that what I just wrote above is clear.