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
hungryblank
April 24, 2012
Programming
140
1
Share
Railsconf 2009 Rabbitmq
hungryblank
April 24, 2012
More Decks by hungryblank
See All by hungryblank
Rails Underground 2009 RabbitMQ
hungryblank
3
800
Other Decks in Programming
See All in Programming
次世代リンターで探る、tsgo 時代における型認識カスタムルールの現実解
ytakahashii
1
960
サプライチェーン攻撃対策「層を重ねて落ちない壁」を10日間で組み上げた話 #TechLeadConf2026
kashewnuts
1
360
「OSSがあるなら自作するな」は AI時代も正しいか ── Build vs Adopt の新しい判断基準
kumorn5s
7
2.9k
inferと仲良くなる10分間
ryokatsuse
1
250
20260514_its_the_context_window_stupid.pdf
heita
0
1.1k
CSC307 Lecture 17
javiergs
PRO
0
230
SPMマルチモジュールで テストカバレッジを取得する技法
yosshi4486
0
120
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
180
バックエンドにElysiaJSを採用して気付いた、良い点・悪い点
wanko_it
1
170
Composerを使ったサプライチェーン攻撃の様子を眺めてみる #phpstudy
o0h
PRO
2
130
1人1案件のプロダクトエンジニア時代に、"プロセス監督"としてチャレンジしたこと
non0113
0
300
AI時代になぜ書くのか
mutsumix
0
450
Featured
See All Featured
Design of three-dimensional binary manipulators for pick-and-place task avoiding obstacles (IECON2024)
konakalab
0
430
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
220
Game over? The fight for quality and originality in the time of robots
wayneb77
1
180
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.7k
Building AI with AI
inesmontani
PRO
1
1k
The Cost Of JavaScript in 2023
addyosmani
55
9.9k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
210
Bash Introduction
62gerente
615
210k
The agentic SEO stack - context over prompts
schlessera
0
780
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
65
54k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
Mobile First: as difficult as doing things right
swwweet
225
10k
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