进程外的会话变量会导致内存问题吗?
在我当前的 asp.net
应用程序中,我将会话变量
存储在SQL 服务器
中。如果您指定InProc,则会话将保存在服务器内存中,但对于out of proc(在我的例子中),会话将保存在SQL Server 中。
这是真的吗?根据我的阅读,每个需要会话访问的请求(基本上每个页面请求)都会从数据库反序列化会话,并在请求完成后将其保存回来。这意味着一旦检索到这些值,就会将其保留在 Web 服务器上。那么这与 InProc
有什么不同呢?
对于Out of Proc
,它是否仅在请求时检索一个会话变量?否则,在我看来它与 InProc
相同。我缺少什么。
In my current asp.net
application, i'm storing the session variables
in the SQL server
. If you specify InProc
, then the session is kept in the server memory, but for out of proc
(in my case), the session is kept in SQL server.
Is this really true? From what I read, with every request that needs session access (basically every page request) will deserialize the session from db and save it back once the request completes. This means that the values will be kept on the web server once it is retreived. How is this different from the InProc
then?
For Out of Proc
, does it only retreive the one session variable when that is requested for? Otherwise, it sounds to me like it is the same as InProc
. What am I missing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这是真的。
仅在 HTTP 请求期间,值才会存储在内存中。在请求开始时,它们从 SQL Server 加载,在请求结束时,它们被保存到 SQL Server 中。这与 InProc 不同,在 InProc 中,值在请求之间保存在内存中。由于不同的请求(来自同一用户)可能由服务器场中的不同节点提供服务,因此使用 SQL Server 可保证场中的所有节点共享相同的会话值。
Yes, it's true.
Values are stored in memory only for the duration of the HTTP request. In the beginning of the request they are loaded from SQL Server and at the end of the request they are saved into SQL Server. This is different than InProc where values are kept into memory between requests. And because different requests (from the same user) could be served by different nodes in your server farm, using SQL Server guarantees that all nodes of the farm will share the same session values.