beanstalkd源于fackbook,是一個(gè)快速、簡(jiǎn)單的內(nèi)存消息隊(duì)列,也可以開啟binlog,消息將被寫入日志文件,用于重啟時(shí)恢復(fù)數(shù)據(jù)。
1.消息被稱作job,在服務(wù)器端儲(chǔ)存在內(nèi)存隊(duì)列中,具有DELAYED,READY,RESERVED,BURIED狀態(tài),狀態(tài)轉(zhuǎn)換圖如下
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*
消息支持優(yōu)先級(jí),生存時(shí)間的設(shè)置。不同狀態(tài)的消息分別處于相應(yīng)狀態(tài)的隊(duì)列中。
2. 消息屬于某個(gè)tube,tube類似于namespace或者消息主題的概念,消費(fèi)者可以訂閱一個(gè)或多個(gè)tube ,從而接收這些tube的消息 。
3. beanstalkd的代碼實(shí)現(xiàn)和協(xié)議定義很類似memcached的風(fēng)格。