R
R
radik28062015-09-09 18:02:56
PHP
radik2806, 2015-09-09 18:02:56

Is it possible to create dynamic workers in Gearman?

Good afternoon,
I will describe the problem. Delayed posting in VK, users enter posts into the database and indicate when to send a post. php project. The script runs every 5 minutes, collects a pool of posts to send and posts. Post for a very long time. I want to speed it up by posting in multiple threads, Gearman is my eye. A few questions for those in the know:

  • How Gearman handles tasks in general. 1 worker - 1 process? That is, if I want posts to be sent to 10 threads, do I need 10 running workers?
  • Is it possible to run workers dynamically, I don’t want to keep 10 workers in memory, especially since they are not always needed. I would like to see if there are more than 1000 posts, then I create additional workers. Immediately the question is how to cut them down then

Maybe Gearman is not a very good tool for this task. Who faced with multithreading in php, maybe there are better solutions?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Valentine, 2015-09-09
@gephaest

php.net/manual/en/book.pcntl.php

M
matperez, 2015-09-09
@matperez

Yes, you need to run multiple processes per task. If you want 10 threads, run 10 processes.
I personally used this thing to manage the number of processes https://github.com/brianlmoon/GearmanManager. Completely working solution. It seems like it can increase the number of processes on demand (did not use it).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question