SlideShare a Scribd company logo
1 of 23
Download to read offline
快快樂樂 (?) ⽤用 GRPC
+ Python
Andy Dai

daikeren@gmail.com
!1
緣起
• ⼀一切都是意外

• 60+ RD

• 4x Microservice

• ASP.net + Go + Node.js (+ Python)

• gRPC
!2
gRPC 是啥?
https://grpc.io/
!3
特⾊色
• Google 出的

• ⽀支援很多語⾔言

• 好像很厲害
!4
有個架構叫做 REST
• 各家都在⽤用

• ⽀支援很多語⾔言

• 好像沒有很厲害,可是很好理理解
!5
Problem in REST
• (也許)RESTful 不是這麼適合做 API 

• json 的問題

• Schema 

• Type

• Performance
!6
GRPC with Python in
10 minutes
!7
Protocol Buffer
• Serialization & Deserialization of Data

• Data Type

• Smaller, Faster
!8
Protocol Buffer
!9
syntax = "proto3";
package hello;
message Request {
string name = 1;
int64 val = 2;
}
enum Setting {
TEST = 0 ;
TEST2 = 1 ;
}
來來看看 Code
!10
GRPC
• Google 做的 RPC implementation

• HTTP 2.0 + Protocol Buffer 

• ⽀支援不同語⾔言的 Server/Client 實作
!11
GRPC
!12
Why GRPC?
• 你需要建構 Low Latency 的系統

• 你要建構 REST 可能沒辦法滿⾜足需求的系統

• Mobile Client

• 你的研發團隊使⽤用了了不同語⾔言建構 microservice
!13
4 kinds of RPC
• Unary RPC

• Server streaming RPC

• Client streaming RPC

• Bidirectional streaming RPC
!14
開發 GRPC 程式
• 安裝套件

• 寫 .proto 檔案

• Implement Server 

• Implement Client
!15
安裝套件
!16
pip install grpcio grpcio-tools
.proto File
!17
syntax = "proto3";
package hello;
message Request {
string name = 1;
}
message Response {
string val = 1;
}
service Hello {
rpc Echo(Request) returns (Response);
}
codegen
!18
python -m grpc_tools.protoc 

--proto_path=. 

--python_out=. 

--grpc_python_out=. 

hello.proto
proto_path: .proto 檔案的位置
python_out: protobuf Python code 的位置
grpc_python_out: gRPC Python code 的位置
來來看看 Code
!19
GRPC in Python - The bad
parts
• Performance 

• ECO-system

• gRPC + Python 的⼩小問題
!20
Conclusion
• 對於 GRPC with Python 的簡單介紹

• protobuf

• Server/Client Implementation

• 該⽤用 GRPC 嗎?
!21
Q&A
!22
Reference
• https://grpc.io/

• gRPC errors http://avi.im/grpc-errors/

• https://github.com/daikeren/grpc_talk
!23

More Related Content

What's hot

Rpc调试通用
Rpc调试通用Rpc调试通用
Rpc调试通用geeksec80
 
你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事Mu Chun Wang
 
Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Mu Chun Wang
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub維佋 唐
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹Max Ma
 
幸福快樂的完美結局
幸福快樂的完美結局幸福快樂的完美結局
幸福快樂的完美結局Anna Su
 
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作奕浦 郭
 
Git & Sourcetree 介紹
Git & Sourcetree 介紹Git & Sourcetree 介紹
Git & Sourcetree 介紹Adison wu
 
如何與全世界分享你的 Library
如何與全世界分享你的 Library如何與全世界分享你的 Library
如何與全世界分享你的 LibraryMu Chun Wang
 
網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體Mu Chun Wang
 

What's hot (11)

Rpc调试通用
Rpc调试通用Rpc调试通用
Rpc调试通用
 
你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事你畢業後要任職的軟體業到底都在做些什麼事
你畢業後要任職的軟體業到底都在做些什麼事
 
Windbg入门
Windbg入门Windbg入门
Windbg入门
 
Funliday 新創生活甘苦談
Funliday 新創生活甘苦談Funliday 新創生活甘苦談
Funliday 新創生活甘苦談
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
 
Git基礎介紹
Git基礎介紹Git基礎介紹
Git基礎介紹
 
幸福快樂的完美結局
幸福快樂的完美結局幸福快樂的完美結局
幸福快樂的完美結局
 
Git 入門與實作
Git 入門與實作Git 入門與實作
Git 入門與實作
 
Git & Sourcetree 介紹
Git & Sourcetree 介紹Git & Sourcetree 介紹
Git & Sourcetree 介紹
 
如何與全世界分享你的 Library
如何與全世界分享你的 Library如何與全世界分享你的 Library
如何與全世界分享你的 Library
 
網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體網路服務就是一連串搜尋的集合體
網路服務就是一連串搜尋的集合體
 

Similar to Grpc + python.key

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨Wen-Tien Chang
 
[3]投影片 futurewad樹莓派研習會 141204
[3]投影片 futurewad樹莓派研習會 141204[3]投影片 futurewad樹莓派研習會 141204
[3]投影片 futurewad樹莓派研習會 141204CAVEDU Education
 
Comment System of 56.com
Comment System of 56.comComment System of 56.com
Comment System of 56.comHo Kim
 
愛創小小聚201307 小強分享
愛創小小聚201307 小強分享愛創小小聚201307 小強分享
愛創小小聚201307 小強分享iTrEnD
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3Angel Boy
 
做自己的可可豆夾 @ cocoahead.tw
做自己的可可豆夾 @ cocoahead.tw做自己的可可豆夾 @ cocoahead.tw
做自己的可可豆夾 @ cocoahead.twKai-Yuan Cheng
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿Liu Allen
 
Go for web
Go for webGo for web
Go for webWeng Wei
 
Mesos-based Data Infrastructure @ Douban
Mesos-based Data Infrastructure @ DoubanMesos-based Data Infrastructure @ Douban
Mesos-based Data Infrastructure @ DoubanZhong Bo Tian
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版Jackson Tian
 
[students AI workshop] Pytorch
[students AI workshop]  Pytorch[students AI workshop]  Pytorch
[students AI workshop] PytorchTzu-Wei Huang
 
用 GCC 讓你的 PostgreSQL 噴噴噴~
用 GCC 讓你的 PostgreSQL 噴噴噴~用 GCC 讓你的 PostgreSQL 噴噴噴~
用 GCC 讓你的 PostgreSQL 噴噴噴~Little Sky
 
Introduction to big data
Introduction to big dataIntroduction to big data
Introduction to big data邦宇 叶
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用勇浩 赖
 
SACC2015 ”互联网+“任重而道远-白金&高春辉
SACC2015 ”互联网+“任重而道远-白金&高春辉SACC2015 ”互联网+“任重而道远-白金&高春辉
SACC2015 ”互联网+“任重而道远-白金&高春辉ptcracker
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeAngel Boy
 
淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践丁 宇
 
与Python一路走来
与Python一路走来与Python一路走来
与Python一路走来leejd
 

Similar to Grpc + python.key (20)

⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨⼤語⾔模型 LLM 應⽤開發入⾨
⼤語⾔模型 LLM 應⽤開發入⾨
 
[3]投影片 futurewad樹莓派研習會 141204
[3]投影片 futurewad樹莓派研習會 141204[3]投影片 futurewad樹莓派研習會 141204
[3]投影片 futurewad樹莓派研習會 141204
 
Comment System of 56.com
Comment System of 56.comComment System of 56.com
Comment System of 56.com
 
愛創小小聚201307 小強分享
愛創小小聚201307 小強分享愛創小小聚201307 小強分享
愛創小小聚201307 小強分享
 
Binary exploitation - AIS3
Binary exploitation - AIS3Binary exploitation - AIS3
Binary exploitation - AIS3
 
做自己的可可豆夾 @ cocoahead.tw
做自己的可可豆夾 @ cocoahead.tw做自己的可可豆夾 @ cocoahead.tw
做自己的可可豆夾 @ cocoahead.tw
 
课题二:Node.js那些事儿
课题二:Node.js那些事儿课题二:Node.js那些事儿
课题二:Node.js那些事儿
 
Go for web
Go for webGo for web
Go for web
 
Mesos-based Data Infrastructure @ Douban
Mesos-based Data Infrastructure @ DoubanMesos-based Data Infrastructure @ Douban
Mesos-based Data Infrastructure @ Douban
 
D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版D2_node在淘宝的应用实践_pdf版
D2_node在淘宝的应用实践_pdf版
 
