![Page 1: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/1.jpg)
Teach your (micro)services speak Protocol Buffers with gRPC.
Mihai Iachimovschi
@mishunika [email protected]
![Page 2: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/2.jpg)
What’s inside?
![Page 3: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/3.jpg)
What’s inside?
–Message serialization and deserialization
![Page 4: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/4.jpg)
What’s inside?
–Message serialization and deserialization
–Message transport
![Page 5: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/5.jpg)
What’s inside?
–Message serialization and deserialization
–Message transport
–Services diversity
![Page 6: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/6.jpg)
How it works in real life
A
B
C
D
![Page 7: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/7.jpg)
How it works in real life
A
B
C
D
![Page 8: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/8.jpg)
In a nutshell
Client Service
![Page 9: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/9.jpg)
In a nutshell
–Over HTTP
–Serialized to JSON
Client Service
![Page 10: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/10.jpg)
In a nutshell
–Over HTTP
–Serialized to JSON
Client Service
–Proprietary protocol
–Remote objects
![Page 11: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/11.jpg)
JSON advantages
![Page 12: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/12.jpg)
JSON advantages
–Human readable
![Page 13: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/13.jpg)
JSON advantages
–Human readable
–Schema-less
![Page 14: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/14.jpg)
JSON advantages
–Human readable
–Schema-less
–Language agnostic
![Page 15: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/15.jpg)
JSON disadvantages
![Page 16: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/16.jpg)
JSON disadvantages
–Human readable
![Page 17: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/17.jpg)
JSON disadvantages
–Human readable Isn’t it a benefit?
![Page 18: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/18.jpg)
JSON disadvantages
–Human readable
–Schema-less
Isn’t it a benefit?
![Page 19: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/19.jpg)
JSON disadvantages
–Human readable
–Schema-less
Isn’t it a benefit?Isn’t it a benefit as well?
![Page 20: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/20.jpg)
JSON disadvantages
–Human readable
–Schema-less
–Type-less
Isn’t it a benefit?Isn’t it a benefit as well?
![Page 21: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/21.jpg)
Protocol Buffers?
“Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.”
— https://developers.google.com/protocol-buffers/
![Page 22: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/22.jpg)
Protocol Buffers?
“Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.”
— https://developers.google.com/protocol-buffers/
![Page 23: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/23.jpg)
Protocol Buffers?
“Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler.”
— https://developers.google.com/protocol-buffers/
JSON
![Page 24: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/24.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 25: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/25.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 26: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/26.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 27: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/27.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 28: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/28.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 29: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/29.jpg)
Protocol Buffers example
message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 30: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/30.jpg)
Protocol Buffers example
message Person { reserved 1, 2, 5; reserved "name"; int32 id = 3; repeated string aliases = 4; }
![Page 31: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/31.jpg)
Why protocol buffers
Binary format
![Page 32: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/32.jpg)
Why protocol buffers
Enforcing the schema
![Page 33: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/33.jpg)
Why protocol buffers
Language neutral
![Page 34: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/34.jpg)
Out-of the box backward compatibility
Why protocol buffers
![Page 35: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/35.jpg)
Out-of the box backward compatibility
Why protocol buffers
![Page 36: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/36.jpg)
Out-of the box backward compatibility
if version == 3: ... elif version > 4: if (version == 5): ... ...
Why protocol buffers
![Page 37: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/37.jpg)
Why protocol buffers
Generally faster
![Page 38: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/38.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
![Page 39: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/39.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
Proto message definition
![Page 40: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/40.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
Person john = Person.newBuilder() .setId(1234) .setName("John Doe") .addAliases("ionel") .build();
Proto message definition
![Page 41: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/41.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
Person john = Person.newBuilder() .setId(1234) .setName("John Doe") .addAliases("ionel") .build();
Proto message definition
Object creation
![Page 42: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/42.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
john = Person() john.id = 1234 john.name = 'John Doe' john.aliases.add(‘ionel’)
Proto message definition
Object creation
![Page 43: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/43.jpg)
How to…message Person { string name = 1; int32 id = 2; repeated string aliases = 3; }
john = Person(id=1234, name='John Doe', aliases=['ionel'])
Proto message definition
Object creation
![Page 44: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/44.jpg)
Communication (REST-ish)
1. URI: https://api.example.com/person/42
2. Make an HTTP GET Request
3. Receive a plaintext JSON
4. Parse it
5. …
![Page 45: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/45.jpg)
Request
GET /person/42 HTTP/1.1 Accept: */* Accept-Encoding: gzip, deflate Connection: keep-alive Host: api.example.com ...
![Page 46: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/46.jpg)
Response headers
HTTP/1.1 200 OK Access-Control-Allow-Credentials: true Cache-Control: public, max-age=14400 Content-Encoding: gzip Content-Type: application/json; charset=utf-8 ...
![Page 47: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/47.jpg)
Response body{ "name": "John Doe", "id": 42, "aliases": [ "ionel", "honzík" ] }
![Page 49: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/49.jpg)
Distributed objects
https://en.wikipedia.org/wiki/Distributed_object
![Page 50: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/50.jpg)
Distributed objects
“First Law of Distributed Object Design:don't distribute your objects”.
— Martin Fowlerhttps://martinfowler.com/articles/distributed-objects-microservices.html
![Page 51: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/51.jpg)
The 8 Fallacies of distributed computing
1. The network is reliable.
2. Latency is zero.
3. Bandwidth is infinite.
4. The network is secure.
5. Topology doesn't change.
6. There is one administrator.
7. Transport cost is zero.
8. The network is homogeneous.
http://www.rgoarchitects.com/Files/fallacies.pdf
![Page 52: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/52.jpg)
Keep in mind…
“Anything that can go wrong will go wrong.”
—Murphy’s Law
![Page 53: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/53.jpg)
So, what’s next?
![Page 54: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/54.jpg)
Services not Objects, Messages not References
http://www.grpc.io/blog/principles
![Page 55: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/55.jpg)
Coverage & Simplicity
http://www.grpc.io/blog/principles
![Page 56: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/56.jpg)
How does it work
![Page 57: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/57.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 58: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/58.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 59: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/59.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 60: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/60.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 61: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/61.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 62: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/62.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 63: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/63.jpg)
Service definition
message GetRoutesRequest { Location origin = 1; Location destination = 2; }
message GetRoutesResponse { repeated Route routes = 1; }
![Page 64: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/64.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 65: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/65.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 66: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/66.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 67: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/67.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 68: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/68.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 69: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/69.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 70: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/70.jpg)
Generate server code
$ python -m grpc_tools.protoc \ --proto_path=../protos \ --python_out=. \ --grpc_python_out=. \ ../protos/route_planner.proto
![Page 71: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/71.jpg)
Generated code
$ tree . ├── route_planner_pb2.py └── route_planner_pb2_grpc.py
0 directories, 2 files
![Page 72: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/72.jpg)
Implementing the service
![Page 73: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/73.jpg)
Implementing the service
![Page 74: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/74.jpg)
Service code
class Servicer(route_planner_pb2_grpc.RoutePlannerServicer): """Service implementation."""
def GetRoutes(self, request, context): return process_magically_the_request(request)
![Page 75: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/75.jpg)
Service code
server = grpc.server( futures.ThreadPoolExecutor(max_workers=10))
route_planner_pb2_grpc.add_RoutePlannerServicer_to_server( Servicer(), server)
server.add_insecure_port('[::]:12345') server.start()
![Page 76: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/76.jpg)
Service code
server = grpc.server( futures.ThreadPoolExecutor(max_workers=10))
route_planner_pb2_grpc.add_RoutePlannerServicer_to_server( Servicer(), server)
server.add_insecure_port('[::]:12345') server.start()
![Page 77: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/77.jpg)
Service code
server = grpc.server( futures.ThreadPoolExecutor(max_workers=10))
route_planner_pb2_grpc.add_RoutePlannerServicer_to_server( Servicer(), server)
server.add_insecure_port('[::]:12345') server.start()
![Page 78: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/78.jpg)
Service code
server = grpc.server( futures.ThreadPoolExecutor(max_workers=10))
route_planner_pb2_grpc.add_RoutePlannerServicer_to_server( Servicer(), server)
server.add_insecure_port('[::]:12345') server.start()
![Page 79: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/79.jpg)
Service code
server = grpc.server( futures.ThreadPoolExecutor(max_workers=10))
route_planner_pb2_grpc.add_RoutePlannerServicer_to_server( Servicer(), server)
server.add_insecure_port('[::]:12345') server.start()
![Page 80: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/80.jpg)
Implementing the client
![Page 81: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/81.jpg)
Implementing the client
![Page 82: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/82.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 83: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/83.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 84: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/84.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 85: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/85.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 86: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/86.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 87: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/87.jpg)
Client code
channel = grpc.insecure_channel(‘localhost:12345')
stub = route_planner_pb2_grpc.RoutePlannerStub(channel)
request = route_planner_pb2.GetRoutesRequest( origin=CURRENT_LOCATION, destination=DESTINATION_COORDS)
response = stub.GetRoutes(request)
![Page 88: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/88.jpg)
Client code (async)
response_future = stub.GetRoutes.future(request)
response_future.result()
![Page 89: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/89.jpg)
grpc_cli
$ grpc_cli call localhost:12345 \ RoutePlanner.GetRoutes \ <<- PROTO origin: <long: 0.0 lat: 0.0> destination: <long: 1.1 lat: 1.1> PROTO
![Page 90: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/90.jpg)
grpc_cli
$ grpc_cli call localhost:12345 \ RoutePlanner.GetRoutes \ <<- PROTO origin: <long: 0.0 lat: 0.0> destination: <long: 1.1 lat: 1.1> PROTO
![Page 91: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/91.jpg)
grpc_cli
$ grpc_cli call localhost:12345 \ RoutePlanner.GetRoutes \ <<- PROTO origin: <long: 0.0 lat: 0.0> destination: <long: 1.1 lat: 1.1> PROTO
![Page 92: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/92.jpg)
grpc_cli
$ grpc_cli call localhost:12345 \ RoutePlanner.GetRoutes \ <<- PROTO origin: <long: 0.0 lat: 0.0> destination: <long: 1.1 lat: 1.1> PROTO
![Page 93: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/93.jpg)
grpc_cli
$ grpc_cli call localhost:12345 \ RoutePlanner.GetRoutes \ <<- PROTO origin: <long: 0.0 lat: 0.0> destination: <long: 1.1 lat: 1.1> PROTO
![Page 94: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/94.jpg)
grpc_cli
Rpc succeeded with OK status Response: routes: <...> routes: <...> routes: <...> routes: <...>
![Page 95: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/95.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 96: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/96.jpg)
Service definition - response streaming
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (stream GetRoutesResponse) {} }
![Page 97: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/97.jpg)
Service definition
service RoutePlanner { rpc GetRoutes (GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 98: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/98.jpg)
Service definition - request streaming
service RoutePlanner { rpc GetRoutes (stream GetRoutesRequest) returns (GetRoutesResponse) {} }
![Page 99: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/99.jpg)
Request streaming? Response streaming?
![Page 100: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/100.jpg)
Request streaming? Response streaming?
![Page 101: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/101.jpg)
Service definition - bidirectional streaming
service RoutePlanner { rpc GetRoutes (stream GetRoutesRequest) returns (stream GetRoutesResponse) {} }
![Page 102: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/102.jpg)
Keep in mind…
Things will go wrong
![Page 103: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/103.jpg)
Timeouts
Client Service B
A
C
D
E
? ms ? ms
? ms
? ms
? ms
? ms
![Page 104: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/104.jpg)
Uniform timeout
Client Service A B
![Page 105: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/105.jpg)
Uniform timeout
Client Service A B
500 ms timeout 500 ms timeout 500 ms timeout
![Page 106: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/106.jpg)
Uniform timeout
Client Service A
20 ms
B
500 ms timeout 500 ms timeout 500 ms timeout
![Page 107: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/107.jpg)
Uniform timeout
Client Service A
20 ms 30 ms
B
500 ms timeout 500 ms timeout 500 ms timeout
![Page 108: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/108.jpg)
Uniform timeout
Client Service A
20 ms 30 ms
B
40 ms
500 ms timeout 500 ms timeout 500 ms timeout
![Page 109: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/109.jpg)
Uniform timeout
Client Service A
20 ms 30 ms
B
40 ms
420 ms
500 ms timeout 500 ms timeout 500 ms timeout
![Page 110: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/110.jpg)
Uniform timeout
Client Service A
20 ms 30 ms
B
40 ms
420 ms
500 ms timeout 500 ms timeout 500 ms timeout
X
![Page 111: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/111.jpg)
Uniform timeout
Client Service A
20 ms 30 ms
B
40 ms
20 ms 420 ms
500 ms timeout 500 ms timeout 500 ms timeout
X X
![Page 112: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/112.jpg)
Fine-tuned timeout
Client Service A B
![Page 113: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/113.jpg)
Fine-tuned timeout
Client Service A B
300 ms timeout 280 ms timeout 50 ms timeout
![Page 114: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/114.jpg)
Fine-tuned timeout
Client Service A
20 ms
B
300 ms timeout 280 ms timeout 50 ms timeout
![Page 115: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/115.jpg)
Fine-tuned timeout
Client Service A
20 ms 30 ms
B
300 ms timeout 280 ms timeout 50 ms timeout
![Page 116: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/116.jpg)
Fine-tuned timeout
Client Service A
20 ms 30 ms
B
15 ms
300 ms timeout 280 ms timeout 50 ms timeout
![Page 117: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/117.jpg)
Fine-tuned timeout
Client Service A
20 ms 30 ms
B
15 ms
40 ms
300 ms timeout 280 ms timeout 50 ms timeout
![Page 118: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/118.jpg)
Fine-tuned timeout
Client Service A
20 ms 30 ms
B
15 ms
40 ms
300 ms timeout 280 ms timeout 50 ms timeout
X
![Page 119: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/119.jpg)
Adaptive timeout
Client Service A B
![Page 120: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/120.jpg)
Adaptive timeout
Client Service A B
200 ms timeout
![Page 121: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/121.jpg)
Adaptive timeout
Client Service A
20 ms
B
200 ms timeout
![Page 122: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/122.jpg)
Adaptive timeout
Client Service A
20 ms
B
200 ms timeout 200ms - 20ms = 180 ms
![Page 123: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/123.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
200 ms timeout 200ms - 20ms = 180 ms
![Page 124: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/124.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
200 ms timeout 200ms - 20ms = 180 ms
180ms - 30ms = 150ms
![Page 125: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/125.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
15 ms
200 ms timeout 200ms - 20ms = 180 ms
180ms - 30ms = 150ms
![Page 126: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/126.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
15 ms
40 ms
200 ms timeout 200ms - 20ms = 180 ms
180ms - 30ms = 150ms
![Page 127: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/127.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
15 ms
20 ms 40 ms
200 ms timeout 200ms - 20ms = 180 ms
180ms - 30ms = 150ms
![Page 128: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/128.jpg)
Adaptive timeout
Client Service A
20 ms 30 ms
B
15 ms
40 ms 20 ms 40 ms
200 ms timeout 200ms - 20ms = 180 ms
180ms - 30ms = 150ms
![Page 129: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/129.jpg)
gRPC: Deadlines
![Page 130: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/130.jpg)
gRPC: Deadlines
–Timeout is relative
![Page 131: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/131.jpg)
gRPC: Deadlines
–Timeout is relative
–Deadline is absolute
![Page 132: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/132.jpg)
Deadline propagation
Client Service A B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
![Page 133: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/133.jpg)
Deadline propagation
Client Service A B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600000
![Page 134: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/134.jpg)
Deadline propagation
Client Service A
20 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600000
![Page 135: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/135.jpg)
Deadline propagation
Client Service A
20 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020TS: 3600000
![Page 136: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/136.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020TS: 3600000
![Page 137: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/137.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050TS: 3600000
![Page 138: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/138.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050TS: 3600000
![Page 139: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/139.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045TS: 3600000
![Page 140: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/140.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045TS: 3600000
![Page 141: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/141.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045
TS: 3600085
TS: 3600000
![Page 142: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/142.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
20 ms 40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045
TS: 3600085
TS: 3600000
![Page 143: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/143.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
20 ms 40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045
TS: 3600105 TS: 3600085
TS: 3600000
![Page 144: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/144.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
40 ms 20 ms 40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045
TS: 3600105 TS: 3600085
TS: 3600000
![Page 145: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/145.jpg)
Deadline propagation
Client Service A
20 ms 30 ms
B
15 ms
40 ms 20 ms 40 ms
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600020 TS: 3600050 TS: 3600045
TS: 3600105 TS: 3600085TS: 3600145
TS: 3600000
![Page 146: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/146.jpg)
Deadline propagation
Client Service A B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
![Page 147: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/147.jpg)
Deadline propagation
Client Service A B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600000
![Page 148: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/148.jpg)
Deadline propagation
Client Service A
150ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600000
![Page 149: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/149.jpg)
Deadline propagation
Client Service A
150ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150TS: 3600000
![Page 150: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/150.jpg)
Deadline propagation
Client Service A
150ms 100 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150TS: 3600000
![Page 151: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/151.jpg)
Deadline propagation
Client Service A
150ms 100 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150 TS: 3600250TS: 3600000
![Page 152: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/152.jpg)
Deadline propagation
Client Service A
150ms 100 ms
B
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150 TS: 3600250TS: 3600000
X
![Page 153: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/153.jpg)
Deadline propagation
Client Service A
150ms 100 ms
B
DEADLINE_EXCEEDED
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150 TS: 3600250TS: 3600000
X
![Page 154: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/154.jpg)
Deadline propagation
Client Service A
150ms 100 ms
B
DEADLINE_EXCEEDED DEADLINE_EXCEEDED
Start TS: 3600000 Timeout: 200 Deadline: 3600200
TS: 3600150 TS: 3600250TS: 3600000
X
![Page 155: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/155.jpg)
Cancellation
![Page 156: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/156.jpg)
Cancellation
–Can be initiated by both client/server
![Page 157: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/157.jpg)
Cancellation
–Can be initiated by both client/server
– Immediately terminates the RPC
![Page 158: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/158.jpg)
Cancellation
–Can be initiated by both client/server
– Immediately terminates the RPC
– It is not a roll-back
![Page 159: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/159.jpg)
Cancellation
–Can be initiated by both client/server
– Immediately terminates the RPC
– It is not a roll-back
–Automatically cascaded
![Page 160: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/160.jpg)
Backward compatibility
https://github.com/grpc-ecosystem/grpc-gateway
![Page 161: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/161.jpg)
gRPC language support
–C++
–Python
–Java
–Go
–Ruby
–C#
–JS (Node)
–Android Java
–Objective-C
–PHP
![Page 162: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/162.jpg)
gRPC Platform support
–Linux
–macOS
–Windows
–Android
– iOS
![Page 163: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/163.jpg)
Success stories
![Page 164: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/164.jpg)
Success stories
![Page 165: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/165.jpg)
Benefits
![Page 166: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/166.jpg)
Benefits–Focus on the API design & contract
![Page 167: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/167.jpg)
Benefits–Focus on the API design & contract
–HTTP2 is awesome
![Page 168: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/168.jpg)
Benefits–Focus on the API design & contract
–HTTP2 is awesome
–Bi-directional streaming
![Page 169: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/169.jpg)
Benefits–Focus on the API design & contract
–HTTP2 is awesome
–Bi-directional streaming
–Freedom to pick any language
![Page 170: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/170.jpg)
Benefits–Focus on the API design & contract
–HTTP2 is awesome
–Bi-directional streaming
–Freedom to pick any language
–Service-to-Service and Service-to-Mobile friendly
![Page 171: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/171.jpg)
Benefits–Focus on the API design & contract
–HTTP2 is awesome
–Bi-directional streaming
–Freedom to pick any language
–Service-to-Service and Service-to-Mobile friendly
–Production ready
![Page 172: Teach your (micro)services speak Protocol Buffers with gRPC.€¦ · Teach your (micro)services speak Protocol Buffers with gRPC. Mihai Iachimovschi @mishunika mihai.iachimovschi@gmail.com](https://reader030.vdocuments.us/reader030/viewer/2022040214/5ec98876cd21621731505b6d/html5/thumbnails/172.jpg)
Fin.
Thank you.