Slide 1

Slide 1 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge Cloud Endpoints https://cloud.google.com/endpoints/

Slide 2

Slide 2 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge What does Swagger bring to the table?

Slide 3

Slide 3 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge How do we Scale in the Cloud? Google-style!

Slide 4

Slide 4 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge So what’s Cloud Endpoints

Slide 5

Slide 5 text

Proprietary + Confidential @glaforge Ok, OpenAPI Specs! Cloud Endpoints mastermind!

Slide 6

Slide 6 text

Proprietary + Confidential Benefits of OpenAPI Specs Contract First is Trendy ! @glaforge

Slide 7

Slide 7 text

Contract as the Source of Truth

Slide 8

Slide 8 text

Facilitates Team Communication, Collaboration

Slide 9

Slide 9 text

Great for Tooling Client SDKs Server skeletons Test stubs Static & live mocks Sandbox & live playground Static documentation API Portal w/ provisioning Be careful with code generation overwriting customisations

Slide 10

Slide 10 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Staff Developer Advocate Google Cloud Platform @glaforge How do we Scale in the Cloud? Google-style!

Slide 11

Slide 11 text

Proprietary + Confidential The various compute options on Google Cloud Platform @glaforge

Slide 12

Slide 12 text

Proprietary + Confidential Google App Engine — GAE Flex and Standard “Deploy your code, we’ll scale it for you!” @glaforge

Slide 13

Slide 13 text

Proprietary + Confidential Google Container Engine — GKE Powered by Kubernetes & Docker OSS Kubernetes based container clustering @glaforge

Slide 14

Slide 14 text

Proprietary + Confidential Google Compute Engine — GCE Customize your VM images Full control: Reusable and customisable VMs @glaforge

Slide 15

Slide 15 text

Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Staff Developer Advocate Google Cloud Platform @glaforge So what’s Cloud Endpoints

Slide 16

Slide 16 text

Proprietary + Confidential Cloud Endpoints API Management on Google Cloud Platform @glaforge

Slide 17

Slide 17 text

Proprietary + Confidential What is API Management? @glaforge

Slide 18

Slide 18 text

Proprietary + Confidential ● API Management from Google ● This architecture serves hundreds of billions of requests per day ● All configuration happens through Open API Spec (JSON/HTTP & gRPC) Cloud Endpoints @glaforge

Slide 19

Slide 19 text

Proprietary + Confidential Three key aspects For public / private / mobile / µ-services use cases @glaforge

Slide 20

Slide 20 text

Proprietary + Confidential Three key aspects For public / private / mobile / µ-services use cases Control access, authenticate users SECURE @glaforge

Slide 21

Slide 21 text

Proprietary + Confidential Three key aspects For public / private / mobile / µ-services use cases Logging and monitoring of key metrics SECURE MONITOR @glaforge

Slide 22

Slide 22 text

Proprietary + Confidential Three key aspects For public / private / mobile / µ-services use cases Speed and scalability SECURE MONITOR SCALE @glaforge

Slide 23

Slide 23 text

Proprietary + Confidential @glaforge

Slide 24

Slide 24 text

Proprietary + Confidential Extensible Service Proxy Why a server-local proxy? Extremely thin Eliminates network hop Simpler, better security Scales with your app <1 ms latency Will be Open Sourced @glaforge

Slide 25

Slide 25 text

Pancake DEMO

Slide 26

Slide 26 text

Proprietary + Confidential Proprietary + Confidential What else? @glaforge

Slide 27

Slide 27 text

Proprietary + Confidential JSON-HTTP/1.1 Use Open API specs to manage RESTful APIs written in any language and with any framework. Proto-HTTP/2 Use gRPC to build highly efficient HTTP/2-based APIs Choose your protocol @glaforge

Slide 28

Slide 28 text

Proprietary + Confidential Write once; serve twice ● At Google, our gRPC APIs serve both gRPC and REST/JSON surfaces ● Proxy allows you to write a gRPC backend and serve both REST/JSON and gRPC ● The only API management product that allows managing gRPC-based APIs @glaforge

Slide 29

Slide 29 text

Proprietary + Confidential Summary Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge

Slide 30

Slide 30 text

Summary Manage Open Choice JSON Web Tokens, Auth0, Firebase API Keys, Custom... Secure Monitor Scale Dashboard with API Metrics and API Logs

Slide 31

Slide 31 text

Summary Manage Open Choice Protocol Tech Scale JSON / HTTP Or gRPC Any Language Any Framework 3rd party cloud, or on-premise

Slide 32

Slide 32 text

Summary Manage Open Choice Standard OSS

Slide 33

Slide 33 text

Current state & supported platforms ● Cloud Endpoints for JSON / HTTP REST APIs ○ App Engine Flex, Container Engine, Compute Engine ○ Other clouds + on premise via Kubernetes ● Cloud Endpoints for gRPC ○ Same (except GAE Flex w/ HTTP/1.1 support only) @glaforge

Slide 34

Slide 34 text

Proprietary + Confidential Thanks for your attention! Guillaume Laforge Developer Advocate Google Cloud Platform @glaforge Cloud Endpoints https://cloud.google.com/endpoints/

Slide 35

Slide 35 text

References Slides of this presentation http://bit.ly/nordic-endpoints Google Cloud Endpoints https://cloud.google.com/endpoints/ Managing gRPC APIs with Google Cloud Endpoints http://www.slideshare.net/WenchengLu/managing-grpc-apis-with-google-cloud-endpoints Choosing a compute option on Google Cloud Platform https://cloud.google.com/docs/choosing-a-compute-option @glaforge

Slide 36

Slide 36 text

Picture credits — public domain images Truth newspaper https://pixabay.com/fr/v%C3%A9rit%C3%A9-journal-actualit%C3%A9s-imprim%C3%A9-166853/ Women working together https://pixabay.com/fr/femmes-travail-d-%C3%A9quipe-l-%C3%A9quipe-1209678/ Drill https://pixabay.com/fr/t%C3%AAte-de-forage-foret-perceuse-m%C3%A9tal-444504/ Pancakes https://pixabay.com/fr/cr%C3%AApe-cr%C3%AApes-manger-alimentaire-640865/ Room service icon https://pixabay.com/fr/service-de-chambre-serviteur-service-297071/ @glaforge

Slide 37

Slide 37 text

Proprietary + Confidential Appendix

Slide 38

Slide 38 text

Proprietary + Confidential --- swagger: "2.0" info: description: "No description" version: "1.0.0" title: "pancakes-api" contact: {} host: "pancakes-api.endpoints.pancakes-endpoints-v2.cloud.goog" paths: /pancakes: get: summary: "Retrieve the pancakes" operationId: "getAllPancakes" produces: - "application/json" parameters: [] responses: 200: description: "Status 200" schema: type: "array" items: $ref: "#/definitions/Pancake" security: - api_key: [] swagger2.yaml post: summary: "Add a new pancake" operationId: "createPancake" consumes: - "application/json" produces: - "application/json" parameters: - in: "body" name: "body" required: false schema: $ref: "#/definitions/Pancake" responses: 201: description: "Status 201" schema: $ref: "#/definitions/Pancake" security: - api_key: []

Slide 39

Slide 39 text

Proprietary + Confidential /pancakes/{pancakeId}: get: summary: "Retrieve a particular pancake" operationId: "getPancakeById" produces: - "application/json" parameters: - name: "pancakeId" in: "path" description: "The unique pancake ID" required: true type: "string" responses: 200: description: "Status 200" schema: $ref: "#/definitions/Pancake" security: - api_key: [] swagger2.yaml securityDefinitions: api_key: type: "apiKey" name: "key" in: "query" definitions: Pancake: type: "object" required: - "title" properties: id: type: "string" description: "The unique pancake ID" title: type: "string" description: "Pancake title"

Slide 40

Slide 40 text

Proprietary + Confidential FROM gcr.io/google_appengine/openjdk8 VOLUME /tmp ADD build/distributions/pancakes-endpoints-v2-1.0.tar / ENV JAVA_OPTS='-Djava.security.egd=file:/dev/./urandom' ENTRYPOINT ["/pancakes-endpoints-v2-1.0/bin/pancakes-endpoints-v2"] EXPOSE 8081 Dockerfile

Slide 41

Slide 41 text

Proprietary + Confidential kube-cfg.yaml apiVersion: v1 kind: Service metadata: name: pancakes-api spec: ports: - port: 80 targetPort: 8080 protocol: TCP name: http selector: app: esp-pancakes type: LoadBalancer --- apiVersion: extensions/v1beta1 kind: Deployment metadata: name: pancakes-api spec: replicas: 1 template: metadata: labels: app: pancakes-api spec: containers: - name: esp image: gcr.io/endpoints-release/endpoints-runtime:1 args: [ "-p", "8080", "-a", "127.0.0.1:8081", "-s", "pancakes-api.endpoints.pancakes-endpoints-v2.cloud.goog", "-v", "2017-05-10r3", ] ports: - containerPort: 8080 - name: pancakes-image image: gcr.io/pancakes-endpoints-v2/pancakes-image:latest ports: - containerPort: 8081

Slide 42

Slide 42 text

Proprietary + Confidential SERVICE: “esp-pancakes” CONTAINER: “esp” APP-CONTAINER: “pancakes-image” APP 80 8080 8081 8081