SlideShare a Scribd company logo
Protocol Buffers Overview
Fabrício Epaminondas - @fabricioepa
Senior Software Engineer, Signove
About me
BSc in Computer Science at
Federal University of Campina
Grande, UFCG.
Recent activities
• Implementation of IEEE Data
Exchange Protocol 11073 part 20601
• Data modeling for Bluetooth services
• Data synchronization using REST
services
Agenda
Background
What are Protocol Buffers?
How do they work?
Why use Protocol Buffers?
Techniques
Questions
Quick Links
Background
Data Formats in
Information Technology
• Typing/interpretation,
transmission, storage
Popular data formats...
CSV
• Simple to read/write by
application
• Tabular data structure
• Flat
• No validation
Name, Age, Phone
Fabricio, 26, +558388000000
Kaka, 28, +558388000001
Cafu, 40, +558388000002
Pele, 70, +558388000003
XML
• Markup language for
Documents
• Hierarchical structure
• Data validation
• A common standard with
great acceptance
<person>
<name>Fabricio</name>
<age>26</age>
<contacts>
<email>
my@email.com
</email>
<phone>999</phone>
</contacts>
</person>
JSON
• Lightweight data-
interchange format
• Browser support
• Alternative to XML
person {
name: “Fabricio”
age: 26
contacts: {
email: “my@email.com”
phone: “999”
}
}
Comparison
CSV
XML
JSON
Parsing
efficiency
Reusable
Model
Update
Hierarchical Small Size
Google's Data Interchange
Requirements
We use literally thousands of
different data formats to represent:
• networked messages between servers
• index records in repositories
• geospatial datasets
Most of these formats are
structured, not flat. This raises an
important question…
How do we encode it all?
Requirements:
Hierarchical data structure
Small data size
Parsing performance
Model update: add/ignore fields,
modify parser code...
Backwards compatible
What are Protocol Buffers?
A language-neutral, platform-neutral,
extensible way of serializing structured data
for use in communications protocols, data
storage, and more.
It was initially developed at Google to deal
with an index server request/response
protocol
How do they work?
You define how your structured data
format is a descriptor file
Generated source code to easily write and
read your structured data to and from a
variety of data streams and using a variety
of languages.
You can even update your data structure
without breaking deployed programs that
are compiled against the "old" format.
Writing some code…
.proto C++
message Person {
required string name = 1;
required int32 id = 2;
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
required string number = 1;
optional PhoneType type = 2 [default =
HOME];
}
repeated PhoneNumber phone = 4;
}
Person person;
person.set_name("John Doe");
person.set_id(1234);
person.set_email("jdoe@example.com");
fstream output("myfile", ios::out | ios::binary);
//Write
person.SerializeToOstream(&output);
//Read
fstream input("myfile", ios::in | ios::binary);
Person person;
person.ParseFromIstream(&input);
cout << "Name: " << person.name() << endl;
cout << "E-mail: " << person.email() << endl;
Generated code
Messages
• Immutable
Builders
Enums and Nested Classes
• C++: Person:: Mobile
• Java: Person.PhoneType.MOBILE
Parsing and Serialization
Why use Protocol Buffers?
Protocol Buffers’ major design
goals is simplicity
Protocol buffers are the
flexible, efficient
PB are 3 to 10 times smaller
than XML
PB are 20 to 100 times faster
than XML
Comparison
CSV
XML
JSON
PB
Parsing
efficiency
Reusable
Model
Update
Hierarchical Small Size
Why use Protocol Buffers?
Use object serialization
(like in Java) causes
interoperability problems.
In C/C++ the raw in-
memory data structures
can be sent/saved in binary
form, but is hard to extend.
Alternatives
Thrift
ASN1
Java Externalizable
Others IDL...
• WSDL, XSD, XML
• CORBA, Java-IDL, etc…
Techniques
Backward/Forward
compatibility
Updating Message
Types
O-O Design
Backward/Forward compatibility
You must not change the tag numbers of any
existing fields.
You must not add or delete any required fields.
Consider writing application-specific custom
validation routines instead of required fields
You may delete optional or repeated fields.
You may add new optional or repeated fields but
you must use fresh tag numbers…
(i.e. tag numbers that were never used in this
protocol buffer, not even by deleted fields).
Backward/Forward compatibility
Old code will simply ignore new fields, for deleted fields it
will read default values
Unknown fields are not discarded, and if the message is
later serialized, the unknown fields are serialized along
with it
Changing a default value is generally OK, but remember
default values are never sent over the wire
Receiver will NOT see the default value that was defined
in the sender's code.
New code will also transparently read old messages
Updating Message Types
Don't change the numeric tags for any existing fields.
Despite of non-required fields can be removed, it’s better
to rename the field instead to something like
“DEPRECATED_...”
int32, uint32, int64, uint64, and bool are all compatible.
It does not breaks forwards- or backwards-compatibility.
string and bytes are compatible as long as the bytes are
valid UTF-8.
More issues in protobuf manual
O-O Design
Generated source code of
message objects should not be
modified
Use wrappers to encapsulate
messages
Do not inherit from message
objects
Questions…
Protocol buffers
Quick Links
• API
▫ http://code.google.com/apis/protocolbuffers/
• Post By Kenton Varda, Protocol Buffers Team
▫ http://google-opensource.blogspot.com/2008/07/protocol-buffers-googles-data.html
• Kevin Weil, Analytics Lead, Twitter
▫ http://www.slideshare.net/kevinweil/protocol-buffers-and-hadoop-at-twitter
• Benchmarks
▫ http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking
• Computer World Article
▫ http://www.computerworld.com/s/article/9191098/Twitter_solves_its_data
_formatting_challenge

