高可用性 ASP.NET MVC
当构建具有高可用性目标的 ASP.NET MVC 应用程序时,如果没有可用的状态服务器,将会话状态保留在 SQL Server 上是否是一个好习惯?
When building an ASP.NET MVC application with a goal of high availability, is it a good practice to keep the session state on the SQL Server, if there is no state server available?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里的要点实际上是,您有 2-3 个网络服务器,就像您在对 Craigs 答案的评论中提到的那样。
一种方法是使用 SQL-server sessionstate,它有自己的问题 http://idunno.org/articles/ 277.aspx。
如果你有这个 SQL-Server,我会小心的,因为会话状态数据库会给它带来沉重的负载。每个请求都会写入数据库。
我们使用 2 个网络服务器和一个具有粘性会话的负载均衡器。如果您的第一个请求最终出现在服务器 1 中,那么您的所有请求都由服务器 1 处理。(这有点复杂,但您明白了。)
这可能并不总是最好的解决方案,但至少在我们的网站上(它是用户通常会停留 20-30 分钟的商店)效果很好。我们只使用很少的 SessionState,并且大部分用户特定的内容都由 ProfileSystem 存储。但我想如果请求发送到不同的服务器,ProfileSystem 也会失败。
The point here realy is that you have 2-3 webservers like you mentioned in the comment to Craigs answer.
One way is to use SQL-server sessionstate which has its own problems http://idunno.org/articles/277.aspx.
If you have this one SQL-Server I would be carefull, because the DB for sessionstate will put heavy load on it. Each request will write to the db.
We use 2 webservers and a Loadbalancer that has sticky sessions. If your first request ends up in server 1 then all your requests are handled by server 1. (Its a bit more sophisticated but you get the idea.)
This might not allways be the best solution, but at least on our site (its a shop where user typically stay 20-30minutes) it works well. We use only little SessionState and have most of the userspecific stuff stored by the ProfileSystem. But I guess the ProfileSystem will also fail if requests go to different servers.
我建议改为 AppFabric 缓存(fka Velocity)。
I'd suggest AppFabric Caching (f.k.a. Velocity) instead.