Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6677391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:06:50+00:00 2026-05-26T04:06:50+00:00

Recently I’ve been researching the use of Beanstalkd with PHP. I’ve learned quite a

  • 0

Recently I’ve been researching the use of Beanstalkd with PHP. I’ve learned quite a bit but have a few questions about the setup on a server, etc.

Here is how I see it working:

  1. I install Beanstalkd and any dependencies (such as libevent) on my Ubuntu server. I then start the Beanstalkd daemon (which should basically run at all times).
  2. Somewhere in my website (such as when a user performs some actions, etc) tasks get added to various tubes within the Beanstalkd queue.
  3. I have a bash script (such as the following one) that is run as a deamon that basically executes a PHP script.

    #!/bin/sh
    php worker.php
    

4) The worker script would have something like this to execute the queued up tasks:

while(1) {
  $job = $this->pheanstalk->watch('test')->ignore('default')->reserve();
  $job_encoded = json_decode($job->getData(), false);
  $done_jobs[] = $job_encoded;
  $this->log('job:'.print_r($job_encoded, 1));
  $this->pheanstalk->delete($job);
}

Now here are my questions based on the above setup (which correct me if I’m wrong about that):

  1. Say I have the task of importing an RSS feed into a database or something. If 10 users do this at once, they’ll all be queued up in the “test” tube. However, they’d then only be executed one at a time. Would it be better to have 10 different tubes all executing at the same time?

  2. If I do need more tubes, does that then also mean that i’d need 10 worker scripts? One for each tube all running concurrently with basically the same code except for the string literal in the watch() function.

  3. If I run that script as a daemon, how does that work? Will it constantly be executing the worker.php script? That script loops until the queue is empty theoretically, so shouldn’t it only be kicked off once? How does the daemon decide how often to execute worker.php? Is that just a setting?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:06:50+00:00Added an answer on May 26, 2026 at 4:06 am
    1. If the worker isn’t taking too long to fetch the feed, it will be fine. You can run multiple workers if required to process more than one at a time. I’ve got a system (currently using Amazon SQS, but I’ve done similar with BeanstalkD before), with up to 200 (or more) workers pulling from the queue.
    2. A single worker script (the same script running multiple times) should be fine – the script can watch multiple tubes at the same time, and the first one available will be reserved. You can also use the job-stat command to see where a particular $job came from (which tube), or put some meta-information into the message if you need to tell each type from another.
    3. A good example of running a worker is described here. I’ve also added supervisord (also, a useful post to get started) to easily start and keep running a number of workers per machine (I run shell scripts, as in the first link). I would limit the number of times it loops, and also put a number into the reserve() to have it wait for a few seconds, or more, for the next job the become available without spinning out of control in a tight loop that does not pause at all – even if there was nothing to do.

    Addendum:

    1. The shell script would be run as many times as you need. (the link show how to have it re-run as required with exec $@). Whenever the php script exits, it re-runs the PHP.
    2. Apparently there’s a Djanjo app to show some stats, but it’s trivial enough to connect to the daemon, get a list of tubes, and then get the stats for each tube – or just counts.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently I have been dealing with windows LogonUser API. The LogonUser api returns different
Recently i am making an app on facebook. So i have use facebook api.
Recently I've been doing quite the project mostly working with the DateTime class. Now,..
Recently I've been thinking about how to transform a complex polygon into a non-complex
Recently I've been experimenting with the use of the Func<T> class, and so far
Recently I have been told that static class/methods are evil. Take for example my
Recently I have been investigating the possibilities of caching in ASP.NET. I rolled my
Recently, in attempting to import a module I'd written, I have been coming across
Recently I was asked to develop an app, which basically is going to use
Recently the PHP manual started showing the following warning on every mysql function page:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.