Reference
Overview of interprocess communication in a microservice architecture
Interaction styles
Dimension - 1
- One-to-one—Each client request is processed by exactly one service
- Request/response: client send request and wait for response
- Asynchronous request/response: client send request to service without waiting, service will response later
- One-way notifications: client send notification to service
- One-to-many—Each request is processed by multiple services
Dimension - 2
- Synchronous—The client expects a timely response from the service and might even block while it waits.
- Asynchronous—The client doesn’t block, and the response, if any, isn’t necessarily sent immediately
USE SEMANTIC VERSIONING
- MAJOR—When you make an incompatible change to the API
- MINOR—When you make backward-compatible enhancements to the API
- PATCH—When you make a backward-compatible bug fix
Robustness principle / Postel's law
Be conservative in what you do, be liberal in what you accept from others
(often reworded as "Be conservative in what you send, be liberal in what you accept").
MAKING MAJOR, BREAKING CHANGES
Can let API gateway to translate old version API to new version API implementation
- /v1/… and /v2/…
- In HTTP header, such asGET /orders/xyz HTTP/1.1Accept: application/vnd.example.resource+json; version=1
Message formats
- use a cross-language message format.
- Ex. D NOT use Java serialization
- 2 main categories
- TEXT-BASED MESSAGE FORMATS. ex. JSON, XML
- Good: An advantage of these formats is that not only are they human readable, they’re self describing
- Bad:
- the messages tend to be verbose. Ex: XML element name
- the overhead of parsing text, especially when messages are large
- BINARY MESSAGE FORMATS. Ex. Proto Buffer
沒有留言:
張貼留言