the background task degrade performance of file operations
I'm trying to make performance critical Asp.net core 2.0 page - and I needed Background logic To prepare some files and memory before user requests - but actually when A user request is being processed and if the background task had been running simultaneously I find that file saving operations takes long time- I checked this by logging times of background and my MVC Action . I don't know why its the case but even if background task is doing nothing just trying to start at (ExecuteAync) at same time result in big slowdown on Request processing that involves writing files - so i need an option to pause background task entirely so no actual calling to it would happen and then resume it after request processing is done
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: d49a03c0-a844-26eb-48a5-33a612dd3ead
- Version Independent ID: 0707865f-9db7-0d71-42a5-bc1a1e89680a
- Content: Implement background tasks in microservices with IHostedService and the BackgroundService class
- Content Source: docs/architecture/microservices/multi-container-microservice-net-applications/background-tasks-with-ihostedservice.md
- Product: dotnet
- Technology: dotnet-ebooks
- GitHub Login: @nishanil
- Microsoft Alias: nanil
@CESARDELATORRE Can you comment on the concern above?
Interesting.. I'll point the ASP.NET team to look at it. However, and as we're doing in eShopOnContainers, I'd recommend to implement the IHostedServices in a different project than the ASP.NET Core Web App, if the process you need to do can be targeted remotely. Doing that way not only you wouldn't have that problem, but also you can scale out the web app differently than the background tasks. An now, in .NET Core 2.1 you can even use a IHost (with no ASP.NET Web stack overhead) instead of an IWebHost, as explained in the same link: https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/multi-container-microservice-net-applications/background-tasks-with-ihostedservice
About your concrete issue, I talked to the ASP.NET team and we’re not aware of similar issues. We’d need far more details, for example are you hitting disk contention? Is the increase in time when it is starting the HostedService because no requests will be served until after the hosted service returns from start? etc. You’d need to log a bug on hosting with many details at the .NET CORE repo if you think you found a possible bug. Ok?
Closing as it appears resolved. If this is not the case, then please reopen. Thanks!