[文章作者:张宴 本文版本:v1.0 最后修改:2009.11.01 转载请注明原文链接:http://blog.s135.com/dips/]
2009年10月28日,在金山逍遥技术支持部内部分享会上,介绍了Gearman分布式计算框架与金山逍遥DIPS分布式图片处理平台,以下是PPT图片:









PDF版本下载:
下载文件
附1:Gearman分布式计算框架网址
http://gearman.org/
附2:PHP客户端Gearman扩展安装:
php.ini文件中增加:
附2:Gearman调度器安装(JOB Server):
以守护进程启动:
2009年10月28日,在金山逍遥技术支持部内部分享会上,介绍了Gearman分布式计算框架与金山逍遥DIPS分布式图片处理平台,以下是PPT图片:









PDF版本下载:

附1:Gearman分布式计算框架网址
http://gearman.org/
附2:PHP客户端Gearman扩展安装:
wget http://www.monkey.org/~provos/libevent-1.4.12-stable.tar.gz
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable/
./configure --prefix=/usr
make && make install
/sbin/ldconfig
cd ../
wget http://launchpad.net/gearmand/trunk/0.9/+download/gearmand-0.9.tar.gz
tar zxvf gearmand-0.9.tar.gz
cd gearmand-0.9/
./configure
make
make install
/sbin/ldconfig
cd ../
wget http://pecl.php.net/get/gearman-0.5.0.tgz
tar zxvf gearman-0.5.0.tgz
cd gearman-0.5.0
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-gearman
make
make install
cd ../
tar zxvf libevent-1.4.12-stable.tar.gz
cd libevent-1.4.12-stable/
./configure --prefix=/usr
make && make install
/sbin/ldconfig
cd ../
wget http://launchpad.net/gearmand/trunk/0.9/+download/gearmand-0.9.tar.gz
tar zxvf gearmand-0.9.tar.gz
cd gearmand-0.9/
./configure
make
make install
/sbin/ldconfig
cd ../
wget http://pecl.php.net/get/gearman-0.5.0.tgz
tar zxvf gearman-0.5.0.tgz
cd gearman-0.5.0
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-gearman
make
make install
cd ../
php.ini文件中增加:
extension = "gearman.so"
附2:Gearman调度器安装(JOB Server):
wget http://launchpad.net/gearmand/trunk/0.9/+download/gearmand-0.9.tar.gz
tar zxvf gearmand-0.9.tar.gz
cd gearmand-0.9/
./configure
make
make install
/sbin/ldconfig
cd ../
tar zxvf gearmand-0.9.tar.gz
cd gearmand-0.9/
./configure
make
make install
/sbin/ldconfig
cd ../
以守护进程启动:
gearmand -L 192.168.0.1 -p 4730 -u root -d
不过为什么在系统负载对比处的对比指标不一样呢?
2 使用gearman需要考虑下系统的安全性问题
<kangglmail@163.com>
你觉得目前使用gearman有会带来哪些安全隐患呢?
1、将生成图片的操作转移到了专用的29台图片处理服务器上,故新架构webserver负载大大降低
2、gearman只是起到了类似LVS的功能,并未体现出其他作用。
替换gearman只需类似如下代码就可实现:
//图片处理服务器列表
$imageHandlerServers = array(
array('ip' => '', 'port' => 9527),
... * n
);
//取随机数
$randomServerId = random(1, count($imageHandlerServers));
$imageHandlerServer = $imageHandlerServers[$randomServerId];
//生成图片
$image = genImage($imageHandlerServer, $data);
1、gearman有完善的调度作用。普通的array数组+随机数无法保证负载的均衡,无法根据后端Worker的繁忙程度做调度分发。
2、gearman能够实现故障转移与高可用。如果后端的一台Worker进程有故障,gearman能够不把请求分发到故障服务器。而array数组+随机数,仍然会将请求发送到发生故障的Worker服务器上。
2、按照DIPS中的程序,我不清楚$image=$dips.do(***),这段代码返回的是图片对象还是图片地址,如果是图片对象,那么是否流量会堆积在job server上?
3、如果某台worker有问题,用数组+随机数方式可改进一下,如果执行失败,可再尝试另一台worker,可在一定程度上实现故障转移。
另外,对于job server,如果访问量巨大,job server是否会成为瓶颈?由于我没有研究过gearman底层负载均衡的方式,这个请博主解答一下~
对于新老架构负载对比图,个人觉得意义不大,新架构只是把高负载的任务由webserver拆到了worker上,并不是由于引进gearman而带来根本上的负载降低,有误导新手的嫌疑
4台client,分成2组,连接到2台JobServer上,4台Worker分别都连接到2台JobServer上。
有一个问题:
对于worker来说,没有问题,同时为2台JobServer提供服务。
当1台JobServer故障,4台client中,就有2台就服务连接到JobServer了,无法进行服务了。这样必然有相当部分的用户收到了影响。
有没有现成的方式,client也同时连接到2台JobServer上,当一台JobServer故障,可以自动发送给另外一台运行正常的JobServer,这样实现fail over?
这个问题如何处理的?
从整个架构上来看。gearman所起到的作用确实没有完全表现出来。
既然申请网游密保卡的用户比例相对较小,又和1亿用户数有什么关系呢?预先生成大量密保卡只和绝对用户数有关吧?
如果只是申请时生成,何必用上几十台服务器做这个事呢?
2、gearman只是起到了类似LVS的功能,并未体现出其他作用
我很想了解一下 gearman 比 lvs 有哪些优势?