Gearman-combined with php (1) a Scheduling module is required for the project to schedule scheduled tasks and conditional trigger tasks (such as by traffic. My design is: a scanner regularly scans unstarted tasks in the database, sends the tasks to gearman one by one, and gearman delivers the tasks to workers. The worker judges the task trigger conditions in a distributed manner. if the trigger conditions are met, the encapsulated task is sent to gearman and gearman is distributed to workers. The workers executes the task.
Running architecture of gearman:
Gearman's client & worker api supports many languages and I need php. There are two types of php: Gearman Extension and php Extension. it is an Extension that encapsulates the libgearman c library. to load php by using the so extension module, take the following steps: install libgearman (libevent should be installed before), and then install the php gearman extension using pecl; the other is Net_Gearman, which is a pure php library and can be implemented between pear and require.
Here I also figured out the difference between pecl and pear:
Pear: it is an extension code package of PHP. all extensions are in the form of PHP code. they are powerful and easy to install, and can even be used after modification. You must Include it in the code before using it.
Pecl: it is a standard extension of PHP and can supplement the functions required in actual development. all extensions need to be installed and configured in php. ini to restart php.
When I installed Gearman Extension, I encountered n problems. I gave up and switched to Net_Gearman.
Installation:
Pear install Net_Gearman
It is usually decompressed here:
Php/lib/php/Net/Gearman
Api documentation
I found a Net_Gearman tutorial written by a foreigner. it feels pretty good. there are some examples in it. I ran an example and then learned and tested each example.