beanstalkd源于fackbook,是一个快速、简单的内存消息队列,也可以开启binlog,消息将被写入日志文件,用于重启时恢复数据。
1.消息被称作job,在服务器端储存在内存队列中,具有DELAYED,READY,RESERVED,BURIED状态,状态转换图如下
Here is a picture of the typical job lifecycle:
put reserve delete
-----> [READY] ---------> [RESERVED] --------> *poof*
Here is a picture with more possibilities:
put with delay release with delay
----------------> [DELAYED] <------------.
| |
| (time passes) |
| |
put v reserve | delete
-----------------> [READY] ---------> [RESERVED] --------> *poof*
^ ^ | |
| \ release | |
| `-------------' |
| |
| kick |
| |
| bury |
[BURIED] <---------------'
|
| delete
`--------> *poof*
消息支持优先级,生存时间的设置。不同状态的消息分别处于相应状态的队列中。
2. 消息属于某个tube,tube类似于namespace或者消息主题的概念,消费者可以订阅一个或多个tube ,从而接收这些tube的消息 。
3. beanstalkd的代码实现和协议定义很类似memcached的风格。