Agni

17
AGNI AGNI MESSAGING. ON FIRE. MESSAGING. ON FIRE. Rick Dillon Yep. That dude is a god.

description

 

Transcript of Agni

Page 1: Agni

AGNIAGNIMESSAGING. ON FIRE.MESSAGING. ON FIRE.

Rick Dillon

Yep. ⇧ That dude is a god.

Page 2: Agni

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

Page 3: Agni

HOW DO SERVICES COMMUNICATE?HOW DO SERVICES COMMUNICATE?HTTP, of course.

But then, two problems emerge:

Traffic can be burstySystems go down for maintenance

Page 4: Agni

So we thought:

“ Wouldn't it be great if all the requests coming inwere queued somewhere? ”

Page 5: Agni

So we built Agni.

Page 6: Agni

DESIGNDESIGNAgni is built around three principles:

SimplicityQueuingPriority

Page 7: Agni

SIMPLICITYSIMPLICITYOne primitive: the queue. Avoid the complexities of AMQP.

ChannelsConsumersExchangesBindingsRoutesRoute keys

Page 8: Agni

QUEUINGQUEUINGAsynchronous-by-design: just because no one is subscribed toa queue doesn't mean that messages can't wait for aconsumer.Durability is baked in.Flexible architecture: publishers don't need to know aboutwho is consuming published data.

Page 9: Agni

PRIORITYPRIORITY'Asynchronous' doesn't mean 'not important'. Prioritize the stuff

that needs to be done fast.

Page 10: Agni

The Messenger object is used for both publishing andsubscribing.

It's easy to make one.

require 'agni'm = Agni::Messenger.new('amqp://localhost')

Page 11: Agni

Subscribing is a one-liner.

m.subscribe('test_queue') {|m,p| printf p}

Page 12: Agni

So is publishing.

1.upto(100).each{|n| m.publish("test#{n}", 'test_queue')}

Page 13: Agni

Sending prioritized messages adds only a single parameter.

1.upto(100000).each{|n| m.publish("test#{n}", 'test_queue', n%10)}

Page 14: Agni

BEHIND THE SCENESBEHIND THE SCENESBased on RabbitMQ via Use 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 heap

ruby-amqp

Page 15: Agni

LIMITATIONSLIMITATIONSEach message is only consumed once (by design)EventMachine-Fast (5,000 messages/sec)Supports ten levels of priority

Page 16: Agni

STATUSSTATUSAgni 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.

Page 17: Agni

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