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).
- Spin up an AKLWEB HOST server instance running Ubuntu 14.10 x64 and SSH into the server after it’s done provisioning.
- Install Beanstalkd.
sudo apt-get update sudo apt-get install -y beanstalkd
- 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
- Make sure that Beanstalkd is running.
sudo service beanstalkd start
- Start Beanstalk Console by going to the directory where it was installed and starting a PHP server instance.
cd /app/beanstalk-console php -S [aklwebhost-instance-ip]:7654 -t public # *where **[aklwebhost-instance-ip]** is the IP address of the AKLWEB HOST instance you spun up or a domain name pointing to it*
- Navigate to
http://[aklwebhost-instance-ip]:7654. 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.
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.