beanstalkd

 beanstalkd

A revolutionary idea: why not use a job queue system for your job queue?

Most people use delayed job aka a database or resque/sidekiq for queuing. But why hack your way around a database or a "smarter memcache" to do a simple queue when there are other solutions that were build for this?

Beanstalkd is one of them. It's small. It's fast. It's awesome. And I show you why.

F3c4a818db15623a3f4fd035d781e8ee?s=128

Bodo Tasche

July 03, 2014
Tweet

Transcript

  1. submit

  2. submit

  3. @bitboxer @bitcrowd Bodo Tasche

  4. Queues!

  5. create table 'job_queue';

  6. gem install delayed_job

  7. None
  8. beanstalkd

  9. Beanstalkd is a simple, fast work queue.

  10. brew install beanstalkd

  11. https://kr.github.io/beanstalkd/

  12. beanstalkd -p 11300

  13. gem install beaneater

  14. @beanstalk = Beaneater::Pool.new( [’localhost:11300’] )

  15. @tube = @beanstalk.tubes['email'] @tube.put '{"key" : "foo"}', :pri => 5

    @tube.put '{"key" : "bar"}', :delay => 3
  16. @beanstalk.jobs.register('email') do |job| json = Oj.load(job.body) puts "job value is

    #{json["key"]}!" end ! @beanstalk.jobs.process!
  17. @beanstalk.jobs.register( 'email', :retry_on => [SomeError], :max_retries => 2 )

  18. @tube.put '{"key" : "bar"}', :ttr => 120

  19. @beanstalk.jobs.register('email') do |job| # Long running stuff job.touch end

  20. • ready • delayed • buried

  21. job = @tube.peek(:buried)

  22. job.kick

  23. job.delete

  24. Beaneater.configure do |config| config.default_put_delay = 0 config.default_put_pri = 65536 config.default_put_ttr

    = 120 end
  25. @beanstalk.stats

  26. @beanstalk.tubes['email'].stats

  27. https://github.com/kr/beanstalkd/wiki/Tools

  28. beanstalkd

  29. @bitsofberlin http://bitsofberlin.org