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: c3460b0d-9c60-3a06-ac63-18cf990e53c3
- Version Independent ID: b2dece1f-15b8-03af-6d52-7cc070432b4b
- Content: Background tasks with hosted services in ASP.NET Core
- Content Source: aspnetcore/fundamentals/host/hosted-services.md
- Service: unspecified
- Product: asp.net-core
- GitHub Login: @guardrex
- Microsoft Alias: riande
Hi @future81 ... See: https://github.com/aspnet/Hosting/issues/1393
I hacked around a little bit with this scenario myself. What I was playing with is NOT how these bits are designed to work. What I was doing falls into USE AT YOUR OWN RISK! What I did was create a Razor Pages app that had some buttons in the Index page that could start and stop background tasks on a user click. You can see the sample app here: https://github.com/guardrex/HostedServiceSample ... Again, that approach is not supported or recommended by Microsoft. It's also different than what @benaadams recommended in his response on that issue, which sounds like a better approach.
If you have additional questions or a feature request in this area, either post a comment on https://github.com/aspnet/Hosting/issues/1393 or open a new Hosting issue. We won't be changing the doc to address the scenario you're asking about unless the engineers come up with an officially-supported scenario for it.
Thanks for commenting!