Can I safely create threads in ASP.NET MVC?

I have a scheduled task that I need to run by going to the page, my web host does not allow me to use the window scheduler.

One task performed by this task is to get some data from several other websites, due to how slow the web requests can be. I set a task to use threads.

Performing this task from the mvc action seems to cause the entire web server to become sloppy, making it impossible to load more pages.

Is it wrong to use streams from a web application? Is there any way to do this safely? What are the restrictions on threading? Do I just need to know more information?

EDIT: SUBQUESTIONS

If I use threads from threadpool (which is used by ASP.NET runtime ( thanks Anton ), can I limit the number of threads that it can use? What is ASP.NET? Threadpool size limit?

Would it be better to have a separate site that does this? Perhaps a virtual folder containing a separate ASP.NET application? Would this prevent me from restricting flow rights?

+3
source share
3 answers

When servicing incoming requests, the ASP.NET runtime receives threads from .NET ThreadPool, which has limited capacity. Therefore, if you use streams from this tread pool, this can damage the scalability of your applications.

Thread, , AppPool .

+3

, , / ( ). ? ""?

.., .

, /, ( ) , , , / ASP.NET MVC.

+3

I think it depends on how it is done. I'm not very competent when it comes to streaming in ASP.NET, but I think there is a risk that you end up using streams that were otherwise used to serve requests from clients.

Here is an ASP.NET multithreading tutorial that can help you forward a little.

0
source

Source: https://habr.com/ru/post/1708413/


All Articles