scale a swagger based web api (guillaume laforge)

54
Proprietary + Confidential Scale a Swagger-based Web API with Google Cloud Endpoints Guillaume Laforge Staff Developer Advocate Google Cloud Platform @glaforge Slides available here: bit.ly/endpoints-nordic Cloud Endpoints https://cloud.google.com/endpoints/

Upload: nordic-apis

Post on 09-Jan-2017

179 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

Slides available here:bit.ly/endpoints-nordic

Cloud Endpointshttps://cloud.google.com/endpoints/

Page 2: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

What does

Swagger bring

to the table?

Page 3: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

How do we Scale

in the Cloud?

Google-style!

Page 4: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

So what’s

Cloud Endpoints

Page 5: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

@glaforge

Ok, OpenAPI Specs!

Page 6: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

@glaforge

Ok, OpenAPI Specs!

Cloud

Endpoints

mastermind!

Page 7: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Benefits of OpenAPI Specs

Contract

First is

Trendy !@glaforge

Page 8: Scale a Swagger based Web API (Guillaume Laforge)

Contract as

the Source

of Truth

Page 9: Scale a Swagger based Web API (Guillaume Laforge)

Facilitates Team

Communication,

Collaboration

Page 10: Scale a Swagger based Web API (Guillaume Laforge)

Great for Tooling

Page 11: Scale a Swagger based Web API (Guillaume Laforge)

Great for Tooling

Client SDKs

Server skeletons

Page 12: Scale a Swagger based Web API (Guillaume Laforge)

Great for Tooling

Client SDKs

Server skeletons

Test stubs

Static & live mocks

Page 13: Scale a Swagger based Web API (Guillaume Laforge)

Great for Tooling

Client SDKs

Server skeletons

Test stubs

Static & live mocks

Static documentation

Page 14: Scale a Swagger based Web API (Guillaume Laforge)

Great for Tooling

Client SDKs

Server skeletons

Test stubs

Static & live mocks Sandbox & live playground

Static documentation

API Portal w/ provisioning

Page 15: Scale a Swagger based Web API (Guillaume Laforge)

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

Page 16: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

How do we Scale

in the Cloud?

Google-style!

Page 17: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

The various compute optionson Google Cloud Platform

@glaforge

Page 18: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Google App Engine — GAEFlex and Standard

“Deploy your code,

we’ll scale it

for you!”

@glaforge

Page 19: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Google Container Engine — GKEPowered by Kubernetes & Docker

OSS Kubernetes

based container

clustering

@glaforge

Page 20: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Google Compute Engine — GCECustomize your VM images

Full control:

Reusable and

customisable VMs

@glaforge

Page 21: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Scale a Swagger-based Web APIwith Google Cloud Endpoints

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

So what’s

Cloud Endpoints

Page 22: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Cloud EndpointsAPI Management on Google Cloud Platform

@glaforge

Page 23: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

What is API Management?

@glaforge

Page 24: Scale a Swagger based Web API (Guillaume Laforge)

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

Page 25: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Three key aspectsFor public / private / mobile / µ-services use cases

@glaforge

Page 26: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Three key aspectsFor public / private / mobile / µ-services use cases

Control access, authenticate users

SECURE

@glaforge

Page 27: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Three key aspectsFor public / private / mobile / µ-services use cases

Logging and monitoring of key metrics

SECURE MONITOR

@glaforge

Page 28: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Three key aspectsFor public / private / mobile / µ-services use cases

Speed and scalability

SECURE MONITOR SCALE

@glaforge

Page 29: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

@glaforge

Page 30: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Extensible Service ProxyWhy a server-local proxy?

Extremely thin

Eliminates network hop

Simpler, better security

Scales with your app

<1 ms latency

@glaforge

Page 31: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Extensible Service ProxyWhy a server-local proxy?

Extremely thin

Eliminates network hop

Simpler, better security

Scales with your app

<1 ms latencyWill be

Open

Sourced

@glaforge

Page 32: Scale a Swagger based Web API (Guillaume Laforge)

Pancake DEMO

Page 33: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Proprietary + Confidential

What else?

@glaforge

Page 34: Scale a Swagger based Web API (Guillaume Laforge)

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

Page 35: Scale a Swagger based Web API (Guillaume Laforge)

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

Page 36: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Summary

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

Page 37: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

JSON Web Tokens,

Auth0, Firebase

API Keys, Custom...

Secure

Monitor

Scale

Page 38: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

Secure

Monitor

ScaleDashboard with

API Metrics

and API Logs

Page 39: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

Secure

Monitor

Scale

Page 40: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

Protocol

Tech

Scale

JSON / HTTP

Or gRPC

Page 41: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

Protocol

Tech

Scale

Any Language

Any Framework

Page 42: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

Choice

Protocol

Tech

Scale

3rd party cloud,

or on-premise

Page 43: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

ChoiceStandard

OSS

Page 44: Scale a Swagger based Web API (Guillaume Laforge)

Summary

Manage

Open

ChoiceStandard

OSS

Page 45: Scale a Swagger based Web API (Guillaume Laforge)

Current state & supported platforms

● BETA: Cloud Endpoints for JSON / HTTP REST APIs ○ App Engine Flex, Container Engine, Compute Engine○ Other clouds + on premise via Kubernetes

● ALPHA: Cloud Endpoints for gRPC○ Same (except GAE Flex w/ HTTP/1.1 support only)

@glaforge

Page 46: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Thanks for your attention!

Guillaume LaforgeStaff Developer Advocate

Google Cloud Platform

@glaforge

Slides available here:bit.ly/endpoints-nordic

Cloud Endpointshttps://cloud.google.com/endpoints/

Page 47: Scale a Swagger based Web API (Guillaume Laforge)

References

Slides of this presentationhttp://bit.ly/nordic-endpoints

Google Cloud Endpointshttps://cloud.google.com/endpoints/

Managing gRPC APIs with Google Cloud Endpointshttp://www.slideshare.net/WenchengLu/managing-grpc-apis-with-google-cloud-endpoints

Choosing a compute option on Google Cloud Platformhttps://cloud.google.com/docs/choosing-a-compute-option

@glaforge

Page 48: Scale a Swagger based Web API (Guillaume Laforge)

Picture credits — public domain images

Truth newspaperhttps://pixabay.com/fr/v%C3%A9rit%C3%A9-journal-actualit%C3%A9s-imprim%C3%A9-166853/

Women working togetherhttps://pixabay.com/fr/femmes-travail-d-%C3%A9quipe-l-%C3%A9quipe-1209678/

Drillhttps://pixabay.com/fr/t%C3%AAte-de-forage-foret-perceuse-m%C3%A9tal-444504/

Pancakeshttps://pixabay.com/fr/cr%C3%AApe-cr%C3%AApes-manger-alimentaire-640865/

Room service iconhttps://pixabay.com/fr/service-de-chambre-serviteur-service-297071/

@glaforge

Page 49: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

Appendix

Page 50: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

--- swagger: "2.0" info: description: "No description" version: "1.0.0" title: "pancakes-api" contact: {} host: "pancakes-endpoint-demo.appspot.com" 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: []

Page 51: Scale a Swagger based Web API (Guillaume Laforge)

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"

Page 52: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

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

Dockerfile

Page 53: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidentialkube-cfg.yaml

apiVersion: v1 kind: Service metadata: name: esp-pancakes spec: ports: - port: 80 targetPort: 8080 protocol: TCP name: http selector: app: esp-pancakes type: LoadBalancer ---

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: esp-pancakes spec: replicas: 1 template: metadata: labels: app: esp-pancakes spec: containers: - name: esp image: b.gcr.io/endpoints/endpoints-runtime:0.3 args: [ "-p", "8080", "-a", "127.0.0.1:8081", "-s", "pancakes-endpoint-demo.appspot.com", "-v", "2016-10-24r0", ] ports: - containerPort: 8080 - name: pancakes-image image: gcr.io/pancakes-endpoint-demo/pancakes-image:latest ports: - containerPort: 8081

Page 54: Scale a Swagger based Web API (Guillaume Laforge)

Proprietary + Confidential

SERVICE: “esp-pancakes”

CONTAINER: “esp” APP-CONTAINER: “pancakes-image”

APP

80 8080 8081 8081