Reference
- synchronous communication with other services as part of request handling reduces application availability
- As a result, you should design your services to use asynchronous messaging whenever possible
Synchronous communication reduces availability
- Problem of "Use REST for inter-service communication" is "it's synchronous protocol"
- Synchronous protocol => Reduce availability
- If you want to maximize availability, you must minimize the amount of synchronous communication.
Eliminating synchronous interaction
ways to reduce the amount of synchronous communication with other services while handling synchronous requests
- defining services that only have asynchronous APIs (but public APIs are commonly RESTful)
USE ASYNCHRONOUS INTERACTION STYLES
REPLICATE DATA
- If a service has a synchronous API, one way to improve availability is to replicate data
- A service maintains a replica of the data that it needs when processing requests.
- It keeps the replica up-to-date by subscribing to events published by the services that own the data
- Drawback
- it can sometimes require the replication of large amounts of data, which is inefficient.
- it doesn’t solve the problem of how a service updates data owned by other services
FINISH PROCESSING AFTER RETURNING A RESPONSE
handle a request as follows:
- Validate the request using only the data available locally.
- Update its database, including inserting messages into the OUTBOX table.
- Return a response to its client.
it asynchronously sends messages to other services
Drawback:
- makes the client more complex
沒有留言:
張貼留言