diff --git a/Configuration.cs b/Configuration.cs index 48503a7..aff4457 100644 --- a/Configuration.cs +++ b/Configuration.cs @@ -73,7 +73,7 @@ class Configuration { SqlDatabase = ReadConfKey(jc, nameof(SqlDatabase), false); SqlUsername = ReadConfKey(jc, nameof(SqlUsername), true); SqlPassword = ReadConfKey(jc, nameof(SqlPassword), true); - SqlApplicationName = $"ClientShard{ShardStart}+{ShardAmount}"; + SqlApplicationName = $"Shard{ShardStart:00}-{ShardStart + ShardAmount - 1:00}"; } private static T? ReadConfKey(JObject jc, string key, [DoesNotReturnIf(true)] bool failOnEmpty) { diff --git a/Data/BotDatabaseContext.cs b/Data/BotDatabaseContext.cs index 2fc2616..18e11a9 100644 --- a/Data/BotDatabaseContext.cs +++ b/Data/BotDatabaseContext.cs @@ -15,7 +15,12 @@ public class BotDatabaseContext : DbContext { Username = conf.SqlUsername, Password = conf.SqlPassword, ApplicationName = conf.SqlApplicationName, - MaxPoolSize = Math.Max((int)Math.Ceiling(conf.ShardAmount * 2 * 0.6), 8) + + // Let's see if this works? + ConnectionIdleLifetime = 60, + MaxPoolSize = Math.Max( + (int)Math.Ceiling(conf.ShardAmount * 2 * 0.75), + (int)Math.Ceiling(ShardManager.MaxConcurrentOperations * 2.5)) }.ToString(); } diff --git a/ShardManager.cs b/ShardManager.cs index dda1d6b..cd09a00 100644 --- a/ShardManager.cs +++ b/ShardManager.cs @@ -1,6 +1,5 @@ global using Discord; global using Discord.WebSocket; -using BirthdayBot.BackgroundServices; using Discord.Interactions; using Microsoft.Extensions.DependencyInjection; using System.Text; @@ -23,9 +22,9 @@ class ShardManager : IDisposable { /// /// Number of concurrent shard startups to happen on each check. - /// This value is also used in . + /// This value also determines the maximum amount of concurrent background database operations. /// - public const int MaxConcurrentOperations = 4; + public const int MaxConcurrentOperations = 3; /// /// Amount of time without a completed background service run before a shard instance