LinuxCommandLibrary

beanstalkd

Queue jobs for asynchronous processing

TLDR

Start the server, listening on port 11300

$ beanstalkd
copy

[l]isten on a specific [p]ort and address
$ beanstalkd -l [ip_address] -p [port_number]
copy

Persist work queues by saving them to disk
$ beanstalkd -b [path/to/persistence_directory]
copy

Sync to the persistence directory every 500 milliseconds
$ beanstalkd -b [path/to/persistence_directory] -f [500]
copy

SYNOPSIS

beanstalkd [-h|-V] [-d] [-F] [-l address] [-p port] [-u user] [-g group] [-z max-job-size] [-i max-open-tubes] [-c max-connections] [-b dir] [-f fifo-name]

PARAMETERS

-d, --daemon
    Daemonize the process (default).

-F, --foreground
    Run in foreground (for init scripts).

-l address, --listen=address
    Listen on specific IP (default 0.0.0.0).

-p port, --port=port
    TCP port to listen on (default 11300).

-u user, --user=user
    Drop privileges to user, chroot to home dir.

-g group, --group=group
    Drop group privileges.

-z size, --max-job-size=size
    Max job size in bytes (default 262144, up to 2G).

-i num, --max-open-tubes=num
    Max open tubes (default 1024).

-c num, --max-connections=num
    Max open connections (default 1024).

-b dir, --dir=dir
    Directory for binlog files (persistence).

-f fifo, --fidofifo=fifo
    FIFO path to wake listeners after dump.

-h, --help
    Display help.

-V, --version
    Show version.

DESCRIPTION

beanstalkd is a lightweight, high-performance message queue server for handling background jobs on Unix-like systems. It uses a minimal text-based TCP protocol (default port 11300) to manage jobs organized into named queues called tubes. Producers push jobs with optional priorities, delays, and TTR (time-to-run) timeouts. Workers reserve jobs; timeouts requeue them automatically.

Designed for speed and simplicity, it achieves millions of jobs per second with low latency and minimal CPU/memory usage. Written in C with no external dependencies. Optional binlogs enable persistence and crash recovery.

Key features: priorities for ordering, delayed jobs, job watching/reserving, statistics via the 'stats' command. Ideal for web apps needing async processing, like email delivery or image resizing. Supports clients in most languages: Resque (Ruby), Pheanstalk (PHP), beanstalkc (Python).

In production, run multiple instances behind a load balancer for horizontal scaling, as it's single-threaded.

CAVEATS

Single-threaded; scale horizontally with multiple instances and load balancer. Binlogs require manual rotation/backup. No built-in clustering or pub/sub.

TUBES

Named queues for job organization.
Default: default.

PROTOCOL

Line-based text protocol over TCP.
Use telnet localhost 11300 for testing.

PERSISTENCE

Enable with -b dir for binlogs.
Provides durability; rotate logs periodically.

HISTORY

Created by Keith Rarick in 2007 as a simple alternative to complex queues. Stable since v1.4 (2010); minimal changes due to robust design. Maintained on GitHub.

SEE ALSO

telnet(1), nc(1), redis-server(1)

Copied to clipboard