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

What is the difference between grpc and thrift in rpc framework

2025-03-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the difference between grpc and thrift in the rpc framework". In the daily operation, I believe that many people have doubts about the difference between grpc and thrift in the rpc framework. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the question of "what is the difference between grpc and thrift in the rpc framework?" Next, please follow the editor to study!

First, language support is different.

Grpc and thrift have different support for different languages, and thrift has more support than grpc. How to choose rpc framework needs to be combined with the company's technology stack. For example, php does not support server of grpc, so some companies can only use thrift as their rpc framework.

Grpc supports 11 languages, of which php only supports client.

Caterpillar: follow the instructions under the src/cpp directory

C#: NuGet package Grpc

Dart: pub package grpc

Go: go get google.golang.org/grpc

Java: Use JARs from Maven Central Repository

Node: npm install grpc

Objective-C: Add gRPC-ProtoRPC dependency to podspec

PHP: pecl install grpc

Python: pip install grpcio

Ruby: gem install grpc

WebJS: follow the grpc-web instructions

Second, the codec protocols are different

There is a big difference between thrift and pb compared with xml,json.

Different coding methods

Xml,json is encoded in text mode, while thrift and pb can support binary encoding.

Idl

Through idl, it is convenient for the client and the server to maintain the data structure and generate it uniformly. After the project is very large, the maintenance cost is reduced.

Efficiency

Because of the different encoding methods and implementation, it can be considered that the performance of TCompactProtocol and pb is the same, which is better than that of json and xml, but the specific data type will affect the performance gap. For example, the json encoding and decoding of double type data is particularly poor. There is an article to refer to: https://www.infoq.cn/article/json-is-5-times-faster-than-protobuf.

Third, different transport protocols

In the transport layer, grpc uses http2, and thrift supports a variety of custom tcp layer transport methods such as Tsocket, TFramedTransport, TFileTransport, TZlibTransport and so on.

Fourth, how to choose?

Technology stack is a very important factor, multi-language especially php, it may be more appropriate to choose thrift.

It is more appropriate to support http2,grpc.

Grpc has a more complete example.

Thrift is more documented than grpc.

At this point, the study on "what is the difference between grpc and thrift in the rpc framework" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

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

Internet Technology

Wechat

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

12
Report