Using Beanstalkd with Laravel

Beanstalk is a simple, fast work queue.

Its interface is generic, but was originally designed for reducing the latency of page views in high-volume web applications by running time-consuming tasks asynchronously.


Using Ubuntu Server on VM

sudo apt-get install beanstalkd

Public access

We need to enable public access in order to access the beanstalkd queue from host PC.

This is only for development, because we will be using beanstalk console on the host PC to watch the queue of Beanstalkd running in a virtual machine.

Don’t do this on production server.

sudo nano /etc/default/beanstalkd


Now restart the beanstalkd service

sudo service beanstalkd restart

Beanstalk console installation

If you want to see the queue while developing the application this console is very handy. You can see the number of jobs and inspect every job or delete it.

composer create-project ptrofimov/beanstalk_console -s dev

It will create a folder for beanstalk console. Navigate to that folder and start php server with this command:

php -S localhost:7654 -t public

Now if you check http://localhost:7654 in your browser.

Add remote server to check beanstalkd queues. Leave the port to default and change the server name. You can use the IP address or the server name where you have install beanstalkd.

Configure Laravel

Pheanstalk is a pure PHP 5.3+ client for the beanstalkd workqueue. It has been actively developed, and used in production by many, since late 2008. Created by Paul Annesley

composer require pda/pheanstalk

Now you can write job and run queue worker use connection beanstalkd



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s