🍋
Menu
.protobuf Data

Protocol Buffers(Protobuf)

Protocol Buffers 是 Google 的语言无关结构化数据序列化格式。它比 JSONXML 更紧凑、更快速,使用模式定义(.proto 文件)在数十种编程语言中生成类型安全的代码。

MIME 类型

application/x-protobuf

类型

二进制

压缩

无损

优点

  • + 10-100x smaller and faster than JSON/XML
  • + Schema-driven with generated type-safe code
  • + Backward-compatible schema evolution via field numbers
  • + Standard wire format for gRPC

缺点

  • Not human-readable — binary format requires tooling
  • Requires .proto schema definition and code generation step
  • Not suitable for human-edited configuration files

何时使用 .PROTOBUF

gRPC 服务、内部微服务通信以及任何需要快速、紧凑、模式驱动序列化的系统中使用 Protobuf。

技术细节

Protobuf 使用带编号字段的 .proto 模式,编译为特定语言的代码。二进制传输格式对整数使用变长编码,对字符串和嵌套消息使用长度前缀编码。

历史

Google 在内部开发了 Protocol Buffers,并于 2008 年开源。Proto2 添加了可选字段,Proto3(2016)通过默认值简化了语言。gRPC 使用 Protobuf 作为默认的传输格式。

从 .PROTOBUF 转换

转换为 .PROTOBUF

相关格式

相关术语