Boosting Python Web Apps with Protocol Buffers & GRPC Naren Arya @Citrix R&D
Whoami ● Software Engineer 2 working @ Citrix R&D ● Blogger @IMpythonist & Medium ● Pythonista, Gopher and Open Source Lover A programmer with 4 eyes since 4th class
Why JSON is good? JSON is good because ● It is simple ● It is well accepted ● People cannot bear with XML ● REST popularity
Why JSON is dying ? JSON is dying because it is not better than Protocol Buffers!
What are protocol buffers? Just a format which looks exactly like Go structs Protobuf Go struct syntax ‘proto3’; message Person { string name = 1; int32 age = 2; } type Person struct { Name string Age int32 }
What are benefits I get with Protobuf? ● Binary encoding => Less Size ● HTTP/2 compliant => Many Goodies like Header compression ● Strict typing for checking data format ● Platform independent(Hey! JSON does this too)
Steps for using Protobuf with Python - 1 We need to do few things before playing with Protobuf ● Install protoc compiler on any machine ● Run this command protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto
Steps for using Protobuf with Python - 2 ● Use the class file that generated ● Import respected classes in main program Important Methods SerializeToString(): serializes the message and returns it as a string. Note that the bytes are binary, not text; we only use the str type as a convenient container. ParseFromString(data): parses a message from the given string.
Nah nah, More things are kept for Final slide! Sneak Peek of upcoming slides: 1.Working with a real world example 2.Introducing GRPC 3.Building GRPC Servers and Clients in Python 4.Using Protobufs with GRPC to scale microservices 5.Everything is demonstrated with code! Wait and See until then! Bye

Boosting python web apps with protocol buffers & grpc

  • 1.
    Boosting Python Web Appswith Protocol Buffers & GRPC Naren Arya @Citrix R&D
  • 2.
    Whoami ● Software Engineer 2working @ Citrix R&D ● Blogger @IMpythonist & Medium ● Pythonista, Gopher and Open Source Lover A programmer with 4 eyes since 4th class
  • 3.
    Why JSON isgood? JSON is good because ● It is simple ● It is well accepted ● People cannot bear with XML ● REST popularity
  • 4.
    Why JSON isdying ? JSON is dying because it is not better than Protocol Buffers!
  • 5.
    What are protocolbuffers? Just a format which looks exactly like Go structs Protobuf Go struct syntax ‘proto3’; message Person { string name = 1; int32 age = 2; } type Person struct { Name string Age int32 }
  • 6.
    What are benefitsI get with Protobuf? ● Binary encoding => Less Size ● HTTP/2 compliant => Many Goodies like Header compression ● Strict typing for checking data format ● Platform independent(Hey! JSON does this too)
  • 7.
    Steps for usingProtobuf with Python - 1 We need to do few things before playing with Protobuf ● Install protoc compiler on any machine ● Run this command protoc -I=$SRC_DIR --python_out=$DST_DIR $SRC_DIR/addressbook.proto
  • 8.
    Steps for usingProtobuf with Python - 2 ● Use the class file that generated ● Import respected classes in main program Important Methods SerializeToString(): serializes the message and returns it as a string. Note that the bytes are binary, not text; we only use the str type as a convenient container. ParseFromString(data): parses a message from the given string.
  • 9.
    Nah nah, Morethings are kept for Final slide! Sneak Peek of upcoming slides: 1.Working with a real world example 2.Introducing GRPC 3.Building GRPC Servers and Clients in Python 4.Using Protobufs with GRPC to scale microservices 5.Everything is demonstrated with code! Wait and See until then! Bye