Beanstalkd and Beanstalk Console on Ubuntu 14

Modified on: Fri, May 19, 2017 at 5:17 pm EST

Introduction

Beanstalkd is a work queue server that runs time-consuming tasks asynchronously. It comes in very handy if you manage or develop an application (web, mobile, etc.) that needs to perform time-consuming tasks (like sending emails), and you don't want your users to wait while the task is running. You can queue tasks with Beanstalkd and have your application move on to the next operation.

Beanstalk Console is a web admin interface for Beanstalkd that was written in PHP. It provides a friendly interface that you can use to see all the jobs and their current states (urgent, ready, reserved, delayed and buried).

Installation

  1. Spin up an Vultr server instance running Ubuntu 14.10 x64 and SSH into the server after it's done provisioning.

  2. Install Beanstalkd.

    sudo apt-get update
    sudo apt-get install -y beanstalkd
    
  3. Install Beanstalk Console by using PHP's package manager, Composer.

    sudo apt-get install -y php5 php5-cli
    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer
    composer create-project ptrofimov/beanstalk_console -s dev /app/beanstalk-console
    # Note that "/app/beanstalk-console" can be any directory you choose
    

Running Beanstalk

  1. Make sure that Beanstalkd is running.

    sudo service beanstalkd start
    
  2. Start Beanstalk Console by going to the directory where it was installed and starting a PHP server instance.

    cd /app/beanstalk-console
    php -S [vultr-instance-ip]:7654 -t public
    # *where **[vultr-instance-ip]** is the IP address of the Vultr instance you spun up or a domain name pointing to it*
    
  3. Navigate to http://[vultr-instance-ip]:1080. You will be greeted with a "Hello!" screen that contains an "Add Server" button. Click the button and accept the defaults (localhost:11300).

One thing to note here is that you don't have to use PHP with Beanstalk. Beanstalk is technology agnostic. Also, there are two sides to a queue - adding jobs, and removing jobs. Removing jobs is usually done by what we refer to as a "worker process". If your technology stack uses PHP, you can use Pheanstalk to perform both tasks.

Conclusion

A queue server that can run jobs in the background asynchronously is a must considering users expect things to happen instantly with your application. Beanstalkd is a tried and tested work queue server that can reduce latency issues with your applications, thereby causing your users to have richer experiences.

Get started in the SSD Cloud!