开发者

Does the continuously running thread in background impact the website's performance?

In my website I am using thread to perform the function which downloads the CSV from a website and parses the data into the database.

Now if I am not able t开发者_C百科o stop the thread then what could be the impact on the performance?

Also If I unknowingly start another thread then would it impact my website's performance?

Thanks.


Is the thread triggered as part of a user interaction? If not, then it would be better run external to the website, say via windows scheduler.

IIS uses threads to service inbound requests. So starting lots of threads could impact the ability of IIS to handle new requests. This article may help

Threadpool in IIS context

If you're responding to user input then you won't really upset your site. Websites tend to be more memory bound than CPU bound, so the CPU can generally cope with a few extra threads.

Simon


A thread as a structure has limited impact when it's not doing anything (~1MB memory), it does have impact however when:

  • There are many threads, as the OS has to continually switch between them. Only so many threads can run at the same time, so they have to take turns. If there are lots of threads then management and swapping can cause considerable overhead.
  • The threads are doing a lot of work, so resources they are using are contended e.g. CPU and disk.

Your thread is running on the same hardware as your website so it will be taking a share of the resources. If you have many cores, then a single busy thread should not cause too many problems, that is unless you have a very busy website. What could be more of an issue is that your thread is hammering the disk drive. This resource tends to deal less well with concurrent heavy access. If you website does not need disk access, this is less of a problem.

If your thread is occasionally downloading a CSV file and shredding it into the DB, there should be no problem with this running concurrently with your website.


If you are using the ThreadPool to create a work item, then yes this will directly take away a thread that would otherwise be used to serve requests for your site, using Thread directly wont impact your sites ability to serve requests however, too many threads eating up cpu or io will degrade your sites responsiveness definatly. What you are looking for is that sweet spot, where you get the benefits of multi threading without committing to much resources for your site to respond to requests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