Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
with RabbitMQ , Python, and CakePHP
What the wibbleﬁsh?
All about oﬄoading work, and doing things in
Make applications that complete tasks in a
Doing work outside the request/response cycle
of a UI/API.
Work to ofﬂoad
Noti cations (SMS, Email, Postal mail).
Import & export.
Process image & video.
Isn’t cron good enough?
Cron tabs are great with one server.
Cron doesn’t scale to multiple machines.
Cron doesn’t solve the whole problem space.
Problems with Cron
Isn’t suitable for ‘real-time’ results.
Requires a set schedule. You might spin up
processes that do nothing. Or you might not
have enough capacity.
Parallelizing is a pain.
Queues to the rescue!
Queues accept and dispatch events.
Events can contain almost anything*.
Events can be roughly equal to ‘jobs’.
A single event can trigger lots of downstream
Separation of concerns.
Collection of mini/small applications.
No monolithic applications.
Decoupled, and easier to test.
Easy to scale. Busy service = more of them.
Exchanges abstract queues from the producer.
Route messages to queues, that are bound by
Allows consumers to listen to speci c routing
Multiple consumers can listen to the same
Consumers can also listen to topics. Which are
keys separated by dots.
e.g page_view.search, page_view.update
Consumer could listen to page_view.*
Can create messages with many tools.
PHP, python, node, ruby, etc.
Messages can contain any stringy data (JSON)
Data for messages
Only string-y things can be stored in messages.
JSON encoded data in message.
Key to value stored in Redis/Memcache.
Keep messages small. RabbitMQ performs
better with small messages.
Use a daemon process.
Daemons in PHP can be done, but they kinda
Usually use sleep(2) or other workaround.
sleep(2) moves you away from ‘real time’.