open-contracting / software-development-handbook

A guide for developers of OCP's tools
https://ocp-software-handbook.readthedocs.io/en/latest/
Other
4 stars 1 forks source link

Message broker preferences #79

Closed jpmckinney closed 1 year ago

jpmckinney commented 1 year ago

Context

We work in an environment where we don't want any data to be lost (e.g. if we were just tracking user activity, we wouldn't mind losing a few click events, etc.).

As such, we care about:

Choices

The initial choice between Redis and RabbitMQ for Kingfisher Process is described at https://github.com/open-contracting/kingfisher-process/issues/232#issuecomment-571687803 Redis high durability is still "Very very slow", according to the docs. It looks like to re-process unacknowledged messages, a worker will need to run XAUTOCLAIM on restart (the broker doesn't do it automatically).

RabbitMQ is working out okay, but it seems to shut down due to lack of memory and/or have heartbeat timeouts (despite having a thread dedicated to the heartbeat) at least once every few weeks. It's perhaps a problem with any distributed processing, but it would be nice not to have this noise. (We'll try upgrading from 3.8 to 3.11.)

Some other options by Apache include ActiveMQ, Kafka and Pulsar.

RedPanda is similar to Kafka. I don't know if it'll go the way of Elasticsearch (i.e. need to commercialize leading to proprietary licensing). That said, it apparently has less overhead in terms of deployment – if we wanted Kafka.

Non-brokers

ZeroMQ has no persistence, durability (message retention), or acknowledgments, so it's not an option. (Such features can perhaps be built on top of ZeroMQ, but that's extra overhead for us.)

I looked briefly into Apache Avro, which provides RPC and a fast row-based format.

The RPC requires the receiver to be running (like ZeroMQ). If Process goes down, then messages sent from Collect can be lost. "fast writes" are not a problem between Collect and Process, because the source's latency is the bottleneck.

jpmckinney commented 1 year ago

I can make this into an ADR, but I'll just leave this here for now, as I was trying to remember our past decision, and this seems to summarize our position well enough.