RPC Learning & Comparison of GPROTOBUF and thrift

Source: Internet
Author: User

Reference http://blog.csdn.net/pi9nc/article/details/17336663

RPC Framework RPC with integrated Libevent,google protobuf (Remote Procedure Call), Chinese translation is a long-range procedure invocation, which in fact is not a new concept in principle. My understanding is that there are interfaces between different machines, as well as client and server side The client can invoke a server-side service that is already registered through a negotiated interface. Plainly speaking, it is also the mechanism of network communication. Since it is still network communication, why do you need to use RPC instead of yourself to do such a job? If you do such a thing, you need to consider the codec, network layer, In particular, many of the details need to be focused on: What are the protocols? How to define a format? It is also important to consider the network and host byte order when it comes to integers, and if logic programmers need to pay attention to these details, it is obviously too cumbersome. There are few documents for domestic companies to develop If you are looking for a problem, you need to read the code to know the meaning of the various fields in the protocol, which can have a significant impact on the maintainability of the project. If RPC is used, the protocol is defined by the RPC tool-defined format. And the network layer should only focus on the work of the network layer, The logical layer schema completes the logical operation on top of the network layer. Separating the network from the logic is also a clear architectural design.

Google Protobuf is a set of tools that Google exposes for use in Protocol codecs for network communications, using the format it defines, you can define the fields of the protocol, and the compiler that comes with it generates code files that are responsible for codec (many different language files can be generated). At the same time, It also includes the basic RPC interface definition. However, the big problem with this tool with RPC is that it is only responsible for generating code files, and if it is actually used as an RPC framework, it needs to be encapsulated on the network layer. But in its own official document, it does not give a demo that tells the reader how to do such a job step-by-step. Thrift is a tool library that is also located with Google Protobuf, in addition to the same features as Google Protobuf, such as multi-lingual support, Cross-platform, efficient codec, also integrates the network communication layer, you can use it to complete all the RPC needs to complete the work. On this page, Google Protobuf gives some known projects that encapsulate it in different languages.

Chenshuo's Evproto is also an RPC framework that integrates libevent with Google Protobuf, but there are different ways to use libevent:
1) He uses the RPC functionality of Libevent, which only uses the most basic functionality of libevent for network I/O encapsulation.
2) The reason for 1) is because I think a tool should preferably be "do one thing, do it Better" (perhaps from this can explain why Google Protobuf does not have a network layer like thrift, but to leave the job to the user), Libevent is getting bigger and larger, besides the encapsulation of I/O, signal, timer and so on, there is now RPC, support for asynchronous Dns,http protocol and so on, really, if just focus on the multiplexing mechanism of network I/O, Then almost any skilled programmer can quickly make such a set of things themselves, using libevent is nothing more than to prepare for the possible cross-platform in the future. With my libevent development direction, I have also thought about using Libev instead of libevent, But for the time being, I don't want to toss this thing.

EVENTRPC Project is currently a sub-project under Avidya, Avidya Project positioning is to achieve a number of distributed toy systems (such as Google has published paper CHUBBY,MAPREDUCE,GFS, etc.), may not be able to be used in the future, But it has to be done in practice. Because there is a good RPC framework to do distributed essentials, all first implement EVENTRPC this subproject, and later may also implement other language versions, such as Python,java.

On the EVENTRPC network model, using the previously mentioned memcached network model, the main thread is responsible for receiving new connections and then handing these new connections to the secondary thread, each with an I/O dispatcher. In the Samples directory, There is a client and server-side example that implements the Echo service.

Before using, make sure that Libevent and Google Protobuf are installed successfully and are currently available only under Linux.

RPC Learning & Comparison of GPROTOBUF and thrift

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.