在负载均衡环境中是否值得将会话状态信息保存在httpcontext或请求cookie中?

发布于 2024-08-23 02:38:34 字数 82 浏览 1 评论 0原文

在负载平衡服务器环境中,是否可以在 httpcontext 或请求 cookie 中维护会话状态。

它会导致任何性能问题或安全问题吗?

In load balancing server environment is it possible to maintain the session state in httpcontext or request cookie.

Does it cause any performance issue or security issue?

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

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

发布评论

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

评论(3

凉城已无爱 2024-08-30 02:38:34

假设您的 cookie 已加密,那么这不应该是安全问题,但如果您有大量会话,则会导致大量额外流量。我认为您需要更清楚地将会话状态存储在 httpcontext 的哪一部分。

Assuming your cookie is encrypted it shouldn't be a security issue, but if you have a lot of session it will cause a lot of extra traffic. I think you need to be more clear about what part of httpcontext you would store the session state in.

夜巴黎 2024-08-30 02:38:34

上下文通常是请求驱动的(因此不会持久)。

您可以将内容保存到 cookie,但除非您对 cookie 进行签名,否则它们是不安全的。但这(自然)会对性能造成影响。

最合乎逻辑的方法是将会话存储移动到共享平台。我不知道你在使用什么,但更高版本的 IIS 有共享会话的方法,如果你使用 Django 之类的东西,你可以在 Memcached 之类的东西上托管会话。

大多数平台还可以选择将会话存储在数据库中。如果您的数据库速度快且平衡良好,那么这是可以的。

如果您的所有计算机都位于同一个数据中心,那么分布式专用会话服务器是迄今为止最好的解决方案。

Context is usually request driven (so doesn't persist).

You can save things to cookie but they're insecure unless you go about signing your cookies. But this (naturally) has a performance hit.

The most logical method is to move your session store to a shared platform. I don't know what you're using but later versions of IIS have methods for sharing the session and if you're using something like Django, you can host the session on something like Memcached.

Most platforms also have the option of storing the session in the database. This is okay if your DB is fast and well balanced.

A distributed, dedicated session server is by far the best solution if all your machines are in the same datacentre though.

梦太阳 2024-08-30 02:38:34

如果您确实希望在服务器场中拥有相同的会话,请使用进程外分布式会话状态提供程序,即 ASP Net Session 甚至更好的 memcached、SOSS State Server 等。

If you really want to have the same session in a server farm, use out of proc distributed session state provider i.e. ASP Net Session or even better, memcached, SOSS State Server, and many others.

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