乐闻世界logo
搜索文章和话题

What is RPC? What are the basic principles and workflow of RPC?

2月22日 14:06

RPC (Remote Procedure Call) is a technology that allows programs to call functions on a remote server as if they were local functions. Its core principles include:

Basic Concepts:

  • RPC hides the complexity of network communication, making distributed system development simpler
  • Client initiates a call request, server executes and returns results
  • Data transmission is achieved through serialization and deserialization

Workflow:

  1. Client calls local stub
  2. Stub serializes parameters
  3. Transmits over network to server
  4. Server receives and deserializes parameters
  5. Server executes actual function
  6. Result is serialized and returned to client
  7. Client receives and deserializes result

Key Components:

  • Serialization Protocol: Protobuf, Thrift, JSON
  • Transport Protocol: HTTP/2, TCP, gRPC
  • Service Registration and Discovery: Consul, Etcd
  • Load Balancing: Nginx, HAProxy

Common RPC Frameworks:

  • gRPC: Based on HTTP/2 and Protobuf
  • Dubbo: Alibaba's open-source Java RPC framework
  • Thrift: Facebook's open-source cross-language framework
  • Spring Cloud OpenFeign: Declarative RPC based on HTTP

Advantages:

  • Simplifies distributed system development
  • Supports multiple programming languages
  • High performance, low latency
  • Easy to scale and maintain

Challenges:

  • Network failure handling
  • Service discovery and governance
  • Serialization performance optimization
  • Security assurance
标签:RPC