introducción a protocol buffers

24
PROTOCOL BUFFERS ENRIQUE ZAMUDIO @CHOCHOSMX

Upload: enrique-zamudio-lopez

Post on 15-Apr-2017

13 views

Category:

Software


2 download

TRANSCRIPT

Page 1: Introducción a Protocol Buffers

PROTOCOL BUFFERSENRIQUE ZAMUDIO

@CHOCHOSMX

Page 2: Introducción a Protocol Buffers

AL PRINCIPIO...TODO ERA BINARIO

Page 3: Introducción a Protocol Buffers

PROTOCOLOS BINARIOS

• Multitud de protocolos• RPC• COM, DCOM, CORBA, DDE, RMI

• Problemas de Codificación• Incompatibilidad entre plataformas

Page 4: Introducción a Protocol Buffers

HASTA QUE UN BUEN DÍA...

Page 5: Introducción a Protocol Buffers
Page 6: Introducción a Protocol Buffers

SOAP-RPC, PARA SER MÁS PRECISOS.

Page 7: Introducción a Protocol Buffers
Page 8: Introducción a Protocol Buffers

<?xml version="1.0" ?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><Request> <id>1234</id> <user>username</user> <password>password</password> <product>product</product> <amount>12.34</amount> <account>12345678</account> <date>2017-03-27T18:45:07.361-06:00</date></Request></S:Body></S:Envelope>

Page 9: Introducción a Protocol Buffers

• 315 bytes en total, sin espacios• 246 bytes de XML• 69 bytes de datos• 78% del mensaje es transporte

Page 10: Introducción a Protocol Buffers
Page 11: Introducción a Protocol Buffers

{ "id":1234, "user":"username", "password":"password", "product":"product", "amount":12.34, "account":"12345678", "date":1490112726145}

Page 12: Introducción a Protocol Buffers

• 128 bytes en total, sin espacios• 75 bytes de JSON• 53 bytes de datos• 58% del mensaje es transporte

Page 13: Introducción a Protocol Buffers
Page 14: Introducción a Protocol Buffers

Cliente ServidorPetición

Respuesta

HTTP es síncrono

Page 15: Introducción a Protocol Buffers

PROTOCOL BUFFERS

• Formato binario diseñado por Google• Compacto• Rápida codificación y decodificación• Multiplataforma• Independiente del esquema de comunicación• Tipado estático

Page 16: Introducción a Protocol Buffers

PROTOCOL BUFFERS

• Lenguaje para definir mensajes• Se compilan para la plataforma deseada

• Java, PHP, ObjC, C++, C#, JS, Ruby, Python• Incluye codificadores y parser

Page 17: Introducción a Protocol Buffers

message Peticion { int32 id = 1; string user = 2; string password = 3; string product = 4; float amount = 5; string account = 6; int64 date = 7;}

Page 18: Introducción a Protocol Buffers

08 d2 09 12 08 75 73 65 72 6e 61 6d 65 1a 08 70 61 73 73 77 6f 72 64 22 07 70 72 6f 64 75 63 74 2d a4 70 45 41 32 08 31 32 33 34 35 36 37 38 38 de 8b cf c3 af 2b

|.....username..p||assword".product||-.pEA2.123456788| |.....+|

Page 19: Introducción a Protocol Buffers

• 54 bytes en total• 45 bytes de datos• 9 bytes de protobuf• 17% del mensaje es transporte

Page 20: Introducción a Protocol Buffers
Page 21: Introducción a Protocol Buffers

• Clientes móviles pagan por datos• Nube/datacenter cobra por ancho de banda• Parsers usan CPU y RAM

• CPU y RAM tienen un costo en donde sea• Miles de clientes simultáneos

Page 22: Introducción a Protocol Buffers

LIVE DEMO!

Page 23: Introducción a Protocol Buffers

¿?

Page 24: Introducción a Protocol Buffers

github.com/chochos