mirror of
https://github.com/NoiTheCat/BirthdayBot.git
synced 2024-11-21 21:54:36 +00:00
Edit SQL pool config, usage
This commit is contained in:
parent
236c34b810
commit
a9853021f4
3 changed files with 9 additions and 5 deletions
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue