Microservices are often prematurely adopted, creating distributed monoliths where services are tightly coupled over slow HTTP REST interfaces. Here is a pragmatic blueprint for clean service boundaries.
When to Actually Split Services
Prefer gRPC for Synchronous Internal RPC
Inter-service HTTP/REST adds heavy JSON serialization and header parsing overhead. Switching internal service calls to gRPC with Protocol Buffers delivers:
protobuf
syntax = "proto3";
service ConsultationService {
rpc InitiateSession (SessionRequest) returns (SessionResponse);
}
message SessionRequest {
string patient_id = 1;
string doctor_id = 2;
int64 timestamp = 3;
}Asynchronous Event Streaming with NATS
For decoupled workflows like sending prescription notifications or audit logs, synchronous blocking calls degrade resilience. Utilizing a lightweight broker like NATS JetStream ensures delivery guarantees with sub-millisecond latencies.