Edit SQL pool config, usage

This commit is contained in:
Noi 2022-11-21 10:45:46 -08:00
parent 236c34b810
commit a9853021f4
3 changed files with 9 additions and 5 deletions

View file

@ -73,7 +73,7 @@ class Configuration {
SqlDatabase = ReadConfKey<string?>(jc, nameof(SqlDatabase), false);
SqlUsername = ReadConfKey<string>(jc, nameof(SqlUsername), true);
SqlPassword = ReadConfKey<string>(jc, nameof(SqlPassword), true);
SqlApplicationName = $"ClientShard{ShardStart}+{ShardAmount}";
SqlApplicationName = $"Shard{ShardStart:00}-{ShardStart + ShardAmount - 1:00}";
}
private static T? ReadConfKey<T>(JObject jc, string key, [DoesNotReturnIf(true)] bool failOnEmpty) {

View file

@ -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();
}

View file

@ -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 {
/// <summary>
/// Number of concurrent shard startups to happen on each check.
/// This value is also used in <see cref="DataRetention"/>.
/// This value also determines the maximum amount of concurrent background database operations.
/// </summary>
public const int MaxConcurrentOperations = 4;
public const int MaxConcurrentOperations = 3;
/// <summary>
/// Amount of time without a completed background service run before a shard instance