Beanstalkd,一个高性能、轻量级的分布式内存队列系统,最初设计的目的是想通过后台异步执行耗时的任务来降低高容量Web应用系统的页面访问延迟,支持过有9.5 million用户的Facebook Causes应用。
wget https://github.com/downloads/kr/beanstalkd/beanstalkd-1.6.tar.gz
tar -xzvf beanstalkd-1.6.tar.gz
make && make install
安装php扩展
git clone https://github.com/nil-zhang/php-beanstalk.git
git clone https://github.com/bergundy/libbeanstalkclient.git
先安装libbeanstalkclient,然后继续php扩展安装
cd php-beanstalk
phpize
./configure
make && make install
python客户端安装
git clone https://github.com/earl/beanstalkc.git
cd beanstalk
python setup.py install
在运行时如果报:Failed to load PyYAML, will not parse YAML
则需要安装python的依赖组件:pip install pyyaml 进行安装
核心概念:
特性:
后台启动:
beanstalkd -l 地址 -p 端口号 -z 最大的任务大小(byte) -c &
如果是外部客户端连接,ip地址要写外网地址,这样才能连接上
启动选项
-b DIR wal directory
-f MS fsync at most once every MS milliseconds (use -f0 for "always fsync")
-F never fsync (default)
-l ADDR listen on address (default is 0.0.0.0)
-p PORT listen on port (default is 11300)
-u USER become user and group
-z BYTES set the maximum job size in bytes (default is 65535)
-s BYTES set the size of each wal file (default is 10485760)
(will be rounded up to a multiple of 512 bytes)
-c compact the binlog (default)
-n do not compact the binlog
-v show version information
-V increase verbosity
-h show this help