fleeting systemdesign distributedsystem/microservice/grpc

Remote Procedure Calls vs. Local Procedure Calls | Baeldung on Computer Science

Procedure Calls

Info

The procedure in modular programming is standalone code containing instructions. A procedure instructs the computer to execute a specific program or perform certain tasks.

The Procedure Call Transfers the control from the current process to another. We can also pass a list of parameters along with the procedure call. After successful execution, control returns to the initial procedure invoked, and the program continues its execution.

flowchart TD
    A[Procedure Call]
    B{Exist locally?}
    C[Local Procedure Call]
    D[Local execution]
    E[Remote Procedure Call]
    F[Remote execution]

    A --> B
    B -- Yes --> C
    C --> D
    B -- No --> E
    E --> F
    F -- Yes --> A
    F -- No --> E
    D -- Yes --> A
    D -- No --> C

Local Procedure Calls (LPC)

Local Inter-Process Communication - Wikipedia

LPC aka Local Inter-Process Communication is the feature for threads to synchronize and communicate when a memory is not shared.
We can exchange messages in synchronous and asynchronous communication modes via ports.

RPC

Remote procedure call - Wikiwand

RPC is a communication mechanism that allows a process to invoke a procedure (function/method) on a remote server as if it were a local function call. The caller does not need to handle the complexities of network communication explicitly.

The remote procedures provide an interface using Interface Definition Language (IDL). The compiler receives the IDL interface to generate stubs that allow the local procedure to initiate remote calls. We can see the stubs as placeholder functions facilitating calls for run-time library functions.
👉 Interface Definition Language (IDL)

Differences

  • In RPC, programs can be executed from a different computer while in LPC, programs are executed by the host computer.
  • RPC is slower than LPC since it uses the network to invoke the method.
  • With RPC the procedure call can be executed on a remote machine which can be addressed in several ways.
  • The parameters and return value need to be serializable (to use java terminology).
  • RPC’s can fail due to network issues.
  • RPC’s need to be set up before using them.
  • The language used to call the remote procedure and the language implementing the remote procedure are not necessarily the same.

gRPC