Comparison of Several distributed call technologies-RPC vs rest

Source: Internet
Author: User

I used to work in a traditional IT company, and then came to the Internet and felt a lot different. One of them was that there were some differences in the technology they used. For example, distributed calling technology.

My internal service architecture in this company is based on thrift, and the service is released based on thrift, so many people have never heard of or used Web Services.

SOA, which has been passed through traditional it for many years, is based on Web Services. It already has a complete set of theories and products for support. Many of the Internet has not been involved. Later I Thought About It. Traditional it focuses more on the integration of various resources, focusing on heterogeneous systems. The complexity of legacy system integration does not require high efficiency. The Internet imposes extremely high requirements on efficiency, and the internal system's Web service performance cannot keep up. In addition, the Services released to the outside world now have better rest, and there are not so many scenarios for using web services.


I use a relatively large term "distributed call" to indicate access from one machine to another.To put it bluntly, with the development of technology and business, the computing capability of a single machine cannot meet the increasing IT business needs, storage Capacity expanded to multiple machines.


The underlying foundation of distributed calling is network programming. One machine sends messages to another machine. After receiving the messages, the other machine does some work according to a certain protocol.:

1. For example, call a method.

2. For example, operations on a resource


Distributed calling is basicallyThere are two types: RPC and rest.The main differences between the two are:

1. RPC is action-oriented (method call)

2. Rest is resource-oriented (URL indicates resources and HTTP verb indicates actions)


From the perspective of realization form, the RPC programming model is more important and the rest programming model is more lightweight.


The main focus of the distributed calling technology is four. The first two points are common, and the last two points are newly added:

1. What transmission protocol, TCP, HTTP, or others are used?

2. what serialization protocol is used (also called codec, codec, and callback alling), such as text-based XML (custom XML, or soap), binary stream (Java serialization, or custom serialization Protocol, for example, thrift, protobuf, JBoss implements alling)

3. What Io format is used, blocking Io, non-blocking synchronous io (select/poll/epoll), non-blocking asynchronous Io

4. How to run the service on the HTTP server or a separate process?


According to the first point, the RPC camp is as follows:

1. Web Service uses HTTP as the transport layer protocol and soap as the application layer protocol

2. XML-RPC, using HTTP protocol for Transport Layer Protocol, using custom XML for application layer protocol

3. Both jmi, thrift, and protobuf use TCP as the transmission protocol and custom application layer protocol.


Rest directly uses HTTP as the application layer protocol, uses URL to represent resources, and uses HTTP verbs to represent actions


According to the second point, the RPC camp is as follows:

1. Web Service and XML-RPC are serialized using text-based XML

2. Rmi is based on Java serialization Protocol

3. thrfit and protobuf adopt binary stream-based serialization protocols. For example, the message body is transmitted in the message header, and the length is defined through the message header to ensure correct data read and write.


According to the third point, with the wide application of NiO, more and more servers support non-blocking Io, and the client can adopt synchronous Io or non-blocking Io.

About the concept of blocking, non-blocking, synchronous, asynchronous, read this http://blog.csdn.net/iter_zc/article/details/39291647


About the fourth point, both web service and rest run on the HTTP server, and thrift runs in separate processes.


In addition, the Web Service uses the HTTP layer as the transmission protocol and the text-format soap as the application layer protocol. Compared with the binary stream-based RPC protocol,

Advantage: Based on HTTP transmission, it uses text to traverse the firewall and is suitable for providing services inside and outside the organization.

Disadvantages: text-based serialization is inefficient. The transmission layer is based on HTTP. Compared with TCP, there is an additional layer of protocol, which also affects the performance and is not suitable for scenarios with high performance requirements.


In recent years, rest has replaced web services, mainly because of the advantages of Web services. It is also lightweight, and JSON-based data serialization can also provide better performance. The programming model is simpler, suitable for publishing services outside the Organization.

The RPC technology like thrift can be used in scenarios with high performance requirements within the organization. the serialization protocol based on binary stream and NiO transmission protocol have high performance and are suitable for high concurrency scenarios.











Comparison of Several distributed call technologies-RPC vs rest

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.