开发者

Threads and requests confusion

开发者 https://www.devze.com 2022-12-20 10:44 出处:网络
If I have a site and each request has its own thr开发者_运维百科ead, does this mean that 1000 visitors will spawn 1000 threads? How does this work (obviously that can\'t be right)?

If I have a site and each request has its own thr开发者_运维百科ead, does this mean that 1000 visitors will spawn 1000 threads? How does this work (obviously that can't be right)?

Thanks


Threads in ASP.NET are handled via a ThreadPool.

Requests are pooled across the ThreadPool, so each request can be handled by a different thread, but the threads can be reused, preventing the 1000 threads for 1000 requests scenario you mentioned.

For more details, see this CodeProject article on Multi-Threading in ASP.NET.


Yes, it is right. If you have 1 thread per visitor and 1000 visitors that makes for 1000 threads. It may not perform well, but that's another matter.

Fr multi-threaded server applications, you typically have 3 different allocation systems:

  • 1 thread for all visitors - each one takes it in turn;
  • 1 thread per visitor - obvious;
  • a combination fo the 2 - 1 pool of threads (say 10) and visitors get 1 each until thet're all used whereupon new visitors wait.
0

精彩评论

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

关注公众号