RPC over RabbitMQ (with Elixir)

Click for: original source

At Community we use RabbitMQ, a lot. It’s the infrastructure backbone that allows our services (over forty at this point) to communicate with each other. That mostly happens through events (since we have an event-sourced system), but in some cases what we need is a request-response interaction between two services. By Andrea Leopardi.

We settled on using it for request-response interactions as well in the form of Remote Procedure Calls (RPCs). In this post, I’ll go over the architecture of such interactions, the RabbitMQ topologies we use to make them work, the benefits around reliability and the compromises around performance, and finally how this all implemented to be as fault-tolerant as possible with Elixir.

The article deals with:

  • What is an RPC
  • Why RPCs over RabbitMQ
  • RabbitMQ topology
  • Caller architecture
    • The response queue
    • Elixir process architecture
  • Receiver architecture and topology
    • In Elixir, as always, the answer is Broadway

We saw how we architected a system to make service-to-service RPCs over RabbitMQ. We went over the RabbitMQ topology we use, showing all the queues, exchanges, and bindings involved. We also covered the Elixir-specific implementation of this system, to sprinkle some practical examples on top of this stuff. You will find also plenty of links to further reading in the article. Good read!

[Read More]

Tags erlang programming web-development app-development performance