Asynchronous communication is a key aspect of modern
microservices architecture, providing several benefits that enhance the overall
system performance and scalability :
De-coupling Across Components - Asynchronous communication
decouples components, allowing them to operate independently without waiting
for each other. This reduces dependencies and improves system resilience.
Fire-and-Forget Interaction- In a fire-and-forget
interaction, the sender sends a message and does not wait for a response. This
is useful for tasks that do not require immediate feedback, reducing the load
on the system and improving responsiveness.
Support Long-Running Jobs - Asynchronous communication
supports long-running jobs by allowing tasks to be processed in the background.
This prevents blocking resources and ensures that the system remains responsive
to other requests.
Microservice Functional Requirements
To build effective microservices, certain functional
requirements must be met:
Loosely Coupled Service - Microservices should be
loosely coupled, meaning changes in one service should not impact others. This
enhances maintainability and scalability.
Backward Compatibility - Independently Changeable - Services
should be independently changeable without breaking existing functionality.
This ensures that updates can be made without disrupting the system.
Backward Compatibility - Independently Deployable -
Microservices should be independently deployable, allowing for updates and
deployments without affecting other services.
Support and Honor Contracts - Microservices must support and
honor contracts, ensuring consistent and reliable communication between
services.
Technology Agnostic API - APIs should be technology
agnostic, allowing different technologies to interact seamlessly.
Stateless - Microservices should be stateless, meaning they
do not retain client state between requests. This simplifies scaling and
improves reliability.
Lightweight Communication - Communication between
microservices should be lightweight to reduce overhead and improve
performance.
Cache-able Communication - Communication should be
cache-able to improve efficiency and reduce redundant processing.
Usability – API Consistency, Predictable, Readable - APIs
should be consistent, predictable, and readable to enhance usability and
developer experience.
Usability – Query-able Data - APIs should allow for
query-able data to enable flexible and efficient data retrieval.
Pragmatic REST API - Pragmatic REST API refers
to a more practical approach to REST, focusing on simplicity and usability
rather than strictly adhering to CRUD operations.
Example :
Use Verbs Instead of Nouns: Use verbs in the API to denote
actions, e.g., /startProcess instead of /process.
Append Query Parameters: Use query parameters to pass
constraints, e.g., /search?query=example.
HATEOAS: Implement Hypermedia as the Engine of Application
State (HATEOAS) by including URLs in responses to guide the client on the next
steps, e.g., the server responds with the next URL needed for the client to
make a call.
By following these principles, microservices can achieve
better performance, scalability, and maintainability, while providing a more
practical and user-friendly API.
Facade Pattern
The Facade pattern is popular for keeping implementation
separate from the contract. It provides flexibility in the implementation
without impacting the integration. This pattern simplifies the interface for
the client and hides the complexities of the underlying system.
Proxy Pattern
The Proxy pattern is popular when connecting with other services. The proxy object helps in various scenarios such as caching and making the internal model extendable. It can also assist with authentication and authorization. Additionally, the proxy pattern is beneficial for unit testing, as mocking proxy data is straightforward.
No comments:
Post a Comment