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

Oracle Cloud Hangout Cafe - サービス間通信のトレンド - gRPC & GraphQL入門 / ochacafe-grpc-graphql

Oracle Cloud Hangout Cafe - サービス間通信のトレンド - gRPC & GraphQL入門 / ochacafe-grpc-graphql

Oracle Cloud Hangout Cafe(おちゃかふぇ)のセッションスライドです。

(セッションの録画)
https://youtu.be/khwBXnUxDak

(イベントページ)
https://ochacafe.connpass.com/event/183721/

oracle4engineer

August 27, 2020
Tweet

More Decks by oracle4engineer

Other Decks in Technology

Transcript

  1. gRPC GraphQL
    Kyotaro Nonaka
    Solution Engineer
    Oracle Corporation Japan
    August 27th, 2020

    View full-size slide

  2. 以下の事項は、弊社の一般的な製品の方向性に関する概要を説明するものです。また、
    情報提供を唯一の目的とするものであり、いかなる契約にも組み込むことはできません。以
    下の事項は、マテリアルやコード、機能を提供することを確約するものではないため、購買
    決定を行う際の判断材料になさらないで下さい。
    オラクル製品に関して記載されている機能の開発、リリース、時期及び価格については、弊
    社の裁量により決定され、変更される可能性があります。
    Safe harbor statement
    Copyright © 2020, Oracle and/or its affiliates
    2

    View full-size slide

  3. Copyright © 2020, Oracle and/or its affiliates
    3

    View full-size slide

  4. gRPC GraphQL
    Copyright © 2020, Oracle and/or its affiliates
    4

    View full-size slide

  5. 5 Copyright © 2020, Oracle and/or its affiliates
    1.
    2. RESTful
    3. gRPC
    4. GraphQL

    View full-size slide



  6. • EC
    • OCHaCafe 3 3
    • 10
    • 20 FC 15

    Copyright © 2020, Oracle and/or its affiliates
    6
    @non_kyon

    View full-size slide

  7. Copyright © 2020, Oracle and/or its affiliates
    7
    REST API

    View full-size slide

  8. RESTful API REST 4 API




    Web

    • GET, POST HTTP
    • URL/URI
    API
    Copyright © 2020, Oracle and/or its affiliates
    8
    HTTP

    View full-size slide

  9. • URL/URI API
    • REST
    • HTTP

    Copyright © 2020, Oracle and/or its affiliates
    9
    /api/easytouse
    GET
    POST
    PUT
    DELETE

    View full-size slide

  10. REST API


    • /
    Copyright © 2020, Oracle and/or its affiliates
    10

    View full-size slide

  11. Copyright © 2020, Oracle and/or its affiliates
    11
    gRPC

    View full-size slide

  12. RPC Remote Procedure Call

    REST
    • REST RPC
    • RPC
    RPC
    • JSON-RPC: JSON
    • XML-RPC: XML
    • Adobe Flex: AMF( )
    Copyright © 2020, Oracle and/or its affiliates
    12
    /

    View full-size slide

  13. Stubby Google DC RPC
    • HTTP2 2015 OSS
    • Microservices
    Copyright © 2020, Oracle and/or its affiliates
    13
    PanCakes
    GoldenRetriever
    PanCakes
    gRPC

    View full-size slide

  14. 2017 CNCF 6
    • 2020 8 Incubating
    Microservices Cloud Native
    /
    • Netflix
    • Dropbox
    • etcd
    Copyright © 2020, Oracle and/or its affiliates
    14

    View full-size slide

  15. Protocol Buffers
    • Google (2008 )
    • /
    HTTP/2





    Copyright © 2020, Oracle and/or its affiliates
    15

    View full-size slide

  16. Protocol Buffers
    • Google (2008 )
    • IDL( )
    /



    • Protocol Buffers
    gRPC JSON
    Copyright © 2020, Oracle and/or its affiliates
    16
    .proto (IDL)

    View full-size slide

  17. HTTP/2 Connection
    HTTP/2 HTTP/1.1
    • gRPC HTTP/2





    Copyright © 2020, Oracle and/or its affiliates
    17
    gRPC
    Client
    gRPC
    Server
    • /

    request
    response

    View full-size slide

  18. Unary RPC
    • RPC
    1
    1
    RPC

    1
    RPC

    1
    RPC

    /
    Copyright © 2020, Oracle and/or its affiliates
    18
    gRPC
    Client
    gRPC
    Server
    request
    response
    gRPC
    Client
    gRPC
    Server
    request
    response
    gRPC
    Client
    gRPC
    Server
    request
    response
    gRPC
    Client
    gRPC
    Server
    request
    response

    View full-size slide

  19. gRPC
    Server Client
    Server

    Client

    • Server Stub
    Stub
    Copyright © 2020, Oracle and/or its affiliates
    19

    View full-size slide

  20. HTTP/1
    • HTTP/2
    • curl REST
    IDL( )


    Copyright © 2020, Oracle and/or its affiliates
    20

    View full-size slide

  21. gRPC .proto
    Copyright © 2020, Oracle and/or its affiliates
    21
    Protocol Buffers
    v3(2016 )
    .proto import

    View full-size slide

  22. .proto
    • RPC
    • stream /
    Copyright © 2020, Oracle and/or its affiliates
    22
    • RPC
    • RPC
    • RPC
    • RPC

    View full-size slide

  23. message( )
    Copyright © 2020, Oracle and/or its affiliates
    23
    int, string
    message

    View full-size slide

  24. gRPC Client Server ( ) .proto


    Copyright © 2020, Oracle and/or its affiliates
    24
    example.proto
    Client
    Server
    Maven/
    Gradle
    Client
    Server

    View full-size slide

  25. Client
    • Server Stub Stub(class) RPC
    Server

    Copyright © 2020, Oracle and/or its affiliates
    25
    HelloWorldServer.java

    View full-size slide

  26. Helidon gRPC
    Copyright © 2020, Oracle and/or its affiliates
    26
    Interface
    Client
    Service(Server)
    @Grpc, @Unary,
    @ServerStreaming
    gRPC

    View full-size slide

  27. Protocol Buffers +

    Java

    Protocol Buffers
    gRPC
    GrpcMpExtension
    • io.helidon.microprofile.grpc.server.s
    pi.GrpcMpExtension
    gRPC
    Copyright © 2020, Oracle and/or its affiliates
    27
    proto
    request response
    + Protocol Buffers
    Extension

    View full-size slide

  28. Copyright © 2020, Oracle and/or its affiliates
    28
    gRPC

    View full-size slide

  29. • .proto

    Copyright © 2020, Oracle and/or its affiliates
    29
    .proto

    View full-size slide

  30. • 1 1
    • 1 .proto Server
    Copyright © 2020, Oracle and/or its affiliates
    30
    Java
    gRPC Client
    Java
    gRPC Server
    Node
    gRPC Server

    View full-size slide

  31. • 1
    • Client/Server Unary RPC
    Copyright © 2020, Oracle and/or its affiliates
    31
    {name: gRPC}
    {hello gRPC} 10
    Java
    gRPC Client
    Java
    gRPC Server

    View full-size slide

  32. • 1
    • Unary Client Stub
    Copyright © 2020, Oracle and/or its affiliates
    32
    Java
    gRPC Client
    Java
    gRPC Server
    {name: a}
    {name: b}
    {name: c}
    {hello a, hello b , hello c}

    View full-size slide

  33. • Server Streaming ClientStreaming Streaming

    • Client sleep
    Copyright © 2020, Oracle and/or its affiliates
    33
    {name: a}
    {name: b}
    {name: c}
    {hello a}
    {hello b}
    {hello c}
    Java
    gRPC Server
    Java
    gRPC Client

    View full-size slide

  34. Copyright © 2020, Oracle and/or its affiliates
    34
    +
    Java
    gRPC on Helidon
    Interface
    Client
    Service(Server)

    View full-size slide

  35. • (HTTP/2 + protobuf)


    Microservices /

    • .proto

    Copyright © 2020, Oracle and/or its affiliates
    35

    View full-size slide

  36. Copyright © 2020, Oracle and/or its affiliates
    36
    GraphQL

    View full-size slide

  37. Facebook
    • 2012 Web
    • REST API /
    Facebook
    GraphQL
    2015 GraphQL graphql.js OSS
    2018 GraphQL Foundation
    Copyright © 2020, Oracle and/or its affiliates
    37

    View full-size slide

  38. GraphQL
    (nodes/vertices) (edges)
    • edges


    Copyright © 2020, Oracle and/or its affiliates
    38
    CEO
    CTO COO
    VP VP
    Mgr Mgr
    Mgr
    ( )
    O
    H
    H

    View full-size slide

  39. GraphQL HTTP API
    Facebook Github, Airbnb, Twitter
    • : https://graphql.org/users/
    GraphQL Foundation CNCF GraphQL
    landscape
    • : https://landscape.graphql.org/
    Copyright © 2020, Oracle and/or its affiliates
    39
    GraphQL
    GraphQL

    View full-size slide

  40. 3 /
    Copyright © 2020, Oracle and/or its affiliates
    40
    query:
    subscription:
    WebSocket
    mutation:
    POST/UPDATE/DELETE

    View full-size slide

  41. • URI REST
    • GraphQL Server
    Copyright © 2020, Oracle and/or its affiliates
    41
    GraphQL
    Client
    GraphQL
    Server
    Database
    Backend
    3rd party API
    GraphQL
    GraphQL Server
    REST
    Client
    Backend
    3rd party API
    REST API
    Database

    View full-size slide

  42. GraphQL
    Copyright © 2020, Oracle and/or its affiliates
    42
    built-in Scalar
    type(Int, Float, String,
    Boolean, ID)
    Scalar type Enum
    Query Mutation
    • input( )

    View full-size slide

  43. GraphQL Client Server
    GraphQL Server DB
    Copyright © 2020, Oracle and/or its affiliates
    43
    GraphQL
    Client GraphQL
    Server
    Database
    Backend
    3rd party API
    query {

    }
    GET /api/…

    View full-size slide

  44. GraphQL GET POST
    GraphQL
    2
    • Apollo Client: GraphQL
    Apollo 1
    JavaScript (React, Vue,
    Angular)
    • Relay: Facebook React/React Native
    Client
    Copyright © 2020, Oracle and/or its affiliates
    44
    curl -X POST
    -H "Content-Type: application/json"
    -d '{"query": "{ hello }"}'
    http://localhost:4000/graphql
    CURL

    View full-size slide

  45. GraphQL Server Resolver
    • Resolver Client
    • Resolver Function
    • GraphQL Server JavaScript





    • FaaS

    Copyright © 2020, Oracle and/or its affiliates
    45
    mutation

    View full-size slide

  46. • API GraphQL Java
    2020
    • GraphQL Java API
    • 2


    Copyright © 2020, Oracle and/or its affiliates
    46

    View full-size slide

  47. Copyright © 2020, Oracle and/or its affiliates
    47
    query
    Customer
    GraphQL Server
    • Customer
    • GraphQL Server query
    Database

    View full-size slide

  48. GraphiQL/GraphQL Playground
    • GraphQL IDE
    • GraphiQL GraphQL
    Foundation
    • Playground Prisma
    Apollo
    • GraphQL Client, Server,
    CLI
    • Client React, Vue,
    Angular FW
    • Server Heroku, AWS
    Lambda, Azure Functions
    Hasura GraphQL Engine
    • Postgres
    GraphQL Server
    • GraphQL Foundation
    CNCF
    Copyright © 2020, Oracle and/or its affiliates
    48

    View full-size slide

  49. API
    • GraphQL GraphQL Server
    REST
    • HTTP ( 200 )
    • (URI)
    GraphQL Server
    • Resolver

    • JSON
    • base64
    Copyright © 2020, Oracle and/or its affiliates
    49

    View full-size slide

  50. Copyright © 2020, Oracle and/or its affiliates
    50
    id
    DB API
    ID

    View full-size slide

  51. Copyright © 2020, Oracle and/or its affiliates
    51
    /
    non-nullable
    !
    (
    )

    View full-size slide

  52. Copyright © 2020, Oracle and/or its affiliates
    52
    allCustomers
    subscription

    View full-size slide

  53. Copyright © 2020, Oracle and/or its affiliates
    53
    GraphQL

    View full-size slide

  54. • Node.js(Express) + Apollo GraphQL Server
    • query/mutation/subscription GraphQL Playground(GraphQL IDE)
    Copyright © 2020, Oracle and/or its affiliates
    54
    Node.js
    Express
    GraphQL Server
    Playground endpoint
    Playground UI

    View full-size slide

  55. • GraphQL
    • GraphQL Server JavaScript
    • GraphQL Vue Apollo
    Copyright © 2020, Oracle and/or its affiliates
    55

    View full-size slide






  56. • (Web/Native )

    GraphQL
    API 1
    Copyright © 2020, Oracle and/or its affiliates
    56

    View full-size slide

  57. 57 Copyright © 2020, Oracle and/or its affiliates

    View full-size slide

  58. Our mission is to help people see
    data in new ways, discover insights,
    unlock endless possibilities.

    View full-size slide