Remote Procedure Call (RPC) protokoll hajutatud süsteemis

⚡ Nutikas kokkuvõte

Remote Procedure Call (RPC) is an interprocess communication protocol that lets a program execute a procedure in another address space or machine, hiding network details behind an ordinary local function call in distributed client-server systems.

  • 📞 Määratlus: RPC lets a client invoke a procedure on a remote server as if it were a local call.
  • 🗂️ tüübid: Callback, Broadcast, and Batch-mode RPC differ in how requests are routed and queued.
  • 🏗️ ArchiStruktuur: Five parts cooperate on each call: client, client stub, RPC runtime, server stub, and server.
  • 🔄 Kuidas see käib: Stubs marshal parameters into a message and unmarshal the result returned to the caller.
  • 🇧🇷 Kompromissid: RPC simplifies distributed code but adds network overhead and failure points versus local calls.
  • 🤖 AI nurk: gRPC serves machine learning models between microservices, and Copilot speeds up writing RPC stubs.

Remote Procedure Call (RPC) in Distributed System

Mis on RPC?

Remote Procedure Call (RPC) on protsessidevaheline suhtlus technique used for client-server applications. The full form of RPC is Remote Procedure Call. RPC mechanisms are used when a computer program causes a procedure or subroutine to execute in a different address space, coded as a normal procedure call without the programmer explicitly coding the details for the remote interaction.

This procedure call also manages low-level transport protocols, such as UDP and TCP/IP, to carry the message data between programs.

RPC tüübid

RPC-d on kolme tüüpi:

  • Tagasihelistamise RPC
  • Saate RPC
  • Partiirežiimis RPC

Tagasihelistamise RPC

This type of RPC enables a peer-to-peer (P2P) paradigm between participating processes. It helps a process to act as both a client and a server.

Tagasihelistamise RPC funktsioonid:

  • Handles remotely processed, interactive application problems.
  • Provides the server with the client’s handle.
  • Callback makes the client process wait.
  • Manages callback deadlocks.
  • It facilitates a peer-to-peer paradigm among participating processes.

Saate RPC

Broadcast RPC is a client’s request that is broadcast on the network and processed by all servers that have the method for processing that request.

Broadcast RPC funktsioonid:

  • Allows you to specify that the client’s request message has to be broadcast.
  • Saate deklareerida edastuspordid.
  • It helps to reduce the load on the physical network.

Partiirežiimis RPC

Batch-mode RPC helps to queue separate RPC requests in a transmission buffer on the client side, and then send them over a network in one batch to the server.

Functions of Batch-mode RPC:

  • It minimizes the overhead involved in sending a request, as it sends requests over the network in one batch to the server.
  • This type of RPC protocol is only efficient for applications that need lower call rates.
  • See vajab usaldusväärset edastusprotokolli.

RPC Architektuur

RPC arhitektuuril on peamiselt viis programmi komponenti:

  1. klient
  2. Klient Stub
  3. RPC käitusaeg
  4. Server Stub
  5. server

RPC Architektuur

RPC Architektuur

Kuidas RPC töötab?

The following steps take place during the RPC process:

Step 1) The client, the client stub, and one instance of the RPC runtime execute on the client machine.

Step 2) The client starts a client stub process by passing parameters in the usual way. The client stub is stored within the client’s own address space. It also asks the local RPC Runtime to send the request to the server stub.

Step 3) In this stage, the user accesses RPC by making a regular local procedure call. The RPC Runtime manages the transmission of messages between the client and server across the network. It also performs the job of retransmission, acknowledgment, routing, and encryption.

Step 4) After completing the server procedure, execution returns to the server stub, which packs (marshals) the return values into a message. The server stub then sends the message back to the transport layer.

Step 5) In this step, the transport layer sends the result message back to the client transport layer, which returns the message to the client stub.

Step 6) In this stage, the client stub demarshals (unpacks) the return parameters in the resulting packet, and execution returns to the caller.

RPC omadused

Siin on RPC põhiomadused:

  • The called procedure is in another process, which is likely to reside on another machine.
  • Protsessid ei jaga aadressiruumi.
  • Parameetrid edastatakse ainult väärtuste järgi.
  • RPC käivitub serveriprotsessi keskkonnas.
  • It does not offer access to the calling procedure’s environment.

RPC omadused

Siin on RPC olulised funktsioonid:

  • Simple call syntax.
  • Offers known semantics.
  • Provides a well-defined interface.
  • It can communicate between processes on the same or different machines.

RPC eelised

Here are the pros/benefits of RPC:

  • RPC helps clients communicate with servers through the conventional use of procedure calls in high-level languages.
  • RPC is modeled on the local procedure call, but the called procedure is most likely executed in a different process and usually on a different computer.
  • RPC supports process-oriented and thread-oriented models.
  • RPC makes the internal message-passing mechanism hidden from the user.
  • See kohustab jõudlust parandama paljud protokollikihid.
  • RPC annab kõhulihastele lihaspingeidtraction; for example, the message-passing nature of network communication remains hidden from the user.
  • RPC can be used in both distributed and local environments.
  • The effort needed to re-write and re-develop the code is minimal.

RPC miinused

Siin on RPC kasutamise miinused/miinused:

  • Remote Procedure Call passes parameters by values only; pointer (reference) values are not allowed.
  • Remote procedure call (and return) time — the overhead — is significantly higher than for a local procedure.
  • This mechanism is highly vulnerable to failure, as it involves a communication system, another machine, and another process.
  • The RPC concept can be implemented in different ways, so there is no single standard.
  • It does not offer flexibility for hardware architecture, as it is mostly interaction-based.
  • The cost of the process increases because of the remote procedure call.

KKK

RPC exposes actions as remote procedures, while REST exposes data as resources accessed over HTTP verbs. RPC feels like calling a local function; REST centers on resources and state.

gRPC is Google’s modern, high-performance RPC framework. It uses HTTP/2 and Protocol Buffers, and supports bidirectional streaming, making it popular for microservice communication.

RPC can be both. A synchronous call blocks until the server returns a result, while an asynchronous call returns immediately and handles the response later. Frameworks like gRPC support both styles.

RPC is a form of IPC that works across separate machines. While many IPC methods share memory on one host, RPC exchanges messages over a network so processes on different computers can cooperate.

Common RPC implementations include gRPC, Apache Thrift, XML-RPC, JSON-RPC, and Java RMI. They differ in data format and transport but all let a client call a procedure on a remote server.

RPC is not secure by default; security depends on the transport. Implementations add TLS encryption, authentication tokens, and access controls to protect calls.

Machine learning platforms use RPC, especially gRPC, to serve model predictions between microservices. A client sends features and receives an inference result, keeping AI systems fast and loosely coupled.

Yes. GitHub Copilot can scaffold .proto service definitions, client stubs, and server handlers for gRPC. Developers should still review generated interfaces, error handling, and versioning before deploying to production.

Võta see postitus kokku järgmiselt: