Choosing gRPC or RabbitMQ: the sync/async boundary rule
Every cross-service call is one or the other. Getting it backwards once is enough to feel why.
The problem
With fourteen services communicating constantly, every new integration point needs a decision: does this call go over gRPC or get published as a RabbitMQ event? Pick wrong in either direction and the cost shows up later, not immediately — a slow-to-surface coupling problem rather than a build error.
Approaches considered
Default to gRPC everywhere. Synchronous calls are easier to reason about — request in, response out, errors propagate directly. Applied uniformly, this couples every publisher to the availability of everything downstream, even for events nobody needs an answer to right now.
Default to events everywhere. Publish everything, let consumers react asynchronously. Applied uniformly, this means a caller that actually needs an answer — like recommendation-service needing scores back from ml-service before it can respond to its own caller — has to fake synchrony with a reply queue and a timeout, which is slower and more fragile than just calling the service.
Choose per call, based on whether the caller needs the result to do its own job. If the answer is required to respond to whoever called this service, use gRPC. If the call is purely “something happened, react if you care,” publish an event.
Trade-offs
A per-call rule means the codebase has two different integration patterns instead of one, and every new service integration requires actually applying the rule rather than defaulting to whatever’s already there. It’s a small amount of judgment required at every boundary, forever.
The decision
gRPC for calls where the caller needs the response synchronously. RabbitMQ events for everything that’s an announcement, with one deliberate exception: message.send fires as an event with no synchronous reply, because the client already holds a WebSocket connection that will receive delivery confirmation asynchronously through a different channel entirely.
Why
The rule tracks a real distinction, not a stylistic one: gRPC couples the caller to the callee’s availability, which is correct when the caller’s own response depends on it, and wrong when it doesn’t. post-service publishing post.created doesn’t need fanout-service, ingestion-service, or graph-service to be up at that instant — coupling that publish to their availability would make post creation fail for reasons that have nothing to do with posts. recommendation-service calling ml-service for a score has no such luxury; it cannot return a ranked feed without that answer, so a network partition there should fail loudly and immediately, not queue silently.
Implementation
// recommendation-service — gRPC, because the caller can't finish
// its own response without this answer.
scores, err := r.scoringClient.ScoreCandidates(ctx, &pb.ScoreRequest{
Candidates: features,
})
if err != nil {
return nil, fmt.Errorf("scoring unavailable, cannot rank feed: %w", err)
}
// post-service — an event, because nothing about creating this
// post depends on who's listening, or whether they're up.
await channel.publish("domain-events", "post.created", Buffer.from(
JSON.stringify({ postId: post.id, authorId: post.authorId })
));
// returns to the caller immediately; fanout/ingestion/graph react
// on their own schedule.
# realtime-gateway — the deliberate exception: fire-and-forget
# over RabbitMQ, because the WebSocket connection already open
# to this client is the channel that carries the reply back.
def handle_in("send_message", %{"body" => body}, socket) do
MessagingPublisher.publish_message_send(socket.assigns.conversation_id, body)
{:noreply, socket} # no synchronous reply attempted here
end