Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze the actual combat and principle of RPC

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

How to analyze the actual combat and principle of RPC? in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.

What is RPC?

Remote Procedure Call, remote procedure call.

What is the purpose of RPC?

Shield the difference between remote calls and local calls

Hide the complexity of the underlying network communications so that we can focus more on our business.

RPC step

Why do you need serialization?

The network transmission must be "binary", and the caller's parameters are all objects.

Request ↔ binary message body

Zero copy what is zero copy?

Why do you need zero copy?

Network card and other operations can only be operated through the kernel. In order to send network data, applications need to copy the data to the kernel.

How to achieve zero copy?

Virtual memory

Mmap + write

Sendfile

What is the difference between zero copy of Netty?

A request that may be split into multiple packets

The combination of packets in user space to solve the problem of copy processing in user space memory, CompositeByteBuf

It also includes data copy of user space and kernel space: Direct Buffers

Dynamic agent implementation

JDK: proxy interface only

Javassist: operate the underlying bytecode without reflection and good performance

Byte Buddy: easier API, faster than Javassist, Spring, Jackson use

HTTP/2 characteristics

Multiplexing, sending stream data in both directions on the same link

Header compression

Why do you need service discovery?

Public "address book"

Why not use DNS?

DNS multi-level cache with long cache time

Need to set up load balancing, extra cost

Timed tasks & the problem of timing tasks in turn?

Future starts the thread for asynchronous programming, sleep

If 5 seconds timeout, high concurrency

Let CPU extra polling traversal, a waste of CPU

Application of time wheel

Delay message

Order expired (10 minutes unpaid, cancel order)

Clock wheel essence

Reduce additional scanning operations

Application of time Wheel in RPC

Timeout processing of caller request to save CPU

Time wheel realization

TimeWheel of Netty

How do I register and discover services?

RPC Server provides services to register itself with Registry

RPC Client invokes the service to pull the list of services from Registry

When the Server node changes, the change is synchronized, and the Client awareness refreshes the local "service node list"

Achieve:

Registry API

Service Health status Monitoring: session timeout Control Mechanism of ZooKeeper

Service status change Notification: ZooKeeper's Watcher Mechanism

How to implement RPC remote call?

How to establish network connection between client and server: HTTP, Socket

How the server handles requests: NIO (using Netty)

What protocol is used for data transmission?

How data is serialized and deserialized: JSON,PB,Thrift

How to track microservices?

Core idea: call chain, globally unique ID concatenates the same request so as to restore the call relationship and count the system indicators.

Registry selection

High availability

Cluster deployment: multiple instances

Multi-computer room deployment: irresistible factors such as power outage in one computer room

Data consistency

CP type: ZooKeeper (Redis), strong consistency, computer room discontinuous network, registry unavailable

AP: sacrifice consistency to ensure availability. Eureka

Open source RPC framework qualifying language

Dubbo:Java, Ali

Motan:Java, Weibo

Tars:C++, Tencent (multilingual support)

Spring Cloud:Java

Gateway Zuul

Registry Eureka

Service timeout circuit breaker Hystrix

Call chain monitoring Sleuth

Log analysis ELK

Cross-language RPC framework

GRPC:HTTP/2

Thrift:TCP

Spring Cloud micro-service architecture

This is the answer to the question about how to analyze the actual combat and principle of RPC. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report