2. WHY DO WE NEED MESSAGING?WHY DO WE NEED MESSAGING?
Web apps should be fast, so...
do work asynchronously!
And break out cross-cutting concerns into services
3. HOW DO SERVICES COMMUNICATE?HOW DO SERVICES COMMUNICATE?
HTTP, of course.
But then, two problems emerge:
Traffic can be bursty
Systems go down for maintenance
4. So we thought:
“ Wouldn't it be great if all the requests coming in
were queued somewhere? ”
8. QUEUINGQUEUING
Asynchronous-by-design: just because no one is subscribed to
a queue doesn't mean that messages can't wait for a
consumer.
Durability is baked in.
Flexible architecture: publishers don't need to know about
who is consuming published data.
10. The Messenger object is used for both publishing and
subscribing.
It's easy to make one.
require 'agni'
m = Agni::Messenger.new('amqp://localhost')
11. Subscribing is a one-liner.
m.subscribe('test_queue') {|m,p| printf p}
13. Sending prioritized messages adds only a single parameter.
1.upto(100000).each{|n| m.publish("test#{n}", 'test_queue', n%10)}
14. BEHIND THE SCENESBEHIND THE SCENES
Based on RabbitMQ via
Use ten queues, each with their own AMQP channel
Configure each channel with its own prefetch value
Use an in-memory Fibonacci heap to priortize the incoming
prefetch streams
Process messages off of the heap
ruby-amqp
16. STATUSSTATUS
Agni has been in production use at Apartment List for close to
six months, and delivers millions of messages daily.
It is being made available publically for the first time this week.
17. Agni is Open Source, available under the BSD license. Check it
out online at:
Try it out, file bugs, fork it, and send pull requests!
https://github.com/apartmentlist/agni