2
votes

I'm using Gearman Job server in my project. I use 'gearman-ruby' gem. There is a queue of tasks in app. One task have 4 parts.
Appropriately I have 4 workers to solve this parts of task.

My system solve 1 task in 10minutes without gearman. But when I use gearman, time to solve 10 tasks are 2-3 hours :(
Gearman queue are located in mysql. The queue are overflows.

Cron starts clients, which set tasks. one task - parse one page. 1st worker - get page(init), 2nd - get photos(images), 3rd - get comments(text), 4rd - get characteristics(text). 1st worker get pages, other workers parse different data from this pages.

gearman configs:



    $cat /etc/sysconfig/gearmand 
    ## Settings for gearmand
    OPTIONS="--listen=127.0.0.1
             --job-retries=3 \
             --log-file=/var/log/gearman.log \
             --queue-type=MySQL \
             --mysql-host=localhost \
             --mysql-port=3306 \
             --mysql-db=gearman \
             --mysql-table=queue"

    $gearmand --version
    gearmand 0.35

Help me please to setup gearman for speed working

1
You're offering too little to work with. Please add more details: (To a reasonable extend) the nature of the tasks, the current server setup , the code that do the actual processing (workers). As the description stands the problem could be anything / everything. - fmendez
Client set task, but I see this task in gearman.queue (table in mysql) after 10-15minutes. And there's a looong delay before worker start doing his task. I watching it when I'm testing gearman by only 1 task. That's why I think the problem is in german settings... - bmalets
add "--threads=12" into configs. Delay before worker start doing his task is significantly reduce. But Gearman still work very slowly... And queue are overflowed with tasks. Tasks a solved, but there're still in the gearman.queue :( - bmalets
I found an event in my code, through which task doesn't return 'true'. In gearman protocol, compleated task must return 'true'. My roblem is solved :) - bmalets
thanks a lot, fmendez! - bmalets

1 Answers

2
votes
  1. I found an event in my code, through which task doesn't return 'true'. In gearman protocol, compleated task must return 'true'.
  2. I setup gearman config without persistance storage.


    OPTIONS="--listen=127.0.0.1
                 --job-retries=3 \
                 --log-file=/var/log/gearman.log \
                 --threads=12"

З. I add more threads for gearman job-server with '--threads=threds_count' parameter.

And now my system works fast and stable! :)


If you using persistance storage and your queue are overflowing: you can periodically run script to clean gearman_queue. I solved it with periodically calling sh script ( I use cron for this ):



    # stop gearman
    sudo /etc/init.d/gearman stop
    # delete tasks from DB
    mysql -Bse 'DELETE FROM queue' gearman -u root
    # start gearmand back
    sudo /etc/init.d/gearman start
    echo '*** gearman queue cleaned. ***'