ASP.NET单工线程? (在内存会话中)

时间:2021-07-06 20:58:09

I'm using in memory sessions in my ASP.NET MVC application which means that I can only have one single worker thread correct? Does this mean I have parallel processing in my application (think concurrent requests) or not? Does my application accept only 1 request at a time?

我在ASP.NET MVC应用程序中使用内存会话,这意味着我只能有一个单独的工作线程正确吗?这是否意味着我在我的应用程序中进行并行处理(想想并发请求)?我的申请一次只接受1个请求吗?

Edit: According to the IIS7 web site:

编辑:根据IIS7网站:

If the application uses in-process session variables, 
the application will not function correctly, because the same user requests 
are picked up by different worker processes that 
do not share the same session details.

So this means in-memory session can only have 1 worker thread or not? See also here from the IIS7 forums.

那么这意味着内存中的会话只能有1个工作线程吗?另请参见IIS7论坛。

2 个解决方案

#1


3  

Your application receives multiple requests at a time. Based on your edits and comments here you are looking for information on Web Gardens and sessions, as opposed to threads and session state.

您的应用程序一次收到多个请求。根据您在此处的编辑和评论,您正在寻找有关Web Gardens和会话的信息,而不是线程和会话状态。

Web Gardens use multiple processes and act like a load balancer when it comes to session state. Each process will have a separate in memory session store. IIS will send requests to any available process. Since the processes do not share session state then session usage will only really work if your session provider is shared between all the web garden processes.

Web Gardens使用多个进程,在会话状态方面就像负载均衡器一样。每个进程都有一个单独的内存会话存储。 IIS将向任何可用进程发送请求。由于进程不共享会话状态,因此只有在所有Web园进程之间共享会话提供程序时,会话使用才会真正起作用。

Web Gardens only make sense if you use something like SQL Server for session state, and want to have affinity with a particular CPU/core. Since you can increase the number of threads this may be a more appropriate optimization for some users than using web gardens. However some applications may perform better with web gardens due to a particular work load or application characteristic. Use of web gardens in testing could also help work out some potential issues present under load balancing.

Web Gardens只有在使用类似SQL Server的会话状态时才有意义,并希望与特定的CPU /核心具有亲缘关系。由于您可以增加线程数,因此对于某些用户而言,这可能比使用Web园更合适。然而,由于特定的工作负荷或应用特性,一些应用可能在网络花园中表现更好。在测试中使用网络花园也可以帮助解决负载平衡下存在的一些潜在问题。

I believe it uses the .NET ThreadPool and has 20 threads by default. The each request coming into the server may be handled on a separate thread. The ASP.NET performance guidelines have some information on this topic.

我相信它使用.NET ThreadPool并且默认有20个线程。进入服务器的每个请求可以在单独的线程上处理。 ASP.NET性能指南提供了有关此主题的一些信息。

#2


-1  

In memory sessions means you should typically only have one front-end web server at a time, not a single worker thread :D

在内存会话中意味着您通常一次只能有一个前端Web服务器,而不是单个工作线程:D

The reason being that any information stored in session on one machine is not available on the other. If you have two front-end web servers and your proxy or firewall does "load-balancing" whereby it will randomly assign requests to web servers, then you will have problems. That said, the problem is easily solved with so called "sticky sessions" where users are always sent to the same server.

原因是在一台机器上的会话中存储的任何信息在另一台机器上都不可用。如果您有两个前端Web服务器,并且您的代理或防火墙执行“负载平衡”,它会随机将请求分配给Web服务器,那么您将遇到问题。也就是说,问题很容易通过所谓的“粘性会话”来解决,其中用户总是被发送到同一服务器。

-Oisin

-Oisin

#1


3  

Your application receives multiple requests at a time. Based on your edits and comments here you are looking for information on Web Gardens and sessions, as opposed to threads and session state.

您的应用程序一次收到多个请求。根据您在此处的编辑和评论,您正在寻找有关Web Gardens和会话的信息,而不是线程和会话状态。

Web Gardens use multiple processes and act like a load balancer when it comes to session state. Each process will have a separate in memory session store. IIS will send requests to any available process. Since the processes do not share session state then session usage will only really work if your session provider is shared between all the web garden processes.

Web Gardens使用多个进程,在会话状态方面就像负载均衡器一样。每个进程都有一个单独的内存会话存储。 IIS将向任何可用进程发送请求。由于进程不共享会话状态,因此只有在所有Web园进程之间共享会话提供程序时,会话使用才会真正起作用。

Web Gardens only make sense if you use something like SQL Server for session state, and want to have affinity with a particular CPU/core. Since you can increase the number of threads this may be a more appropriate optimization for some users than using web gardens. However some applications may perform better with web gardens due to a particular work load or application characteristic. Use of web gardens in testing could also help work out some potential issues present under load balancing.

Web Gardens只有在使用类似SQL Server的会话状态时才有意义,并希望与特定的CPU /核心具有亲缘关系。由于您可以增加线程数,因此对于某些用户而言,这可能比使用Web园更合适。然而,由于特定的工作负荷或应用特性,一些应用可能在网络花园中表现更好。在测试中使用网络花园也可以帮助解决负载平衡下存在的一些潜在问题。

I believe it uses the .NET ThreadPool and has 20 threads by default. The each request coming into the server may be handled on a separate thread. The ASP.NET performance guidelines have some information on this topic.

我相信它使用.NET ThreadPool并且默认有20个线程。进入服务器的每个请求可以在单独的线程上处理。 ASP.NET性能指南提供了有关此主题的一些信息。

#2


-1  

In memory sessions means you should typically only have one front-end web server at a time, not a single worker thread :D

在内存会话中意味着您通常一次只能有一个前端Web服务器,而不是单个工作线程:D

The reason being that any information stored in session on one machine is not available on the other. If you have two front-end web servers and your proxy or firewall does "load-balancing" whereby it will randomly assign requests to web servers, then you will have problems. That said, the problem is easily solved with so called "sticky sessions" where users are always sent to the same server.

原因是在一台机器上的会话中存储的任何信息在另一台机器上都不可用。如果您有两个前端Web服务器,并且您的代理或防火墙执行“负载平衡”,它会随机将请求分配给Web服务器,那么您将遇到问题。也就是说,问题很容易通过所谓的“粘性会话”来解决,其中用户总是被发送到同一服务器。

-Oisin

-Oisin