Home > Article > Web Front-end > What is RPC communication in Node.js? What is the difference between it and Ajax?
This article will take you to understand RPC communication and introduce the similarities and differences between RPC and Ajax. I hope it will be helpful to everyone!
For back-end personnel, RPC communication is very familiar and easy Things to understand, but for front-end personnel like me, RPC is relatively unfamiliar and it is relatively difficult to understand. Regarding this problem, let's try it today and understand RPC communication from the front-end perspective. [Recommended learning: "nodejs Tutorial"]
RPC and Ajax are very similar, and there are many similarities between them. For example:
is a communication between two computers
The data format will be agreed upon
The difference between RPC and Ajax:
is not necessarily based on DNS as an addressing service
The application layer protocol is generally not used HTTP protocol
Based on TCP or UDP protocol
Let’s talk about the differences between them one by one:
The URL that Ajax initiates a request is generally like this, For example: HTTP://domain name/path
, but the communication between computers relies on IP instead of domain name, so an addressing server is needed to find the IP corresponding to the domain name, which is what Ajax uses. DNS serves as the addressing server. After obtaining the IP address, the browser finds the corresponding server based on the IP address, and then the server returns the data to the browser.
The process is as shown below:
RPC is similar to the parsing process of Ajax. But it does not use DNS to address the server, and it uses a certain ID to find the corresponding IP. For example: Alibaba’s ID is similar to VIP.
The browser uses TCP to follow the HTTP specification, but there are many ways to use TCP with RPC :
1.Simplex communication
2.Half-duplex communication
3.Duplex communication
1. Smaller data packet size (binary data instead of text data) 2. Faster encoding and decoding speed ( The computer's encoding and decoding speed for binary data is obviously higher than the encoding and decoding speed for text data!)
NodejS's buffer encoding and decoding binary data. So, see you next time. study hard, improve every day!
For more programming related knowledge, please visit:Programming Video! !
The above is the detailed content of What is RPC communication in Node.js? What is the difference between it and Ajax?. For more information, please follow other related articles on the PHP Chinese website!