[rabbitmq-discuss] RabbitMQ and batch processing

Laing, Michael michael.laing at nytimes.com
Mon May 19 21:10:32 BST 2014


On Mon, May 19, 2014 at 12:48 PM, Greg Poirier <greg.poirier at opower.com>wrote:

> Michael,
>
> Good to hear from you again. If you don't mind, I have a few questions
> about your setup.
>
> I assume for the AMQP proxy, you are referring to something like your
> Fabrik. Would that be correct? How is open sourcing that going? I've been
> interested since your original post.


It's taking longer than I thought :) Bits and pieces are in the pipeline -
our RabbitMQ / Python / Cassandra benchmarks will be out there by Cassandra
Day NYC, here at the NYTimes 21 Jun. A big piece of our rabbit_helpers
python framework is included.


>
> Being short on resources, but working with developers who have resources,
> I am inclined to introduce them to the idea of the middle layer and seeing
> what we can come up with that is equitable for all.
>
> I think being able to not persist messages in RabbitMQ would be a big win
> for us. This removes the bulk of the io, and I solves our still occasional
> partitioning problems. I'm going to talk to other service owners about
> persisting messages themselves in databases and passing only the ids of
> their messages around. I don't think we can implement a unified middle
> layer given some time constraints, but I'm going to propose that as well
> (as I think it is the best way to approach this). Lacking the ability to
> implement, does shifting persistence to databases and maintaining a batch
> table (of ids in flight) seem like a reasonable interim solution? Or is
> there another approach?
>

We let them pass whatever size message they want pretty much. If it is over
a configurable size, currently 10k, we try gzipping it; if it is still over
another configurable amount, currently 100k, we push it to S3 and place a
signed URL in the metadata.

The proxy clusters buy us a lot by: forcing non-persistence, buffering the
core clusters, making copies for message replay, allowing us to redirect
the message flows among core clusters, etc. And they are relatively local
to the our internal customers. We don't run any code on them other than
shovels and and federation. Each internal customer has its own vhost.


>
> A couple of our service owners already do this. Most do not and instead
> pass entire documents via RabbitMQ to persistent queues. I have a hard time
> identifying who some are but am working on that as well. I think providing
> an API for them would make a huge difference in getting them to standardize
> around a better use of RabbitMQ.
>

Our customers don't actually pay attention to the fact that they go through
a proxy - it is all 'fabrik' to them.


>
> I was toying with a simpler implementation of your cluster configuration,
> but (and I think we discussed this) it will require that producers and
> consumers connect to separate proxy hosts, correct? I am still largely
> unfamiliar with how federation and shovel work--despite having read the
> documentation. I am working on a test bed for myself in my spare time (ha).
> It would be nice to have this proxy layer be single unclustered rabbit
> nodes. I could then take do no downtime upgrades of RabbitMQ, add capacity
> for certain vhosts, etc. Am I understanding federation and shovel
> correctly? Is this even possible?
>

Our proxies are 2-way.


>
> The idea here being
>
> publisher - proxy - backing cluster - proxy - consumer
>
> Where consumers take messages from queues bound to exchanges to which
> publishers are connected.
>
> I think this requires a database for persistence, because if you publish
> to a proxy exchange and no consumers are connected, then the message gets
> lost.
>

The publish-to exchange in the proxy has a queue bound to it which is
shoveled to the core cluster. The queue will buffer the messages until they
are shoveled. The core does whatever. A proxy consume-from exchange is
federated to the core as its upstream. The core publishes whatever to that
exchange. Consumers create queues and bind to the proxy consume-from
exchange, implicitly signaling the upstream to send matching messages. This
is one way of configuring the plumbing.


>
> Is there a reasonable way to avoid this without Fabrik? Publisher confirms
> don't help if no queues are bound. And if we are sharing a database between
> producer and consumer, why bother with RabbitMQ at all?
>

Event-driven, no MxN, fast, reliable, flexible, cheap. We have 2 forms of
persistence: S3 for big messages, and Cassandra for memory. So most of the
fabrik focuses on the routing of small messages. Cassandra lets us 'replay'
messages selectively: show me the messages I missed, give me the messages
sent yesterday during a 5 minute period, give me the latest 10 messages on
this topic, etc. And it lets us gather event messages for near real-time
and longitudinal analysis.


>
> The beauty of message buses is the ability to pass arbitrary messages over
> them. Without that, what are they for? I realize that we don't want to pass
> large documents in them, but a small JSON blob seems perfectly reasonable.


That's what we do. Actually we store the json-like stuff in the headers
property as a 'metadata' item. The body is opaque to the fabrik - we treat
it as binary.

ml


