fix: mogo pool e limits
This commit is contained in:
parent
e960e4af03
commit
81ff8d2ae3
@ -11,6 +11,7 @@ namespace QRRapidoApp.Data
|
||||
public MongoDbContext(IConfiguration configuration, IMongoClient? mongoClient = null)
|
||||
{
|
||||
var connectionString = configuration.GetConnectionString("MongoDB");
|
||||
connectionString = connectionString + (connectionString.Contains("?") ? "&" : "?") + "maxPoolSize=200&minPoolSize=50&maxIdleTimeMS=30000";
|
||||
if (mongoClient != null && !string.IsNullOrEmpty(connectionString))
|
||||
{
|
||||
try
|
||||
|
||||
11
Program.cs
11
Program.cs
@ -23,6 +23,7 @@ using Microsoft.AspNetCore.HttpOverrides;
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using System.Threading.RateLimiting;
|
||||
using Microsoft.AspNetCore.Server.Kestrel.Core;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
@ -219,15 +220,19 @@ builder.Services.AddRateLimiter(options =>
|
||||
options.RejectionStatusCode = 429;
|
||||
options.AddFixedWindowLimiter("api", options =>
|
||||
{
|
||||
options.PermitLimit = 600; // 10 req/s = 600 req/min
|
||||
options.PermitLimit = 600;
|
||||
options.Window = TimeSpan.FromMinutes(1);
|
||||
//options.PermitLimit = 100;
|
||||
//options.Window = TimeSpan.FromMinutes(1);
|
||||
options.QueueProcessingOrder = QueueProcessingOrder.OldestFirst;
|
||||
options.QueueLimit = 10;
|
||||
});
|
||||
});
|
||||
|
||||
builder.Services.Configure<KestrelServerOptions>(options =>
|
||||
{
|
||||
options.Limits.MaxConcurrentConnections = 2000;
|
||||
options.Limits.RequestHeadersTimeout = TimeSpan.FromSeconds(30);
|
||||
});
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
app.UseRateLimiter();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user