More Related Content

ODP
Https presentation
PPTX
Protocol Buffers
PPTX
Protocol Buffer.ppt
PPTX
Socket Programming
PPTX
Hypertext transfer protocol and hypertext transfer protocol secure(HTTP and H...
PPSX
HTTP Presentation
PPTX
JSON: The Basics
PPT
Socket programming
Https presentation
Protocol Buffers
Protocol Buffer.ppt
Socket Programming
Hypertext transfer protocol and hypertext transfer protocol secure(HTTP and H...
HTTP Presentation
JSON: The Basics
Socket programming

What's hot (20)

PPTX
Simple mail transfer protocol (smtp)
PDF
HTTP Definition and Basics.
PPTX
PDF
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
PPTX
Http protocol
PPTX
Ipv4 & ipv6
PPTX
Ipv4 header
PPTX
PPTX
Web services SOAP
PPTX
PPTX
Tcp presentation
PPT
Wireshark
PDF
ICE: The ultimate way of beating NAT in SIP
PPTX
Imap(internet massege access protocaols)
PPTX
File Transfer Protocol - FTP
PDF
TCP Vs UDP
PPTX
Osi model vs TCP/IP
PPTX
PDF
IPv6 Transition & Deployment, including IPv6-only in cellular and broadband
PPT
Arp spoofing
Simple mail transfer protocol (smtp)
HTTP Definition and Basics.
HTTP by Hand: Exploring HTTP/1.0, 1.1 and 2.0
Http protocol
Ipv4 & ipv6
Ipv4 header
Web services SOAP
Tcp presentation
Wireshark
ICE: The ultimate way of beating NAT in SIP
Imap(internet massege access protocaols)
File Transfer Protocol - FTP
TCP Vs UDP
Osi model vs TCP/IP
IPv6 Transition & Deployment, including IPv6-only in cellular and broadband
Arp spoofing
Ad

Viewers also liked (20)

PDF
Data Serialization Using Google Protocol Buffers
PPTX
Google Protocol Buffers
PDF
Introduction to protocol buffer
PDF
3 apache-avro
PDF
Quickstart for continuous integration
PDF
Introduction to developing modern web apps
PDF
Continuous integration practices to improve the software quality
PDF
Experience protocol buffer on android
PDF
Designing Scalable Applications
PDF
An Empirical Evaluation of VoIP Playout Buffer Dimensioning in Skype, Google ...
PDF
Continuous testing in agile projects 2015
PDF
Illustration of TextSecure's Protocol Buffer usage
PDF
Axolotl Protocol: An Illustrated Primer
PDF
Info Card - Techical Debt Management
PDF
Understanding Web services
PDF
Workshop Guide: RESTful Java Web Application with Spring Boot
PDF
Hexagonal architecture for java applications
PPTX
Thrift vs Protocol Buffers vs Avro - Biased Comparison
PDF
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
KEY
Hadoop, Pig, and Twitter (NoSQL East 2009)
Data Serialization Using Google Protocol Buffers
Google Protocol Buffers
Introduction to protocol buffer
3 apache-avro
Quickstart for continuous integration
Introduction to developing modern web apps
Continuous integration practices to improve the software quality
Experience protocol buffer on android
Designing Scalable Applications
An Empirical Evaluation of VoIP Playout Buffer Dimensioning in Skype, Google ...
Continuous testing in agile projects 2015
Illustration of TextSecure's Protocol Buffer usage
Axolotl Protocol: An Illustrated Primer
Info Card - Techical Debt Management
Understanding Web services
Workshop Guide: RESTful Java Web Application with Spring Boot
Hexagonal architecture for java applications
Thrift vs Protocol Buffers vs Avro - Biased Comparison
Four Things to Know About Reliable Spark Streaming with Typesafe and Databricks
Hadoop, Pig, and Twitter (NoSQL East 2009)
Ad

Similar to Protocol buffers (20)

PPTX
Golang proto buff_ixxo
ODP
Protocol Buffers
PPTX
Protocol buffers
PPTX
Data Encoding in Remote Procedure calls.
PDF
Maxim Zaks: Deep dive into data serialisation
PPTX
Data Engineering with Protobuf
PDF
Protocol buffers and Microservices
PDF
Yevhen Beshkarov “IPC with Protobuf»
PDF
Teach your (micro)services talk Protocol Buffers with gRPC.
PPT
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
PDF
Rest style web services (google protocol buffers) prasad nirantar
PDF
Apache big data 2016 - Speaking the language of Big Data
PDF
Building a maintainable bi-directional cross platform protocol
PDF
Beyond JSON @ Mobile.Warsaw
PDF
Addressing the data challenge in IIoT system evolution with Protocol Buffers
PDF
Beyond JSON with FlatBuffers
PPS
Advance Java
PPTX
Message passing Programing and MPI.
DOCX
20090814102834_嵌入式C与C++语言精华文章集锦.docx
PPTX
Reversing Google Protobuf protocol
Golang proto buff_ixxo
Protocol Buffers
Protocol buffers
Data Encoding in Remote Procedure calls.
Maxim Zaks: Deep dive into data serialisation
Data Engineering with Protobuf
Protocol buffers and Microservices
Yevhen Beshkarov “IPC with Protobuf»
Teach your (micro)services talk Protocol Buffers with gRPC.
JavaOne 2009 - TS-5276 - RESTful Protocol Buffers
Rest style web services (google protocol buffers) prasad nirantar
Apache big data 2016 - Speaking the language of Big Data
Building a maintainable bi-directional cross platform protocol
Beyond JSON @ Mobile.Warsaw
Addressing the data challenge in IIoT system evolution with Protocol Buffers
Beyond JSON with FlatBuffers
Advance Java
Message passing Programing and MPI.
20090814102834_嵌入式C与C++语言精华文章集锦.docx
Reversing Google Protobuf protocol

Recently uploaded (20)

PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PPTX
Computer Software and OS of computer science of grade 11.pptx
PPTX
history of c programming in notes for students .pptx
PDF
Cost to Outsource Software Development in 2025
PPTX
Operating system designcfffgfgggggggvggggggggg
PPTX
Why Generative AI is the Future of Content, Code & Creativity?
PDF
Understanding Forklifts - TECH EHS Solution
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
CHAPTER 2 - PM Management and IT Context
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Introduction to Artificial Intelligence
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Nekopoi APK 2025 free lastest update
PDF
Digital Strategies for Manufacturing Companies
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Upgrade and Innovation Strategies for SAP ERP Customers
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Navsoft: AI-Powered Business Solutions & Custom Software Development
Computer Software and OS of computer science of grade 11.pptx
history of c programming in notes for students .pptx
Cost to Outsource Software Development in 2025
Operating system designcfffgfgggggggvggggggggg
Why Generative AI is the Future of Content, Code & Creativity?
Understanding Forklifts - TECH EHS Solution
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
CHAPTER 2 - PM Management and IT Context
Reimagine Home Health with the Power of Agentic AI​
Odoo Companies in India – Driving Business Transformation.pdf
Introduction to Artificial Intelligence
Wondershare Filmora 15 Crack With Activation Key [2025
wealthsignaloriginal-com-DS-text-... (1).pdf
Nekopoi APK 2025 free lastest update
Digital Strategies for Manufacturing Companies
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf

Protocol buffers

  • 1. Protocol Buffers Overview Fabrício Epaminondas - @fabricioepa Senior Software Engineer, Signove
  • 2. About me BSc in Computer Science at Federal University of Campina Grande, UFCG. Recent activities • Implementation of IEEE Data Exchange Protocol 11073 part 20601 • Data modeling for Bluetooth services • Data synchronization using REST services
  • 3. Agenda Background What are Protocol Buffers? How do they work? Why use Protocol Buffers? Techniques Questions Quick Links
  • 4. Background Data Formats in Information Technology • Typing/interpretation, transmission, storage Popular data formats...
  • 5. CSV • Simple to read/write by application • Tabular data structure • Flat • No validation Name, Age, Phone Fabricio, 26, +558388000000 Kaka, 28, +558388000001 Cafu, 40, +558388000002 Pele, 70, +558388000003
  • 6. XML • Markup language for Documents • Hierarchical structure • Data validation • A common standard with great acceptance <person> <name>Fabricio</name> <age>26</age> <contacts> <email> my@email.com </email> <phone>999</phone> </contacts> </person>
  • 7. JSON • Lightweight data- interchange format • Browser support • Alternative to XML person { name: “Fabricio” age: 26 contacts: { email: “my@email.com” phone: “999” } }
  • 9. Google's Data Interchange Requirements We use literally thousands of different data formats to represent: • networked messages between servers • index records in repositories • geospatial datasets Most of these formats are structured, not flat. This raises an important question…
  • 10. How do we encode it all? Requirements: Hierarchical data structure Small data size Parsing performance Model update: add/ignore fields, modify parser code... Backwards compatible
  • 11. What are Protocol Buffers? A language-neutral, platform-neutral, extensible way of serializing structured data for use in communications protocols, data storage, and more. It was initially developed at Google to deal with an index server request/response protocol
  • 12. How do they work? You define how your structured data format is a descriptor file Generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages. You can even update your data structure without breaking deployed programs that are compiled against the "old" format.
  • 13. Writing some code… .proto C++ message Person { required string name = 1; required int32 id = 2; optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { required string number = 1; optional PhoneType type = 2 [default = HOME]; } repeated PhoneNumber phone = 4; } Person person; person.set_name("John Doe"); person.set_id(1234); person.set_email("jdoe@example.com"); fstream output("myfile", ios::out | ios::binary); //Write person.SerializeToOstream(&output); //Read fstream input("myfile", ios::in | ios::binary); Person person; person.ParseFromIstream(&input); cout << "Name: " << person.name() << endl; cout << "E-mail: " << person.email() << endl;
  • 14. Generated code Messages • Immutable Builders Enums and Nested Classes • C++: Person:: Mobile • Java: Person.PhoneType.MOBILE Parsing and Serialization
  • 15. Why use Protocol Buffers? Protocol Buffers’ major design goals is simplicity Protocol buffers are the flexible, efficient PB are 3 to 10 times smaller than XML PB are 20 to 100 times faster than XML
  • 17. Why use Protocol Buffers? Use object serialization (like in Java) causes interoperability problems. In C/C++ the raw in- memory data structures can be sent/saved in binary form, but is hard to extend.
  • 18. Alternatives Thrift ASN1 Java Externalizable Others IDL... • WSDL, XSD, XML • CORBA, Java-IDL, etc…
  • 20. Backward/Forward compatibility You must not change the tag numbers of any existing fields. You must not add or delete any required fields. Consider writing application-specific custom validation routines instead of required fields You may delete optional or repeated fields. You may add new optional or repeated fields but you must use fresh tag numbers… (i.e. tag numbers that were never used in this protocol buffer, not even by deleted fields).
  • 21. Backward/Forward compatibility Old code will simply ignore new fields, for deleted fields it will read default values Unknown fields are not discarded, and if the message is later serialized, the unknown fields are serialized along with it Changing a default value is generally OK, but remember default values are never sent over the wire Receiver will NOT see the default value that was defined in the sender's code. New code will also transparently read old messages
  • 22. Updating Message Types Don't change the numeric tags for any existing fields. Despite of non-required fields can be removed, it’s better to rename the field instead to something like “DEPRECATED_...” int32, uint32, int64, uint64, and bool are all compatible. It does not breaks forwards- or backwards-compatibility. string and bytes are compatible as long as the bytes are valid UTF-8. More issues in protobuf manual
  • 23. O-O Design Generated source code of message objects should not be modified Use wrappers to encapsulate messages Do not inherit from message objects
  • 26. Quick Links • API ▫ http://code.google.com/apis/protocolbuffers/ • Post By Kenton Varda, Protocol Buffers Team ▫ http://google-opensource.blogspot.com/2008/07/protocol-buffers-googles-data.html • Kevin Weil, Analytics Lead, Twitter ▫ http://www.slideshare.net/kevinweil/protocol-buffers-and-hadoop-at-twitter • Benchmarks ▫ http://code.google.com/p/thrift-protobuf-compare/wiki/Benchmarking • Computer World Article ▫ http://www.computerworld.com/s/article/9191098/Twitter_solves_its_data _formatting_challenge