>
>
> On Sunday, May 18, 2014, Laing, Michael <michael.laing at nytimes.com> wrote:
>
>> I'll respond inline w our experience:
>>
>> On Sun, May 18, 2014 at 2:55 PM, Greg Poirier <greg.poirier at opower.com>wrote:
>>
>>> I mentioned this on Twitter and a couple of people have requested that I
>>> bring this up on the mailing list.
>>>
>>> It seems to be a given that RabbitMQ was not designed for the batch
>>> processing use case (i.e. using RabbitMQ as a buffer between large serial
>>> steps). We have a system in place that attempts to do just that, however.
>>>
>>
>> It is not a 'given' as far as we are concerned. We have some processes
>> that result in a million or more messages being queued within a minute or
>> so. These messages are processed over the ensuing several minutes (for
>> 'dismissals' of news items from individual devices) to several hours (for
>> lower-priority individualized  'offers'). This is the new 'batch'.
>>
>>
>>>
>>> I have been working with the developers of the software involved in an
>>> attempt to help them redesign around a more ideal use of RabbitMQ (or to
>>> help them move to a different bus altogether -- database or something like
>>> kafka) and some of them have been able to simply operate in smaller batch
>>> sizes (thus keeping their queues relatively small).
>>>
>>
>> We put large message bodies in S3 and pass them by reference. We never
>> use RabbitMQ persistence and compensate for that with replication. For
>> 'real' persistence we use Cassandra. Most importantly, none of our internal
>> users know this, as we provide them with an abstracted interface.
>>
>>
>>>
>>> However, I cannot stem the tide of improper RabbitMQ use.
>>>
>>
>> We try to make it easier to use us than not. We work hard to be the most
>> reliable, fastest, most scalable, most flexible and cheapest component of
>> our customers technology mix.
>>
>>
>>>
>>> When things go poorly, millions of messages end up in the queues.
>>>
>>
>> We target zero length queues. If they grow unexpectedly we: 1) autoscale,
>> 2) shift load, 3) start new regions - usually all those. Then we diagnose.
>>
>>
>>>
>>> In 3.1.x we saw this regularly cause our clusters to partition.
>>>
>>
>> We have never had a partition in production because we always
>> overprovision RabbitMQ so it can maintain cluster communications. We
>> basically avoid disk IO due to the risk of IO wait interfering w the
>> cluster heartbeat.
>>
>>
>>>
>>> In 3.1.x and 3.2.x when we would delete large queues (5+ million
>>> messages enqueued), this would cause the cluster to become unresponsive,
>>> run out of memory, and then crash.
>>>
>>
>> When we have tested situations like this, we found it best to just wipe
>> out the cluster and restart. Before doing this, we shift the load to other
>> regions operating in parallel.
>>
>>
>>>
>>> During the 3.1 -> 3.2 upgrade, we had to completely rebuild our
>>> clusters. When 3.2 came up, it soon crashed.
>>>
>>
>> We have not had that problem.
>>
>>
>>>
>>> In the most recent upgrade, we saw a 3.2.3 cluster in our dev
>>> environment crash. I performed an opportunistic upgrade to 3.3.1, because
>>> hey... downtime already, so let's see if 3.3.1 addresses some of the issues
>>> we've been seeing.
>>>
>>> https://gist.github.com/grepory/384410ac90186ed0ce2a
>>>
>>> After the upgrade, 3.3.1 would not startup at all. I removed
>>> /var/lib/rabbitmq/mnesia on all of the nodes and brought RabbitMQ back up.
>>>
>>
>> We are not yet in production w 3.3.1 but 3.2.4 is running solidly in
>> stage and we will upgrade stage to 3.3.1 this coming week.
>>
>>
>>>
>>> 3.3.1 has been up and running alright so far, but we haven't done
>>> another end-to-end test in our development environment in a while. One of
>>> these tests can lead to at least a million messages in the queue over a
>>> period of time on average.
>>>
>>
>> A million is not that many - depending on size of course. As I said - our
>> target is 0, but really the question is: what's your rate of change? I try
>> to have enough 'headroom' to easily handle the surges - volumes can vary 20
>> to 1 depending on the news of the moment etc. If a queue builds and stays
>> high we add resources until it goes down and then investigate.
>>
>>
>>>
>>> So, I guess my question is:
>>>
>>> If I know that I have people using RabbitMQ like this, and there is
>>> nothing I can do to change that fact... what do I do?
>>>
>>
>> You need enough resource. And it is good to be able to autoscale.
>>
>> A specific suggestion I would make for any internal service provider is
>> to use an amqp proxy. We locate proxy clusters that we control in our
>> internal customers' computing environments. They publish to and subscribe
>> from these proxies. We control the shoveling/federation of the proxies
>> to/from our core pipelines in regions, redirecting as needed. The proxies
>> are an additional buffer and also allow us to 'launder' incoming messages,
>> e.g. by forcing persistence off.
>>
>> We also track and account for every message using metadata, and can
>> charge back... We are cheap but not free.
>>
>> Anyway, I hope this helps.
>>
>> ml
>>
>>
>>>
>>> _______________________________________________
>>> rabbitmq-discuss mailing list
>>> rabbitmq-discuss at lists.rabbitmq.com
>>> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>>>
>>>
>>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140519/83c69e21/attachment.html>


More information about the rabbitmq-discuss mailing list