RPC is a important abstraction for processes to call functions in other processes. In the context of distributed system, it is heavily used and are crucial.
LPC (local procedure call) often used stack to pass in arguments and data between two functions.
RPC refers to the condition when two functions (caller and callee) are in two different processes. In this case, the function call come across the process (even machine) boundary.
In RPC, it is hard to guarantee exactly-once semantics (function run for only once), different occasions may happen:
- Request/Reply message being dropped
- Calles process fails before executing the requested function
- Request message may be duplicated. etc.
To deal with such occasion, re-execute/re-transmit may be implemented, which correspond to RPC semantics of at-least-once/at-most-once.
In re-execute strategy, idempotent operation (operation can be repeat without side effect, such as x = 1,but not x = x + 1) can be used.
RPC sample implementation:
Client stub: manage function signature and allow code reuse for LPC and RPC.
Communication Module: In charge of requesting and receiving reply.
Dispatcher: select which server to respond to request.
Server stub: calls callee() and send back reply.
- 本文作者: Yu Wan
- 本文链接: https://cyanh1ll.github.io/2021/01/15/RPC2/
- 版权声明: CYANH1LL