内容简介:作为后端开发, 你是否有考虑过这个问题:明明已经有http+restful api + json了,为什么还要上各种rpc框架?举个简单的例子,以查户口为例:http + json的形式:
作为后端开发, 你是否有考虑过这个问题:明明已经有http+restful api + json了,为什么还要上各种rpc框架?
举个简单的例子,以查户口为例:
http + json的形式:
我们写一个http server, 就提供一个接口 GET /persion ,然后返回
20150827163347625.jpeg
···
{
"name":"xiaoerhei",
"age": "28"
}
grpc+pb(非常不准确的格式,意会即可):
name|xiaoerhei|age|28
- 少了很无用的http头
- 少了json很多无用的分隔符
- pb序列化和反序列化的性能比比json高很多
在树莓派上做了简单的对比测试, golang + grpc + pb的方式 比 golang + http server+ json的形式,QPS可以高5~10倍。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:- 实战·使用taro+云开发快速开发小程序
- iOS开发之使用Git的基本使用(一)
- 使用IntelliJ IDEA开发SpringMVC网站(一)开发环境
- 使用 deprecated 声明防止开发人员使用危险的系统函数
- 使用Go开发前端应用
- 使用容器Docker进行开发
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Building Social Web Applications
Gavin Bell / O'Reilly Media / 2009-10-1 / USD 34.99
Building a social web application that attracts and retains regular visitors, and gets them to interact, isn't easy to do. This book walks you through the tough questions you'll face if you're to crea......一起来看看 《Building Social Web Applications》 这本书的介绍吧!