SQLServer 与 StateServer 的 ASP.NET 会话状态性能比较
我正在学习 MS 认证,我正在进行的练习测试之一有一个问题,争论的焦点是在 SQL Server 中存储会话与在 StateServer 中存储会话之间的性能。
考虑到应用程序在网络场中运行,哪种会话状态解决方案可提供最佳性能(SQL Server 或 StateServer),最重要的是,为什么?
I'm studying for a MS certification and one of the practice tests I'm doing has a question where the point of contention is the performance between storing the session in SQL Server as opposed to StateServer.
Given the app is running in a web farm, which solution for session state gives the best performance (SQL Server or StateServer) and most importantly, why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
状态服务器速度更快,因为它将会话数据存储在内存字典中。 SQL Server 速度较慢,因为它存储在将数据保存到磁盘的数据库中。
SQL Server 也较慢,因为所有内容都存储在一张表中,随着越来越多的客户端访问/更新会话数据,这会导致争用。
SQL Server更可靠,因为它持久保存到磁盘上,并且可以设置为具有故障转移功能的集群。
有关深入说明,请参阅本文中的序言。
State Server is faster because it stores session data in an in-memory dictionary. SQL Server is slower because it's stored in a database which persists data to disk.
SQL server is also slower because everything is stored in one table which leads to contention as more and more clients access/update the session data.
SQL server is more reliable because it is persisted to disk and can be set up as a cluster with failover capability.
See the preamble in this article for an indepth explanation.
一点但很重要的旁注:InProc 不能在场中使用,顾名思义,它在当前的 w3wp 进程中运行,并且不能在场中共享。 StateServer是一个Windows服务,所以使用StateServer的速度取决于stateserver服务运行的机器的速度,它只是内存。 SQL当然需要写入数据并检索,这可能比仅使用内存慢。
来自此处:
A little, but important sidenote: InProc is not usable in a farm, as the name suggests, it runs in the current w3wp proces and cannot be shared across a farm. StateServer is a Windows service, so the speed of using StateServer is dependend on how fast the machine the stateserver service is running on, it is memory only. SQL of course needs to write the data and retrieve, which is probably slower than memory only.
From here:
通过此链接:http://www.eggheadcafe.com/articles/20021016.asp
因此,StateServer 存储会话状态的速度似乎比 SQL Server 快一些。
就原因而言,我建议 SQL Server 具有更多用途,并且也可能用于其他用途。不仅如此,存储机制是磁盘,因为 StateServer 在单独的进程中运行,但它只是将数据存储在另一个进程的内存空间中,而不是必须将其写入磁盘(虚拟内存允许)
From this link: http://www.eggheadcafe.com/articles/20021016.asp
So it would seem that StateServer is a little faster that SQL Server for storing session state.
In terms of the why, I'd suggest that the SQL Server is more multi-purpose and will likely be used for other things as well. Not only that but the storage mechanism is to disk, where as the StateServer is running in a separate process, yet it is simply storing the data in the memory space of the other process rather than having to write it to disk (virtual memory permitting)
SQL Server(内存中)就是答案 - SQL 2014 中提供
http://blogs.msdn.com/b/kenkilty/archive/2014/07/03/asp-net-session-state-using-sql -内存中服务器.aspx
SQL Server (In Memory) is the answer - available in SQL 2014
http://blogs.msdn.com/b/kenkilty/archive/2014/07/03/asp-net-session-state-using-sql-sever-in-memory.aspx