Generally, the integration between multi-language and multi-system is a big problem. Generally speaking, people will use WebService to deal with such integration problems, no matter what style is used. WebService, such as RPC style, or REST style, has its own complexity. In contrast, Gearman can achieve a similar effect, and is easier to use. The processing of a Gearman request involves three roles: Client -> Job -> Worker. Client: The originator of the request, which can be C, PHP
, Perl, MySQL UDF, etc. Job: The dispatcher of the request, responsible for coordinating the forwarding of requests from the client to the appropriate Work. Worker: The handler of the request, which can be C, PHP, Perl, etc. Because Client, Worker does not restrict the use of the same language, it is conducive to the integration between multi-language and multi-system. Even by adding more workers, we can easily implement a distributed load balancing architecture for the application. Let's take a look at how to install and run an example. Under the limited conditions, we run the three roles Client, Job, and Worker on a server: Install Gearman server and library: wget http://launchpad.net/gearmand/trunk/0.8 /+download/gearmand-0.8.tar.gztar zxf gearmand-0.8.tar.gzcd gearmand-0.8./configuremakemake install Install Gearman PHP extension:wget http://pecl.php.net/get/gearman-0.4.0. Tgztar zxf gearman-0.4.0.tgzcd gearman-0.4.0phpize./configuremakemake install Edit the php.ini configuration file to load the corresponding module and make it effective: extension = "gearman.so"Start Job:gearmand -d if the current user is For root, you need to do this: geomand -d -u root will use port 4730 by default, which will be used below. Note: If you can't find the path to the gearand command, don't forget to confirm with whereis gearmand. Write the contents of the Worker:worker.php file as follows: <?php$worker= new GearmanWorker();$worker->addServer('127.0.0.1', 4730);$worker->addFunction('reverse', ' My_reverse_function');while ($worker->work());function my_reverse_function($job){ return strrev($job->workload());}?> Set the background to run work:php worker.php & Write the Client:client.php file as follows: <?php$client= new GearmanClient();$client->addServer('127.0.0.1', 4730);echo$client->do('reverse' , 'Hello World!'), "\ ";?>Run client:php client.php output:!dlroW olleH For convenience, Worker, Client uses PHP, but this does not affect the demo In practical applications, you can integrate Worker, Client in different languages through Gearman. Perhaps you still want to understand the load balancing function mentioned earlier: very simple, just add more workers, you can write several similar files according to the way worker.php, and set different return values for Identify the presentation. Then start these Worker files in turn, and use client.php multiple times to request, you will find that the Job will forward the Client request to a different Worker. Command Line Tools If you feel that installing something like PHP is too much trouble, you can also experience Gearman's functionality just by using the command line tool: Start Worker: gearman -w -f wc -- wc -l & Run Client: gearman -f wc < /etc/passwd Specific reference to the official documentation, there are some good PDF.
Computer Store News: first Linux systems for flat panel launch For those who have tired of the N
Too many open files Errors are common faults in Linux systems. Solutions can be easily found on the
Multiple startup files Adding multiple startup files by saying that compilation will be wrong. But t
The repo file is the configuration file of the yum source (software repository) in Fedora. Usually a
Insufficient permissions in /etc/hosts cause database startup failure Solution
DNS polling under Linux combined with Squid reverse proxy
Cygwin supports Chinese configuration
Tip: Linux personalized face clock display
How to use the Linux ssh download command wget
How does Linux solve system problems with fsck?
Linux kernel vulnerability (privilege escalation) instance
Fault location technology on Red Hat Linux
How to use Win10 virtual drive to load and pop up
Win10 windows defender can not open /can not start
My hand through the LAN, intranet remote control Raiders
Win 8 method to achieve F8 into safe mode
Is there any wallpaper software on the computer that can cache wallpapers?
How to completely disable the thumbnail display function under Windows7 system
Windows7 play game tips xlive.dll for invalid Windows image how to solve?
Teach you a trick to quickly get the window used by win7