Deploying GraphQL in a Serverless Context€¦ · How GraphQL fits into a Serverless architecture...

Post on 03-Sep-2020

6 views 0 download

Transcript of Deploying GraphQL in a Serverless Context€¦ · How GraphQL fits into a Serverless architecture...

Deploying GraphQL in a Serverless Context

Kevin Old - @kevinold

What is a Serverless architecture?

How GraphQL fits into a Serverless architectureHow to get started with Serverless + GraphQL

Immediate use casesPros and Cons

Agenda

Serverless?

it’s ok to roll your eyes, no really, it is :)

Function as a Service(FaaS)

Write single-purpose stateless functions

Design push-based, event-driven pipelinesCreate thicker, more powerful front ends

Embrace third party servicesUse a compute service to execute code on demand

Principles of a Serverless Architecture

👁 ❤

Lambda is really cool, but is a massive pain to setup

Click "Create a Lambda function"Choose a Blueprint functionConfigure how it is triggered (API Gateway, DynamoDB, CloudWatch, etc.)Configure the function

Runtime (Node.js 4.3)MemoryTimeoutLambda function code (in WYSIWYG editor)Handler path inside containerRole creationPolicy creationVPC access

"Optimize human time, not machine time"

via https://medium.com/apollo-stack/how-to-build-graphql-servers-87587591ded5

Automation for working with AWS Lambda, etc.

+ 😎=

101$ npm install -g serverless@beta

$ serverless create -t aws-nodejs

$ serverless deploy

$ serverless remove

101Function

Event

Resource (S3, Dynamo, IAM, etc)

Service

+

Using GraphQL + Serverless to serve up endless Dad Jokes

Pros

No longer managing servers

Not running server(s) 24 / 7Scale instantly

Serverless, Apex, etc.AWS, Google, Microsoft, IBM solutions

Pay only for what you use

Marketing site (S3) + FormMobile backendsBackground Jobs (Image resize, log processing)CMS and low-bandwidth BFF's (Backend's for Frontend’s)Any pre-compute stored (S3) for later retrievalStartups / Prototyping productsTest, Dev and Staging environments

Immediate Use Cases

Server-rendered ReactSecurity/Compliant heavy appsRead-only API’sAnything with an SLAHigh throughput / availability

Possible, but not a good fit?

ConsLimited documentation/examples

Latency

Best practices are still being defined

Security

Offline development

Serverless (v0.x stable, v1 beta), Apex, etc.

Debugging whoas

Cons

Thanks!

https://github.com/kevinold/serverless-graphql-dadjokes

@kevinold kevin@kevinold.com