Communication style pattern Flashcards
Communcation style pattern
Remote Procedure Invocation
Messaging
Domain-specific protocol
Remote Procedure Invocation (RPI): context
You have applied the Microservice architecture pattern. Services must handle requests from the application’s clients. Furthermore, services must sometimes collaborate to handle those requests. They must use an inter-process communication protocol.
Remote Procedure Invocation (RPI): solution
Use RPI for inter-service communication. The client uses a request/reply-based protocol to make requests to a service.
Remote Procedure Invocation (RPI): example
REST
gRPC
Apache Thrift
Remote Procedure Invocation (RPI): result benefits
- Simple and familiar
- Request/reply is easy
- Simpler system since there in no intermediate broker
Remote Procedure Invocation (RPI): result drawbacks
- Usually only supports request/reply and not other interaction patterns such as notifications, request/async response, publish/subscribe, publish/async response
- Reduced availability since the client and the service must be available for the duration of the interaction
Remote Procedure Invocation (RPI): result issues
Client needs to discover locations of service instances
Remote Procedure Invocation (RPI): related
The Domain-specific protocol is an alternative pattern
The Messaging is an alternative pattern
Externalized configuration supplies the (logical) network location, e.g. URL, of the service.
A client must use either Client-side discovery and Server-side discovery to locate a service instance
A client will typically use the Circuit Breaker pattern to improve reliability
Messaging: context
You have applied the Microservice architecture pattern. Services must handle requests from the application’s clients. Furthermore, services must sometimes collaborate to handle those requests. They must use an inter-process communication protocol.
Messaging: solution
Use asynchronous messaging for inter-service communication. Services communicating by exchanging messages over messaging channels.
Messaging: examples
There are numerous examples of asynchronous messaging technologies
Apache Kafka
RabbitMQ
Messaging: result benefits
- Loose runtime coupling since it decouples the message sender from the consumer
- Improved availability since the message broker buffers messages until the consumer is able to process them
- Supports a variety of communication patterns including request/reply, notifications, request/async response, publish/subscribe, publish/async response etc
Messaging: result drawback
Additional complexity of message broker, which must be highly available
Messaging: result issues
Request/reply-style communication is more complex
Messaging: related
- The Saga pattern and CQRS pattern use messaging
- The Transactional Outbox pattern enables messages to be sent as part of a database transaction
- The Externalized configuration pattern supplies the (logical) message channel names and the location of the message broker
- The Domain-specific protocol pattern is an alternative pattern
- The RPI pattern is an alternative pattern