[students AI workshop] Pytorch
[students AI workshop]  Pytorch[students AI workshop]  Pytorch
[students AI workshop] Pytorch
 
用 GCC 讓你的 PostgreSQL 噴噴噴~
用 GCC 讓你的 PostgreSQL 噴噴噴~用 GCC 讓你的 PostgreSQL 噴噴噴~
用 GCC 讓你的 PostgreSQL 噴噴噴~
 
Introduction to big data
Introduction to big dataIntroduction to big data
Introduction to big data
 
Python 于 webgame 的应用
Python 于 webgame 的应用Python 于 webgame 的应用
Python 于 webgame 的应用
 
SACC2015 ”互联网+“任重而道远-白金&高春辉
SACC2015 ”互联网+“任重而道远-白金&高春辉SACC2015 ”互联网+“任重而道远-白金&高春辉
SACC2015 ”互联网+“任重而道远-白金&高春辉
 
Linux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledgeLinux binary Exploitation - Basic knowledge
Linux binary Exploitation - Basic knowledge
 
Go
GoGo
Go
 
Go
GoGo
Go
 
淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践淘宝网前台应用性能优化实践
淘宝网前台应用性能优化实践
 
与Python一路走来
与Python一路走来与Python一路走来
与Python一路走来
 

More from Andy Dai

Power UP your CLI
Power UP your CLIPower UP your CLI
Power UP your CLIAndy Dai
 
Search search search
Search search searchSearch search search
Search search searchAndy Dai
 
Django channels
Django channelsDjango channels
Django channelsAndy Dai
 
Django Third party packages
Django Third party packagesDjango Third party packages
Django Third party packagesAndy Dai
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirtyAndy Dai
 
總之來講講 Search
總之來講講 Search總之來講講 Search
總之來講講 SearchAndy Dai
 
Python web meetup 11 18
Python web meetup 11 18Python web meetup 11 18
Python web meetup 11 18Andy Dai
 
Django in heavy load environment
Django in heavy load environmentDjango in heavy load environment
Django in heavy load environmentAndy Dai
 
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞Andy Dai
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summlyAndy Dai
 
Tradeoffs of replacing core components
Tradeoffs of replacing core componentsTradeoffs of replacing core components
Tradeoffs of replacing core componentsAndy Dai
 
ElastiCache
ElastiCacheElastiCache
ElastiCacheAndy Dai
 
Django deploy
Django deployDjango deploy
Django deployAndy Dai
 
Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Andy Dai
 
Boost your django admin with Grappelli
Boost your django admin with GrappelliBoost your django admin with Grappelli
Boost your django admin with GrappelliAndy Dai
 

More from Andy Dai (16)

Power UP your CLI
Power UP your CLIPower UP your CLI
Power UP your CLI
 
Search search search
Search search searchSearch search search
Search search search
 
Django channels
Django channelsDjango channels
Django channels
 
Django Third party packages
Django Third party packagesDjango Third party packages
Django Third party packages
 
Practical django secuirty
Practical django secuirtyPractical django secuirty
Practical django secuirty
 
總之來講講 Search
總之來講講 Search總之來講講 Search
總之來講講 Search
 
Python web meetup 11 18
Python web meetup 11 18Python web meetup 11 18
Python web meetup 11 18
 
Django in heavy load environment
Django in heavy load environmentDjango in heavy load environment
Django in heavy load environment
 
電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞電腦不只會幫你選土豆,還會幫你選新聞
電腦不只會幫你選土豆,還會幫你選新聞
 
用 Python 打造你自己的 summly
用 Python 打造你自己的 summly用 Python 打造你自己的 summly
用 Python 打造你自己的 summly
 
Tradeoffs of replacing core components
Tradeoffs of replacing core componentsTradeoffs of replacing core components
Tradeoffs of replacing core components
 
ElastiCache
ElastiCacheElastiCache
ElastiCache
 
Dynamo db
Dynamo dbDynamo db
Dynamo db
 
Django deploy
Django deployDjango deploy
Django deploy
 
Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)Build your own trello witihin 100 LOC (with Meteor)
Build your own trello witihin 100 LOC (with Meteor)
 
Boost your django admin with Grappelli
Boost your django admin with GrappelliBoost your django admin with Grappelli
Boost your django admin with Grappelli
 

Grpc + python.key