Upgrade to Pro — share decks privately, control downloads, hide ads and more …

gRPC e Go um passo antes

gRPC e Go um passo antes

Esta apresentação tenta mostrar um pouco da história dos protocolos HTTP e como funciona sobre as camadas de TCP e UDP. Demostrando sua evolução até chegarmos no SPDY, QUIC e HTTP/3.
Fazemos um apanhando no rEST utilizando HTTP/1, HTTP/2 e finalmente mostramos o RPC utilizando TCP e UDP.
Agora aprender gRPC ficou mais fácil, depois de todo este embasamento demostramos o funcionamento do gRPC e como podemos tirar proveito de sua utilização.

Jefferson Otoni Lima

July 22, 2020
Tweet

More Decks by Jefferson Otoni Lima

Other Decks in Technology

Transcript

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

    View Slide

  2. Senior Software Engineer
    Jefferson Otoni Lima

    View Slide

  3. View Slide

  4. @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/

    View Slide

  5. @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

    View Slide

  6. @jeffotoni
    WEB
    Protocolos

    View Slide

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

    View Slide

  8. @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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  12. @jeffotoni

    View Slide

  13. 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

    View Slide

  14. HTTP/2.0
    @jeffotoni

    View Slide

  15. @jeffotoni

    View Slide

  16. @jeffotoni
    HTTP/3.0

    View Slide

  17. HTTP/3.0

    View Slide

  18. Back-end

    View Slide

  19. 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://

    View Slide

  20. (Representational State Transfer)
    rEST

    View Slide

  21. /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

    View Slide

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

    View Slide

  23. Serializion

    View Slide

  24. . 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

    View Slide

  25. Serializion
    MessagePack

    View Slide

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

    View Slide

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

    View Slide

  28. service3
    service5
    HTTP
    rEST
    rEST CLIENT

    View Slide

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

    View Slide

  30. (Remote Procedure Call)
    RPC server

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  34. RPC server Go
    - Register
    - Metodos
    - Instrumentar
    @jeffotoni

    View Slide

  35. (Remote Procedure Call)
    RPC client

    View Slide

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

    View Slide

  37. Service3
    Service5
    TCP
    RPC
    RPC SERVER
    HTTP
    rEST
    RPC CLIENT

    View Slide

  38. nível de modularidade
    microservice

    View Slide

  39. View Slide

  40. gRPC

    View Slide

  41. Protocol Buffers
    protobuf-compiler

    View Slide

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

    View Slide

  43. View Slide

  44. Metodos

    View Slide

  45. Go Marshal

    View Slide

  46. Go Unmarshal

    View Slide

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

    View Slide

  48. 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

    View Slide

  49. 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/

    View Slide