Agni

305 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
305
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Agni

  1. 1. AGNIAGNIMESSAGING. ON FIRE.MESSAGING. ON FIRE.RickDillonYep.⇧Thatdudeisagod.
  2. 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. 3. HOW DO SERVICES COMMUNICATE?HOW DO SERVICES COMMUNICATE?HTTP, of course.But then, two problems emerge:Traffic can be burstySystems go down for maintenance
  4. 4. So we thought:“ Wouldnt it be great if all the requests coming inwere queued somewhere? ”
  5. 5. So we built Agni.
  6. 6. DESIGNDESIGNAgni is built around three principles:SimplicityQueuingPriority
  7. 7. SIMPLICITYSIMPLICITYOne primitive: the queue. Avoid the complexities of AMQP.ChannelsConsumersExchangesBindingsRoutesRoute keys
  8. 8. QUEUINGQUEUINGAsynchronous-by-design: just because no one is subscribed toa queue doesnt mean that messages cant wait for aconsumer.Durability is baked in.Flexible architecture: publishers dont need to know aboutwho is consuming published data.
  9. 9. PRIORITYPRIORITYAsynchronous doesnt mean not important. Prioritize the stuffthat needs to be done fast.
  10. 10. The Messenger object is used for both publishing andsubscribing.Its easy to make one.require agnim = Agni::Messenger.new(amqp://localhost)
  11. 11. Subscribing is a one-liner.m.subscribe(test_queue) {|m,p| printf p}
  12. 12. So is publishing.1.upto(100).each{|n| m.publish("test#{n}", test_queue)}
  13. 13. Sending prioritized messages adds only a single parameter.1.upto(100000).each{|n| m.publish("test#{n}", test_queue, n%10)}
  14. 14. BEHIND THE SCENESBEHIND THE SCENESBased on RabbitMQ viaUse ten queues, each with their own AMQP channelConfigure each channel with its own prefetch valueUse an in-memory Fibonacci heap to priortize the incomingprefetch streamsProcess messages off of the heapruby-amqp
  15. 15. LIMITATIONSLIMITATIONSEach message is only consumed once (by design)EventMachine-Fast (5,000 messages/sec)Supports ten levels of priority
  16. 16. STATUSSTATUSAgni has been in production use at Apartment List for close tosix months, and delivers millions of messages daily.It is being made available publically for the first time this week.
  17. 17. Agni is Open Source, available under the BSD license. Check itout online at:Try it out, file bugs, fork it, and send pull requests!https://github.com/apartmentlist/agni

×