Gearman-integration with php (1)

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.