我有2个服务器运行每个repcached实例。 Php配置为在那里保存会话。
复制2台服务器以实现冗余
问题是我正在用ab做一些基准测试。运行
ad -n 10000 -c 500 http://mysite
我在apache错误日志中遇到了一些错误 无法写入会话数据
查看两个服务器上的listen_disabled_num,它为0,因此不提供任何连接
顺便说一句,我将最大连接数设置为4096
有什么想法吗?
由于
答案 0 :(得分:0)
在会话数据大于Memcache的1MB屏障之前,我遇到过这个问题。我通过压缩会话数据,然后将其存储在Memcache中来解决它。
这是我正在使用的代码:
<?php
class SessionHandler {
public $lifeTime;
public function __construct() {
$this->lifeTime = intval(ini_get("session.gc_maxlifetime"));
session_set_cookie_params(0,"/",".domain.com",false,true);
session_name("SITESESSION");
session_set_save_handler(array (&$this,"open"),array (&$this,"close"),array (&$this,"read"),array (&$this,"write"),array (&$this,"destroy"),array (&$this,"gc"));
session_start();
}
public function open($savePath,$sessionName) {
return true;
}
public function close() {
return true;
}
public function read($sessionID) {
# The default miss for MC is (bool) false, so return it
return MC::get("userSession_{$sessionID}");
}
public function write($sessionID,$data) {
# This is called upon script termination or when session_write_close() is called, which ever is first.
return MC::set("userSession_{$sessionID}",$data,$this->lifeTime,true); # The last true sets it as compressed.
}
public function destroy($sessionID) {
# Called when a user logs out...
return MC::delete("userSession_{$sessionID}");
}
public function gc($maxlifetime) {
# The MC keys expire on their own, no need to do anything here.
return true;
}
}
?>