为什么要用Thrift
Why Thrift, Why not HTTP RPC(JSON+gzip)
https://stackoverflow.com/questions/9732381/why-thrift-why-not-http-rpcjsongzip
A few reasons other than speed:
-
Thrift generates the client and server code completely, including the data structures you are passing, so you don't have to deal with anything other than writing the handlers and invoking the client. and everything, including parameters and returns are automatically validated and parsed. so you are getting sanity checks on your data for free.
- Thrift生成的代码,包含传递数据的数据结构。不用费劲地写客户端处理器,参数和返回值都被自动化实现验证,你可以很方便地对你的数据做常规的检查。
-
Thrift is more compact than HTTP, and can easily be extended to support things like encryption, compression, non blocking IO, etc.
- Thrift比HTTP协议更紧凑,很容易扩展去支持一些东西:加密,压缩,非阻塞的IO。
-
Thrift can be set up to use HTTP and JSON pretty easily if you want it (say if your client is somewhere on the internet and needs to pass firewalls)
- Thrift能够简单设置为使用HTTP协议和JSON协议,如果你需要这么做(比如说你的客户端运行在因特网的某个地方,需要穿越防火墙)。
-
Thrift supports persistent connections and avoids the continuous TCP and HTTP handshakes that HTTP incurs.
- Thrift支持持久化连接,并且能够避免并不断的TCP和HTTP握手操作,这些操作常在HTTP协议里发生。
Personally, I use thrift for internal LAN RPC and HTTP when I need connections from outside.
I hope all this makes sense to you. You can read a presentation I gave about thrift here:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2011-03-20 WPF/Silverlight Book Model