Slide 1

Slide 1 text

http://s3wf.com @jeffotoni Meetup Golang Campinas Jefferson Otoni RPC, gRPC & Go

Slide 2

Slide 2 text

Senior Software Engineer Jefferson Otoni Lima

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

@jeffotoni Comunidade Telegram https://t.me/go_br https://t.me/go_bh https://t.me/golangcwb Slack https://gophers.slack.com (members >~45k) GopherCon Brasil 2020 https://2020.gopherconbr.org Wiki Conferencias https://github.com/golang/go/wiki/Conferences Meetup https://www.meetup.com/go-belo-horizonte https://www.meetup.com/pt-BR/golangbr https://www.meetup.com/pt-BR/Women-Who-Go-Sampa https://www.meetup.com/pt-BR/Golang-Campinas/ https://www.meetup.com/pt-BR/golang-poa/ https://www.meetup.com/pt-BR/GolangCWB/

Slide 5

Slide 5 text

@jeffotoni https://golang.org https://golang.org/doc/effective_go.html https://golang.org/ref/spec https://golang.org/doc https://tour.golang.org/welcome/1

Slide 6

Slide 6 text

@jeffotoni WEB Protocolos

Slide 7

Slide 7 text

@jeffotoni HTTP/1.1 TCP TCP UDP protocolos HTTP/2.0 SPDY HTTP/3 QUIC SPDY QUIC

Slide 8

Slide 8 text

@jeffotoni HTTP Versões HTTP/0.9 1991; one method HTTP/1.0 1996; headers, caching, languages HTTP/1.1 1999; keepalives, upgrades, ranges, hosts SPDY 2009; one tcp, gzip headers, flow control QUIC 2012; UDP, handshake, baixa latência HTTP/2.0 2015; HPACK, priorities, server push HTTP/3.0 2019; no head-of-line blocking,TLS 1.3

Slide 9

Slide 9 text

@jeffotoni HTTP/3.0 Um bolo de camada HTTP / 3 Fonte: https://blog.cloudflare.com/http-3-from-root-to-tip/

Slide 10

Slide 10 text

@jeffotoni HTTP/2.0 . Multiplexing . Bidirectional Streaming . HTTPS . SSL/TLS . Token auth . Channel credentials . Performance

Slide 11

Slide 11 text

@jeffotoni HTTP/3.0 HTTP/2 vs HTTP/3 Fonte: https://kinsta.com/pt/blog/http3

Slide 12

Slide 12 text

@jeffotoni

Slide 13

Slide 13 text

HTTP/2.0 $ curl -I -L https://app.guula.com.br HTTP/2 200 server: nginx/1.14.0 (Ubuntu) date: Wed, 22 Jul 2020 17:33:15 GMT content-type: text/html; charset=utf-8 vary: Origin @jeffotoni

Slide 14

Slide 14 text

HTTP/2.0 @jeffotoni

Slide 15

Slide 15 text

@jeffotoni

Slide 16

Slide 16 text

@jeffotoni HTTP/3.0

Slide 17

Slide 17 text

HTTP/3.0

Slide 18

Slide 18 text

Back-end

Slide 19

Slide 19 text

serviços/protocolos @jeffotoni RPC TCP/UDP/http REST http SOAP http xml-RPC http RMI tcp Representational State Transfer Remote Procedure Call Simple Object Access Protocol Remote Method Invocation webSocket http/tcp comunicação bidirecional por canais full-duplex e usa o schema: ws:// ou wss://

Slide 20

Slide 20 text

(Representational State Transfer) rEST

Slide 21

Slide 21 text

/auth POST /user GET /user/{uuid} GET /user/{uuid} DELETE /user/{uuid} PUT 1M requests/s 50k requests/s 100k requests/s 60k requests/s 1k requests/s service 1 service 2 service 3 service 4 service 5

Slide 22

Slide 22 text

@jeffotoni Api rEST em Go - Endpoints - Middleware - Instrumentar - Dockerfile - Deploy

Slide 23

