Beanstalk, Pheanstalk and Priorities
[pyg language=”php”]
useTube(“scorem”)->put(json_encode(array(“action” => “my_important_task”)), LOW_PRIORITY);
[/pyg]
This will add the job to the queue, but anything with a higher priority value (where 1 is the highest priority!) will take precendence. This way I can add as many non-urgent jobs as I want to to the queue without impacting my website performance. My setup has multiple workers and also I tend to write a script that puts loads of tiny jobs on the queue rather than putting one monster task on there. I find this approach a bit more fault-tolerant and also means that incoming tasks can get a chance to get serviced rather than waiting for some crazy huge thing to finish.
I had real issues finding information about the priority settings for beanstalkd and PHP, so hopefully if anyone is looking for it, they will find this post :)
Pingback: Beanstalk, Pheanstalk and Priorities | Advanced...