I'm Working with ASP.NET Core 2.2 Web API multi-tenant application. The application uses Hangfire to run background tasks. We are trying to improve the performance of the application.
It stores all the jobs in a separate DB (Hangfire DB), but this impact on API performance. I have traced the API request in order to check the request time, here is the result:
Here is the code
public async Task<string> AddUser(UserModel user)
{
CreateUserInBackgorund(user);
// removed code
return "some status";
}
[Queue(Constants.Critical)]
public void CreateUserInBackgorund(UserModel user)
{
BackgroundJob.Enqueue(() => CreateUser(user));
}
public async Task CreateUser(UserModel user)
{
try
{
//Other code
}
catch (Exception ex)
{
_logger.Error(ex.Message, ex);
}
}
The trace logs seem that background calls impacted on the performance of the request. Is there a way to reduce this time or use another approach?
