ASP.NET会话状态的"InProc"与"StateServer"的最佳实践 [英] Best practices for 'InProc' vs 'StateServer' for ASP .NET session state

查看:60
本文介绍了ASP.NET会话状态的"InProc"与"StateServer"的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在单个Web服务器(无服务器场)上运行了单个ASP .NET应用程序.目前,我们正在使用默认的"InProc"会话存储.是否值得考虑使用ASP .NET状态服务呢?如果走那条路,我们很可能只是将服务本身与应用程序在同一台机器上运行,因此通过网络进行呼叫以获取和设置会话信息将不是问题.我们之所以考虑这一点,是为了避免在应用程序池回收时避免会话数据丢失.

We have a single ASP .NET application running on a single web server (no farm). For now, we're using the default 'InProc' session storage. Is it worth considering using the ASP .NET state service instead? If we went that route we'd likely just run the service itself on the same machine as the application, so making calls out over the network to get and set session info wouldn't be an issue. The reason we are considering this at all is to help avoid session data being lost when the app pool recycles.

此外,现在还没有使用SQL Server的功能,因此我们只在谈论进程内与状态服务器.

Also, using SQL Server is off the table for now, so we're just talking about in-process vs state server.

在这种情况下,每种模式的优缺点是什么?

What are the pros and cons to each mode in this scenario?

推荐答案

状态服务器要比proc慢一些.您将从中得到的好处是,如果您需要回收应用程序池,那么应用程序的状态(用户会话等)将不受影响.如果您打算将来使用状态服务器,那么我现在就开始使用它.在处理过程中,对象按原样存储在内存中,但是在状态服务器中对象被序列化.如果您打算稍后进行切换,这可能会很麻烦,因为您必须检查存储在状态中的所有内容是否可序列化.如果您从这种限制开始,那么您(在积极地研究该模块时)就会知道什么将起作用,什么将不起作用.

Well the state server is a little slower than in proc. The benefit you will get out of it is that if you need to recycle the app pool, then the state of the application (user sessions etc.) will be unaffected. If you plan on using a state server in the future, I would start using it now. With in process, objects are stored in memory as is, but with the state server they are serialized. This can be a big deal if you plan on making the switch later as you'll have to check that everything you store in state is serializable. If you start out with that restraint, you know up front (while you're actively working on that module) what is going to work and what isn't.

这篇关于ASP.NET会话状态的"InProc"与"StateServer"的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