The Good, Bad and Ugly of Serverless

Post on 16-Apr-2017

147 views 2 download

Transcript of The Good, Bad and Ugly of Serverless

ServerlessThe Good, the Bad and the Ugly

Martin Raagmartin@testlio.com

Functions as a Service

Lambda

DynamoDB S3 Kinesis

Lambda

CloudFormation SWF CloudTrail SES Cognito API Gateway CloudWatchSNS

w

The serverless manifesto

• No machines, VMs, or containers visible in the programming model.

• Functions are the unit of deployment & scaling.

• Implicitly fault tolerant, as functions can run anywhere.

• Scales per request.

• Users can not over- or under-provision capacity.

• Permanent storage lives elsewhere.

• Never pay for idle, no cold servers or their costs.

• Bring your own code (BYOC).

• Metrics and logging are a universal right.

Latency

Latency

• Coldstarts add ~100ms latency• Up to ~10s for JVM based functions• Keep your functions warm

Latency

functions: hello: handler: handler.hello events: - http: path: hello method: get - schedule: rate(10 minutes)

Latency

https://www.iopipe.com/2016/09/understanding-aws-lambda-coldstarts/

Latency

0

0.0375

0.075

0.1125

0.15

0.1875

APIGW/Lambda ELB/EC2

time_

tola

l

Latency (Cross Region)

0

0.325

0.65

0.975

1.3

APIGW/Lambda ELB/EC2

time_

tota

l

Latency (Cross Region)

0

0.05

0.1

0.15

0.2

APIGW/Lambda ELB/EC2

time_

conn

ect

API Gateway

– Top Gear

“Ambitious, but rubbish.”

What API Gateway does?• Authentication• Caching• Input validation• Request and response mapping• Throttling• Stages• Environment variables• SDK generation

What API Gateway doesn’t?

• Integrate (well) with other AWS services

API Gateway

• No CloudFront edge cache• Lambda timeout at 10s (maybe 30s)• No Certificate Manager integration

https://forums.aws.amazon.com/thread.jspa?messageID=700646&#700646

https://forums.aws.amazon.com/thread.jspa?messageID=700646&#700646

https://forums.aws.amazon.com/thread.jspa?messageID=700646&#700646

Configuration

Configuration

https://12factor.net/build-release-run

– Adam Wiggins (12 Factor App)

“The twelve-factor app stores config in environment variables.”

https://www.concurrencylabs.com/blog/configure-your-lambda-function-like-a-champ-sail-smoothly/

Local Environments

Debugging

Concurrent Execution Limit

DoS yourself

That’s not all

• No persistent state• 5 minute execution limit• No atomic deployments of a service• Immature tooling• Vendor control / lock-in• Service Discovery

Conclusion

Further reading

http://martinfowler.com/articles/serverless.html

https://www.iopipe.com/2016/09/understanding-aws-lambda-coldstarts/

https://www.concurrencylabs.com/blog/configure-your-lambda-function-like-a-champ-sail-smoothly/

https://github.com/serverless/serverless

https://charity.wtf/2016/05/31/operational-best-practices-serverless/

Release Your App With Confidence

Martin Raagmartin@testlio.com