A Gearman powered application consists of three parts:
Client: The client is responsible for creating a job to be run and sending it to a job server. Here we choose which method form worker need to invoke.
Job Server: The job server will find a suitable worker that can run the job and forwards the job on.
Worker: The worker performs the work requested by the client and sends a response to the client through the job server. Here we define our methods to be executed as required by client.
Gearman provides client and worker APIs that our applications call to talk with the Gearman job server (also known as gearmand) so we don’t need to deal with networking or mapping of jobs
Before installing gearmand we need install Gearman’s dependencies
I have used yum to install the required dependencies:
# yum install gcc-c++ # yum install gperf # yum install uuid-devel # yum install libuuid libuuid-devel # yum install uuid boost-devel # yum install libevent libevent-devel
Installation of gearmand (job server)
I have chosen share directory for gearman installation.
# cd /usr/share # wget https://launchpad.net/gearmand/1.2/1.1.8/+download/gearmand-1.1.8.tar.gz # tar xzf gearmand-1.1.8.tar.gz Run ./configure –help, to see a list of configurable variables. {I have not used any custom variable by my own} # ./configure # make # make install
The job server has been installed and can be started by
gearmand –d
check the running of gearmand job server by ps -fax command.
Now to code Gearman’s client and worker process we need to install Gearman PHP extension.
Reference:
Install Gearman PHP extension
Getting started with Gearman