如何使用 RackSpace Cloud 进行会话管理?

发布于 2024-09-10 03:14:14 字数 170 浏览 2 评论 0原文

如果我运行两个以上的服务器实例(使用rackspace-cloud 的IP 组),如何使用PHP 管理我的会话?

有没有办法让用户“粘”在他们最初登录的服务器上?我确实使用 memcached,但所有云系统上都有 memcached,我需要确保用户会话到达正确的服务器。

我不希望出现单点故障。

If I am running more than two instances of a server (using rackspace-cloud's ip groups), how do I manage my sessions with PHP?

Is there a way to make users 'sticky' to the server they logged into originally? I do use memcached, but all of the cloud systems have memcached on them, I need to insure a users session gets to the right server.

I do not want a single point of failure.

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

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

发布评论

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

评论(1

韬韬不绝 2024-09-17 03:14:14

使用文件以外的东西进行会话管理。 PHP 允许您覆盖处理程序。我使用内存缓存。它还有一个 PECL 扩展: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

这是另一篇关于它的文章:http://www.ducea.com/2009/06/02/php-sessions-in-memcached/

更新

要解决评论中的问题:

这允许您使用一组中央内存缓存计算机进行会话。每个服务器不会在本地查看其文件系统,而是会查看您定义的中央内存缓存集群。

Memcache 集群可以有任意数量的机器,以避免单点故障。以下是 php.ini 中的示例配置:

extension=memcache.so
memcache.allow_failover = 1
内存缓存冗余 = 1
memcache.session_redundancy = 2
;使用 memcache 作为会话处理程序
session.save_handler = 内存缓存
;使用逗号分隔的服务器 URL 列表用于存储:
session.save_path="udp://:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

Use something other than files for session management. PHP allows you to overwrite the handler. I use memcache. There is a PECL extension for it as well: http://www.dotdeb.org/2008/08/25/storing-your-php-sessions-using-memcached/

Here's another article on it: http://www.ducea.com/2009/06/02/php-sessions-in-memcached/

UPDATE

To address issues from the comments:

This allows you to use a central set of memcache machines for sessions. Instead of each server looking locally at its filesystem, it will look to a central memcache cluster you define.

The memcache cluster can be as many machines as you like, to avoid a single point of failure. Here is an example config from php.ini:

extension=memcache.so
memcache.allow_failover = 1
memcache.redundancy = 1
memcache.session_redundancy = 2
; Use memcache as a session handler
session.save_handler = memcache
; Use a comma separated list of server urls to use for storage:
session.save_path="udp://:11211?persistent=1&weight=1&timeout=1&retry_interval=15"

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