Skip to content

Commit

Permalink
refactor(Program.cs): switch from dedicated to default thread pool to…
Browse files Browse the repository at this point in the history
… improve performance

fix(Program.cs): reduce max concurrency from 500 to 100 to prevent potential overload
refactor(Program.cs): move loggerFactory and LogContext setup to a more appropriate location for better code organization
  • Loading branch information
Jossec101 committed Dec 5, 2023
1 parent e5ad4cb commit 20168ed
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static void Main(string[] args)
options.UseNewtonsoftJsonSerializer();
});

q.UseDedicatedThreadPool(x => { x.MaxConcurrency = 500; });
q.UseDefaultThreadPool(x => { x.MaxConcurrency = 100; });

//This allows DI in jobs
q.UseMicrosoftDependencyInjectionJobFactory();
Expand Down Expand Up @@ -325,9 +325,7 @@ public static void Main(string[] args)

}

var loggerFactory = new LoggerFactory()
.AddSerilog(Log.Logger);
Quartz.Logging.LogContext.SetCurrentLogProvider(loggerFactory);


}
catch (Exception ex)
Expand Down Expand Up @@ -368,6 +366,10 @@ public static void Main(string[] args)
//Grpc services
//TODO Auth in the future, DAPR(?)
app.MapGrpcService<NodeGuardService>();

var loggerFactory = new LoggerFactory()
.AddSerilog(Log.Logger);
Quartz.Logging.LogContext.SetCurrentLogProvider(loggerFactory);

app.Run();
}
Expand Down

0 comments on commit 20168ed

Please sign in to comment.