gearman distributed processing system

gearman a distributed processing system. Gearman introduce Gearman architecture is as follows: Gearman is a task distribution program architecture consists of three parts: Gearman client: gearman client API to provide application calls. API can use C, PHP, PERL, MYSQL UDF wait for it a language, it is the initiator of the request. Gearman job server: the client requests are distributed to the respective scheduling gearman worker who acts as a central controller, but it does not handle specific business logic. Gearman worker: providing gearman worker API calls to the application, specifically responsible for the client's request, and the results returned to the client. The core Mogilefs distributed file system is to use gearman achieve. This software application scenarios are many, such as video sites video processing, distributed processing logs, e-mail, file synchronization, image processing and so on, as long as you can let go, do not affect the scenes experience and response requires a large number of parallel calculation and processing procedures are possible. Yahoo gearman use on 60 or more servers to handle 6 million jobs per day. News aggregator digg build a network gearman same size, can handle 400,000 jobs per day. Gearman not only can be used as task distribution, it can also be used as load-balancing applications. Allows worker on a bunch of different servers, you can also start with a plurality of cores on the cpu. For example, video conversion application program, you do not want web servers to handle video format conversion, this time, the task can be distributed on this bunch of servers, load worker process in the above video formats, external web server will not be video conversion process influences. And easy expansion, adding a server to the mission control center, you can register as a worker, then the job server will request at the time of arrival, the request is sent to the idle worker. You can also run multiple job server, composed ha architecture, if a job server crashed, client and worker will automatically migrate to another job server. two. Installation [Job server --- 192.168.1.173] # wget http://nchc.dl.sourceforge.net/project/boost/boost/1.45.0/boost_1_45_0.tar.gz # tar zxvf boost_1_45_0.tar.gz -C ../software/ # ./bjam # ./bjam -s HAVE_ICU=1 --prefix=/home/xuhh/boost-1.45 --includedir=/home/xuhh/boost-1.45/include --libdir=/home/xuhh/boost-1.45/lib # ./bjam install --prefix=/home/xuhh/boost-1.45 # cd /home/xuhh/boost-1.45/lib/ # cp -rf ./* /usr/lib/ # cp -rf ./* /usr/lib64/ # ln -s /home/xuhh/boost-1.45/include/boost /usr/include/boost # wget http://launchpad.net/gearmand/trunk/0.25/+download/gearmand-0.25.tar.gz # tar zxvf gearmand-0.25.tar.gz -C ../software/ # ./configure --prefix=/home/xuhh/gearmand-0.25 --with-boost=/home/xuhh/boost-1.45 # make # make install # /home/xuhh/gearmand-0.25/sbin/gearmand –d //启动gearmand服务 --- [192.168.1.101] Gearmand installation worker shown above # wget http://pecl.php.net/get/gearman-0.7.0.tgz # tar zxvf gearman-0.7.0.tgz -C ../software/ # phpize5 # ./configure --prefix=/usr/local/gearman-0.7.0 --with-php-config=/usr/bin/php-config5 --with-gearman=/usr/local/gearmand-0.25 # make # make install # vim /etc/php5/conf.d/gearman.ini //添加如下一行 extension=gearman.so # php -i | grep gearman //查看gearman是否加载 /etc/php5/cli/conf.d/gearman.ini, gearman gearman support => enabled libgearman version => 0.25 [---] Client installation worker the same as shown above. three. Test establish worker # vi worker.php $worker= new GearmanWorker(); $worker->addServer("192.168.1.173",4730); $worker->addFunction("ttlsa", "ttlsa_function"); while ($worker->work()); function ttlsa_function($job) { return ucwords(strtolower($job->workload())); } ?> applications on # php worker.php // worker continuous operation, serving clients establish vi client.php # client.php $client= new GearmanClient(); $client->addServer("192.168.1.173",4730); print $client->do("ttlsa", "www.ttlsa.com"); print "\n"; ?> # PHP client.php

Reproduced in: https: //my.oschina.net/766/blog/211288

Guess you like

Origin blog.csdn.net/weixin_34235105/article/details/91547564