Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Railsconf 2009 Rabbitmq
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
hungryblank
April 24, 2012
Programming
1
140
Railsconf 2009 Rabbitmq
hungryblank
April 24, 2012
Tweet
Share
More Decks by hungryblank
See All by hungryblank
Rails Underground 2009 RabbitMQ
hungryblank
3
790
Other Decks in Programming
See All in Programming
存在論的プログラミング: 時間と存在を記述する
koriym
4
460
Nuxt Server Components
wattanx
0
110
Laravel Nightwatchの裏側 - Laravel公式Observabilityツールを支える設計と実装
avosalmon
1
210
Ruby and LLM Ecosystem 2nd
koic
1
1.3k
GC言語のWasm化とComponent Modelサポートの実践と課題 - Scalaの場合
tanishiking
0
120
Redox OS でのネームスペース管理と chroot の実現
isanethen
0
430
ファインチューニングせずメインコンペを解く方法
pokutuna
0
150
[PHPerKaigi 2026]PHPerKaigi2025の企画CodeGolfが最高すぎて社内で内製して半年運営して得た内製と運営の知見
ikezoemakoto
0
280
Claude Code Skill入門
mayahoney
0
420
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
970
PHP でエミュレータを自作して Ubuntu を動かそう
m3m0r7
PRO
2
140
Rで始めるML・LLM活用入門
wakamatsu_takumu
0
200
Featured
See All Featured
Design in an AI World
tapps
0
180
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
220
Rebuilding a faster, lazier Slack
samanthasiow
85
9.4k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
120
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
210
Pawsitive SEO: Lessons from My Dog (and Many Mistakes) on Thriving as a Consultant in the Age of AI
davidcarrasco
0
92
Raft: Consensus for Rubyists
vanstee
141
7.4k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
330
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.5k
How to make the Groovebox
asonas
2
2k
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
[RailsConf 2023] Rails as a piece of cake
palkan
59
6.4k
Transcript
%w(map reduce).first A Tale About Rabbits, Latency and Slim Crontabs
Paolo Negri thanks to: www.autoscout24.de
Summary:
Map http://www.matthiasdittrich.com/projekte/dliste/visualisations/index.html
http://www.flickr.com/photos/myxi/448253580 rabbitMQ
crontab diet http://www.flickr.com/photos/tim_norris/2600843131/
Map Reduce “Programming model for processing and generating large data
sets” (Google)
Map Reduce "Map" step the master node takes the input,
chops it up into smaller sub-problems, and distributes those to worker nodes. (Wikipedia)
The problem Invoicing our clients
Is it as simple as... clients.map do |client| client.invoice end
No! •distributed •concurrent Because the process is:
Problems: •How many nodes? •How many workers? •Distribution mechanism to
feed the workers?
What about queuing? • the master node takes the input,
chops it up into smaller sub-problems, and publishes them in a queue • workers independently consume the content of the queue
Here comes • RabbitMQ is an implementation of AMQP, the
emerging standard for high performance enterprise messaging • It’s opensource • Can be used to manage queues • Written in Erlang
Erlang? • Erlang is a general-purpose concurrent programming language designed
by Ericsson • distributed • fault tolerant • soft real time • high availability
Install it •sudo apt-get install rabbitmq •sudo gem install tmm1-amqp
Do it - master node
Use it - worker node
What and where RabbitMQ (Erlang) TCP/IP Master (ruby) Worker (ruby)
Worker (ruby)
Get for free • Decoupling master/worker • Workers take care
of feeding themselves • Flexible number of workers
Get for free • RabbitMQ can be clustered • Support
of message acknowledgement • Queues can be persisted on disk (at a price) • low latency
Queue • Is an actual entity • has a name
• can be inspected and managed
EventMachine
EventMachine • Non blocking IO and lightweight concurrency • eliminate
the complexities of high- performance threaded network programming Is an implementation of Reactor Pattern
EventMachine
EventMachine amqp gem is built on EventMachine => you’re in
a context where you can leverage concurrent programming
EM - Deferrables
EM - Deferrables “The Deferrable pattern allows you to specify
any number of Ruby code blocks that will be executed at some future time when the status of the Deferrable object changes “
EM - Deferrables
EM - Deferrables
Deferrables ClientStat Arrears without deferrables with deferrables Time ClientStat Arrears
Achieved so far • Easy distribution of tasks • Architecture
that supports arbitrary number of workers (and masters) • Concurrency within the single worker
More rabbits Analogy with email system
Multicasting - producer
Multicasting - consumer
Multicasting Exchange msg A Queue1 Queue3 Queue2 Cons1 Cons2 Cons3
Publisher
Multicasting Exchange Queue1 Queue3 Queue2 msg A msg A msg
A Cons1 Cons2 Cons3 Publisher
Not only queues then • communication across hosts, heterogeneous systems
• low latency • clustering Use messages distribution to build the nervous system of your app
Where to start? crontab -l 5 * * * *
bin/do_the_quick_thing.rb 0 2 * * * bin/do_the_scary_thing.rb
Cron • Simple • Reliable • No maintenance • Status
is not explicit • Locking? • Shot and forget
Queue • Distributed easily • Reliable • Can be inspected
• Add/decrease workers •Makes you think! • Adds more complexity
On github - Projects • eventmachine/eventmachine • tmm1/amqp • macournoyer/thin
• famoseagle/carrot • celldee/bunny • ezmobius/nanite
Q&A ?
Thanks! Paolo Negri / hungryblank