2015-10-20 processed billions of job by using beanstalkd queue
TRANSCRIPT
BeanstalkdHow AfterShip use queue?
- Ten of millions of job per day
- Billions of job so far
- 4 beanstalkd servers (AWS m3.large)
- 4 down incidents in last 3 years
Beanstalkd ProtocolCharacteristics
- Guarantee FIFO
- Each job is uniquely assigned to one worker.
- Each connection can only reserve one job at a time
- Support jobs persistent (“-b” option)
- Support priority, delay, ttr (time to run), bury
- No HA
Queue systems
References:http://queues.io/http://www.sitepoint.com/message-queues-comparing-beanstalkd-ironmq-amazon-sqs/
Beanstalkd Amazon SQS
Server Setup Self Host Full Managed
Response Time single digit ms hundred ms
First In First Out (FIFO) Guarantee & unique Does not guarantee
Priority Yes No
Delay Yes Yes
Pub / Sub TCP pub/sub https polling
Beanstalkd ProtocolAction you can do
Status Description
put (with delay) Add a new job in the queue
reserve Take the job from queue
delete Delete the job after reserved.
bury Bury the job after reserved.
kick Kick the job from buried status to ready status.
release (with delay) Release the job back to ready status, after reserved it.The job id, pri, will be same.
Beanstalkd ProtocolTypical life cycle for a job
put --------> [READY] -------> [RESERVED]-------> *proof*
Ready Tube
Job 1
put
Beanstalkd ProtocolReserve
put reserve --------> [READY] -------> [RESERVED]-------> *proof*
Ready Tube
Job 1
reserve
Beanstalkd ProtocolDelete
put reserve delete--------> [READY] -------> [RESERVED]-------> *proof*
Ready Tube
Job 1
delete
Beanstalkd ProtocolBury
put reserve bury--------> [READY] -------> [RESERVED]-------> [BURIED]
Ready Tube
Job 1
buryBuried Tube
Beanstalkd ProtocolKick
put reserve bury--------> [READY] -------> [RESERVED]-------> [BURIED]
KICK
Ready Tube
kickBuried Tube
Job 1
BeanstalkdSo how much?
- 15 servers @ USD0.05 / hr
- 2 workers @ 0.05 USD per hr
- some traffic… $0.12 / GB
BeanstalkdSo how much?
- 15 servers @ USD0.05 / hr
- 2 workers @ 0.05 USD per hr
- some traffic… $0.12 / GB
- $0.97 in total