Slide 23 text

Serializion

Slide 24

Slide 24 text

. encoding/json . encoding/xml . github.com/tinylib/msgp . github.com/golang/protobuf . github.com/gogo/protobuf . Apache/Thrift . Apache/Avro . gotiny . vmihailenco/msgpack/v4 Alguns tipos de serializações

Slide 25

Slide 25 text

Serializion MessagePack

Slide 26

Slide 26 text

@jeffotoni Api rEST em Go - Endpoints - Middleware - Instrumentar - Dockerfile - Deploy

Slide 27

Slide 27 text

/user/{uuid} GET /user/{uuid} PUT 100k requests/s 1k requests/s service 3 service 5 HTTP + JSON

Slide 28

Slide 28 text

service3 service5 HTTP rEST rEST CLIENT

Slide 29

Slide 29 text

RPC (Remote Procedure Call) procedimentos remotos como se fossem chamadas locais

Slide 30

Slide 30 text

(Remote Procedure Call) RPC server

Slide 31

Slide 31 text

/user/{uuid} GET /user/{uuid} PUT 100k requests/s 1k requests/s service 3 service 5 RPC RPC SERVER RPC CLIENT

Slide 32

Slide 32 text

RPC server Go - Struct Args - Struct User - Metodo Get @jeffotoni

Slide 33

Slide 33 text

RPC server Go - Register - Metodos - Instrumentar - Dockerfile - Deploy @jeffotoni

Slide 34

Slide 34 text

RPC server Go - Register - Metodos - Instrumentar @jeffotoni

Slide 35

Slide 35 text

(Remote Procedure Call) RPC client

Slide 36

Slide 36 text

RPC client Go - Conexao - Args/param - Reply/Retorno - Dockerfile - Deploy @jeffotoni

Slide 37

Slide 37 text

Service3 Service5 TCP RPC RPC SERVER HTTP rEST RPC CLIENT

Slide 38

Slide 38 text

nível de modularidade microservice

Slide 39

Slide 39 text

No content

Slide 40

Slide 40 text

gRPC

Slide 41

Slide 41 text

Protocol Buffers protobuf-compiler

Slide 42

Slide 42 text

Protocol Buffers $ protoc --go_out=. produto.proto

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

Metodos

Slide 45

Slide 45 text

Go Marshal

Slide 46

Slide 46 text

Go Unmarshal

Slide 47

Slide 47 text

/user/{uuid} GET /user/{uuid} PUT 100k requests/s 1k requests/s service 3 service 5 gRPC gRPC SERVER gRPC CLIENT

Slide 48

Slide 48 text

referências https://jobs.kenoby.com/engineering https://golang.org https://grpc.io/docs/tutorials/basic/go https://github.com/grpc/grpc-go/tree/master/examples https://developers.google.com/protocol-buffers/docs/gotutorial https://github.com/uw-labs/bloomrpc (curl ou posltman para grpc) https://itnext.io/learning-go-mongodb-crud-with-grpc-98e425aeaae6 https://encurtador.com.br/fHKSU https://encurtador.com.br/eqvJ2 https://gokit.io/examples/ https://github.com/smallnest/gosercomp https://easyengine.io/tutorials/nginx/configuring-http-2-server-push https://www.digitalocean.com/community/tutorials/http-1-1-vs-http-2-what-s-the-difference https://medium.com/@factoryhr/http-2-the-difference-between-http-1-1-benefits-and-how-to-use-it-38094fa0e95b https://blog.cloudflare.com/how-to-test-http-3-and-quic-with-firefox-nightly/ https://blog.cloudflare.com/http-3-vs-http-2 https://kinsta.com/blog/http3 https://blog.cloudflare.com/http3-the-past-present-and-future links

Slide 49

Slide 49 text

Thanks := &Obrigado{...} Obrigado... github.com/jeffotoni instagram.com/jeffotoni https://t.me/devopsbh https://t.me/go_br https://t.me/awsbrasil linkedin.com/in/jeffotoni/