Current location - Quotes Website - Signature design - Why do microservice calls use RPC framework? Isn't http simpler?
Why do microservice calls use RPC framework? Isn't http simpler?
Simply put, HTTP is a protocol and RPC is a concept! The realization of RPC can be based on HTTP protocol (Feign), TCP protocol (Netty), RMI protocol (Soap) and Web service (XML-RPC) framework. In the transmission process, some frameworks and protocols have appeared because of the different serialization methods, such as Dubbo protocol in Dubbo, gRpc—Protobuf serialization protocol and so on. In fact, they are all based on the concept of remote call. What is a remote call?

The point is that RPC is a remote call. Remote call means that the client sends the called interface, parameters, parameter types, methods, return values, return value types, etc. (These are called method signatures) are sent to the server through the above protocol to inform the server of the interface methods that need to be called. This process is the realization process of RPC! HTTP and RPC are two different things!

In terms of performance, HTTP itself is based on TCP protocol and belongs to the application layer protocol, so the HTTP protocol itself will occupy a lot of resources (memory, bandwidth, etc.). In the process of implementation, and the performance is definitely not as fast as the RPC protocol directly through TCP, no matter how optimized HTTP is, it is definitely not as good as TCP! On the other hand, TCP relies on bytecode. At present, it is generally adopted to send the interface information called by the client to the server in a serialized way. Serialization framework also contains many (Hession, Protobuf, Kryo, etc. ). The highest serialization performance is Kryo, and the smallest bytecode after serialization is Protobuf. The smaller the bytecode after serialization, the less bandwidth it occupies, the shorter the serialization time and the shorter the thread IO waiting time. Therefore, there are many technologies that can be discussed at the specific application level, and you can choose the corresponding technology according to your own hardware capabilities!

Welcome people who love technology to discuss!