NOTE
1.11 Distributed-System Communication
1. What Is Distributed-System Communication - After a monolithic system is split into multiple subsystems, the subsystems need to communicate to provide a complete service. 2. Communication Methods Between Distributed Systems 2.1. Synchronous Communication - A calls B and waits for the result to return. 2.1.1. REST vs RPC.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is Distributed-System Communication?
- After a monolithic system is split into multiple subsystems, the subsystems need to communicate to provide a complete service.
2. Communication Methods Between Distributed Systems
2.1. Synchronous Communication
- A calls B and waits for the result to return.
2.1.1. REST vs RPC
- Restful.md (the related note has not yet been published).
- How to Design an RPC Framework
| RPC | REST | |
|---|---|---|
| Idea | Object-oriented | Resource-oriented |
| Communication protocol | TCP | HTTP |
| Message protocol | Binary | JSON |
| Performance | High | Low |
| IDL | proto. See below | swagger. See below |
| Client | Strongly typed | Weakly typed |
- API definitions between the service and client.
| Operation | RPC | REST |
|---|---|---|
| Register | POST /signup | POST /persons |
| Deregister | POST /resign { “personid”: “1234” } |
DELETE /persons/1234 |
| Read user information | GET /readPerson?personid=1234 | GET /persons/1234 |
| Read user’s item list | GET /readUsersItemsList?personid=1234 | GET /persons/1234/items |
| Add an item to user’s item list | POST /addItemToUsersItemsList { “personid”: “1234”; “itemid”: “456” } |
POST /persons/1234/items { “itemid”: “456” } |
| Update an item | POST /modifyItem { “itemid”: “456”; “key”: “value” } |
PUT /items/456 { “key”: “value” } |
| Delete an item | POST /removeItem { “itemid”: “456” } |
DELETE /items/456 |
- API version: MAJOR.MINOR.PATCH
- MAJOR: API is not backward compatible.
- MINIOR: backward-compatible API feature enhancement.
- PATCH: backward-compatible API bug fix.
2.2. Asynchronous Communication
- A calls B and returns directly without waiting for the result.
- How to Design an Asynchronous System.md (the related note has not yet been published).
2.3. Synchronous Communication vs Asynchronous Communication
- I/O Models.md (the related note has not yet been published).
| Synchronous | Asynchronous | |
|---|---|---|
| Can the result be obtained in real time? | Yes | No |
| Throughput | Low | High |
3. Message Formats for Communication Between Distributed Systems
- The physical model in Data Models.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub