Add randomized delay to folder preloading
Replaced fixed delay with a randomized delay when preloading folders to reduce predictability and overloading the server with multiple requests at the same time Introduced a static Random instance for delay calculation.
This commit is contained in:
parent
91a1ba4086
commit
70c1dcc86c
1 changed files with 3 additions and 4 deletions
|
|
@ -19,6 +19,8 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
protected new DataStoreConfig myConfig;
|
protected new DataStoreConfig myConfig;
|
||||||
protected bool botConnected = false;
|
protected bool botConnected = false;
|
||||||
|
private static readonly Random _delayRandom = new();
|
||||||
|
|
||||||
public DataStoreService(EventsSecondBot setMaster) : base(setMaster)
|
public DataStoreService(EventsSecondBot setMaster) : base(setMaster)
|
||||||
{
|
{
|
||||||
myConfig = new DataStoreConfig(master.fromEnv,master.fromFolder);
|
myConfig = new DataStoreConfig(master.fromEnv,master.fromFolder);
|
||||||
|
|
@ -1055,7 +1057,7 @@ namespace SecondBotEvents.Services
|
||||||
{
|
{
|
||||||
preloadingFolders.Add(folder.Guid.ToString());
|
preloadingFolders.Add(folder.Guid.ToString());
|
||||||
}
|
}
|
||||||
await Task.Delay(1000 * currentDepth);
|
await Task.Delay(_delayRandom.Next(500, 1251) * (currentDepth+1));
|
||||||
List<InventoryBase> foldercontents = GetClient().Inventory.FolderContents(
|
List<InventoryBase> foldercontents = GetClient().Inventory.FolderContents(
|
||||||
GetClient().Inventory.Store.RootFolder.UUID,
|
GetClient().Inventory.Store.RootFolder.UUID,
|
||||||
GetClient().Self.AgentID, true, true,
|
GetClient().Self.AgentID, true, true,
|
||||||
|
|
@ -1357,6 +1359,3 @@ namespace SecondBotEvents.Services
|
||||||
public long time = SecondbotHelpers.UnixTimeNow();
|
public long time = SecondbotHelpers.UnixTimeNow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue