ASP.Net 中的会话模式?

发布于 2024-08-11 11:59:15 字数 76 浏览 2 评论 0原文

我应该为我的 ASP.Net 网站实施以下哪种会话模式?

1)进程内。 2)状态服务器。 3)SQL服务器。 4)定制。

Which session mode in the following ,should i implement for my ASP.Net website?

1)InProc .
2)State Server.
3)SQL Server.
4)Custom.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

念﹏祤嫣 2024-08-18 11:59:15

这完全取决于您的情况以及您希望运营的网站类型。

我怀疑您预期的流量及其运行的硬件也是一个重要因素。

您能给我们更多信息吗?

性能注意事项

  • InProc - 最快,但会话数据越多,Web 服务器上消耗的内存就越多,这可能会影响性能。

  • StateServer - 在存储基本类型(例如字符串、整数等)数据时,在一个测试环境中它比 InProc 慢 15%。但是,如果您存储大量数据,序列化/反序列化的成本可能会影响性能
    的物体。你必须针对自己的场景进行性能测试。

  • SQLServer - 在存储基本类型(例如字符串、整数等)数据时,在一个测试环境中它比 InProc 慢 25%。关于序列化的警告与 StateServer 中的警告相同。

鲁棒性

  • InProc - 如果工作进程 (aspnet_wp.exe) 回收,或者应用程序域重新启动,会话状态将会丢失。这是因为会话状态存储在应用程序域的内存空间中。有关详细信息,请参阅 KB324772

  • StateServer - 解决InProc模式下会话状态丢失问题。允许网络场在中央服务器上存储会话。状态服务器上的单点故障。
    SQLServer - 类似于 StateServer。此外,会话状态数据可以在 SQL Server 重新启动后继续存在,并且在按照知识库 311029

以上摘自 Peter A. Bromberg 的文章,可在此处获取

It depends entirely on your circumstances and the type of website you wish to operate.

I suspect your expected volumes of traffic and the hardware it is running on is also a large factor.

Can you give us more information.

Performance considerations

  • InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.

  • StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing lots
    of objects. You have to do performance testing for your own scenario.

  • SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.

Robustness

  • InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. For details, see KB324772.

  • StateServer - Solve the session state loss problem in InProc mode. Allows a webfarm to store session on a central server. Single point of failure at the State Server.
    SQLServer - Similar to StateServer. Moreover, session state data can survive a SQL server restart, and you can also take advantage of SQL server failover cluster, after you've followed instructions in KB 311029.

The above is an extract from an article by Peter A. Bromberg available here

笑咖 2024-08-18 11:59:15

没有一个明确的答案。这取决于您的应用程序的工作方式、您拥有多少服务器、您对故障的容忍程度等。我会仔细阅读差异,然后做出明智的选择。

如果您从一开始就将会话中存储的所有内容都设置为可序列化,那么从一种模式切换到另一种模式通常相当容易,除非您使用 Session_End 事件之类的事件,该事件仅在 proc 模式下使用时才会触发。

There's no one clear answer. It depends on how your app works, how many servers you have, what your tolerance for failure is etc. I would read up on the differences and then make an informed choice.

Providing you make everything that you are storing in the session serializable from the beginning, it is usually fairly easy to switch from one mode to another, unless you are using things like the Session_End event, which only fires when using in proc mode.

花开柳相依 2024-08-18 11:59:15

默认值是 InProc,对于大多数中小型网站来说效果很好。您只需使用它,根本不需要实现任何东西。

如果您有任何特殊情况,例如负载平衡服务器或大量用户,您将需要一些其他方法。

The default is InProc, and that works fine for most small and moderate size web sites. You just use it, you don't have to implement anything at all.

If you have any special curcomstances, like load balanced servers or extreme amounts of users, you would need some of the other methods.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文