Backend Development 20 min read

Understanding Service Coupling and Communication: RPC vs Event‑Driven in Microservices

This article explains the different types of coupling in microservice architectures, compares RPC and event‑driven communication methods, discusses event notification and event sourcing, and offers practical guidance on choosing and combining these approaches to reduce tight coupling while maintaining system flexibility.

Code Ape Tech Column
Code Ape Tech Column
Code Ape Tech Column
Understanding Service Coupling and Communication: RPC vs Event‑Driven in Microservices

In microservice architectures, services must call each other to complete functionality, and the way they interact becomes a critical issue. Two primary communication methods are RPC (Remote Procedure Call) and event‑driven (message‑based) approaches.

Message‑based communication is loosely coupled and generally superior to the tightly coupled RPC, though RPC still has its place in suitable scenarios. The article defines four types of coupling: time coupling, capacity coupling, interface coupling, and transmission‑mode coupling, and analyzes their impact.

Event‑driven communication is divided into two main styles: event notification (services exchange messages without direct calls) and event sourcing (recording all events as a permanent store). Event notification is an integration method, while event sourcing is a storage technique often built on databases or message queues like Kafka.

Examples illustrate how order, customer, and product services can interact via event notification, highlighting both advantages (loose coupling) and drawbacks (loss of end‑to‑end visibility). The article also shows a typical e‑commerce flow (checkout, payment, inventory, shipment) implemented with both RPC and event‑driven styles, concluding that event‑driven is preferable when timing constraints are relaxed.

Event sourcing stores the complete history of state changes, enabling replay of any point in time, but introduces complexity in handling schema evolution and querying. It is recommended to use a read‑only database for complex queries and to separate internal fine‑grained events from coarse‑grained integration events.

RPC mechanisms such as REST, gRPC, and Dubbo are synchronous and simple, making them suitable when immediate results are required. API gateways can reduce client complexity and also help lower coupling by centralizing service interfaces.

To mitigate tight coupling, the article suggests supporting multiple versions, ensuring backward compatibility, and using protocols like Protobuf gRPC that allow optional parameters.

The number of microservices should be kept manageable; excessive granularity leads to operational overhead. Internal microservice design (a monolith that internally follows microservice principles) can be a compromise, allowing gradual migration.

In conclusion, both RPC and event‑driven communication have their roles: event‑driven offers loose coupling, while RPC remains viable for tightly coupled business logic, especially when combined with backward‑compatible protocols.

backend architecturemicroservicesRPCevent-drivenservice coupling
Code Ape Tech Column
Written by

Code Ape Tech Column

Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.