Top Banner
from the TRENCHES TRENCHES what you should know before you go to production AWS LAMBDA AWS LAMBDA
196

Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Jan 21, 2018

Download

Technology

Codemotion
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

from the

TRENCHESTRENCHES

what you should know before you go to production

AWS LAMBDAAWS LAMBDA

Page 2: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

hi, I’m Yan Cui

Page 3: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

hi, I’m Yan CuiAWS user since 2009

Page 4: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 5: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 6: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 7: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 8: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 9: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 10: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

apr, 2016

Page 11: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

hidden complexities and dependencies

low utilisation to leave room for traffic spikes

EC2 scaling is slow, so scale earlier

lots of cost for unused resources

up to 30 mins for deployment

deployment required downtime

Page 12: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

- Dan North

“lead time to someone saying thank you is the only reputation

metric that matters.”

Page 13: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 14: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“what would good

look like for us?”

Page 15: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

be small be fast

have zero downtime have no lock-step

DEPLOYMENTS SHOULD...

Page 16: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

FEATURES SHOULD...be deployable independently

be loosely-coupled

Page 17: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

WE WANT TO...minimise cost for unused resources

minimise ops effort reduce tech mess

deliver visible improvements faster

Page 18: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

nov, 2016

Page 19: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

170 Lambda functions in prod

1.2 GB deployment packages in prod

95% cost saving vs EC2

15x no. of prod releases per month

Page 20: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

timeis a good fit

Page 21: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

1st function in prod!time

is a good fit

Page 22: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

?

timeis a good fit

1st function in prod!

Page 23: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

ALERTING

CI / CD

TESTING

LOGGING

MONITORING

Page 24: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Practices ToolsPrinciples

what is good? how to make it good? with what?

Page 25: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Principles outlast Tools

Page 26: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

170 functions

WOOF!

? ?

timeis a good fit

1st function in prod!

Page 27: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

SECURITY

DISTRIBUTEDTRACING

CONFIGMANAGEMENT

Page 28: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

evolving the PLATFORM

Page 29: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

rebuilt search

Page 30: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Amazon CloudSearch

Page 31: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Amazon CloudSearchAmazon API Gateway Amazon Lambda

Page 32: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

new analytics pipeline

Page 33: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Google BigQuery

Page 34: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Google BigQuery

1 developer, 2 daysdesign production

(his 1st serverless project)

Page 35: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Google BigQuery“nothing ever got done

this fast at Skype!”

- Chris Twamley

Page 36: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

- Dan North

“lead time to someone saying thank you is the only reputation

metric that matters.”

Page 37: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Rebuiltwith Lambda

Page 38: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 39: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 40: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 41: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 42: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 43: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 44: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Rebuiltwith Lambda

Page 45: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

BigQuery

Page 46: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

BigQuery

Page 47: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

grapheneDB

BigQuery

Page 48: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

grapheneDB

BigQuery

Page 49: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

grapheneDB

BigQuery

Page 50: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

getting PRODUCTION READY

Page 51: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CHOOSE A

FRAMEWORK

DEPLOYMENT

Page 52: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://serverless.com

Page 53: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

https://github.com/awslabs/serverless-application-model

Page 54: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://apex.run

Page 55: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

https://apex.github.io/up

Page 56: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

https://github.com/claudiajs/claudia

Page 57: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

https://github.com/Miserlou/Zappa

Page 58: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://gosparta.io/

Page 59: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

TESTING

Page 60: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

amzn.to/29Lxuzu

Page 61: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Level of Testing

1.Unitdo our objects do the right thing?are they easy to work with?

Page 62: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 63: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Level of Testing

1.Unit2.Integrationdoes our code work against code we can’t change?

Page 64: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

handler

Page 65: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

handler

test by invoking the handler

Page 66: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Level of Testing

1.Unit2.Integration3.Acceptancedoes the whole system work?

Page 67: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Level of Testing

unit

integration

acceptance

feedb

ack

confidence

Page 68: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“…We find that tests that mock external libraries often need to be complex to get the code into the right state for the functionality we need to exercise.

The mess in such tests is telling us that the design isn’t right but, instead of fixing the problem by improving the code, we have to carry the extra complexity in both code and test…”

Don’t Mock Types You Can’t Change

Page 69: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“…The second risk is that we have to be sure that the behaviour we stub or mock matches what the external library will actually do…

Even if we get it right once, we have to make sure that the tests remain valid when we upgrade the libraries…”

Don’t Mock Types You Can’t Change

Page 70: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Don’t Mock Types You Can’t ChangeServices

Page 71: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Paul Johnston

The serverless approach to testing is different and may

actually be easier.

http://bit.ly/2t5viwK

Page 72: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

LambdaAPI Gateway DynamoDB

Page 73: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

LambdaAPI Gateway DynamoDB

Unit Tests

Page 74: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

LambdaAPI Gateway DynamoDB

Unit Tests

Mock/Stub

Page 75: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

is our request correct?

is the request mapping set up correctly?is the API resources

configured correctly?

are we assuming the correct schema?

LambdaAPI Gateway DynamoDB

is Lambda proxy configured correctly?

is IAM policy set up correctly?

is the table created?

what unit tests will not tell you…

Page 76: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 77: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

most Lambda functions are simple have single purpose, the risk of

shipping broken software has largely shifted to how they integrate with

external services

observation

Page 78: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 79: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

But it slows down my feedback loop…

IT’S NOT ABOUT YOU!

Page 80: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

…if a service can’t provide you with a relatively easy

way to test the interface in reality, then you should

consider using another one.

Paul Johnston

Page 81: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“…Wherever possible, an acceptance test should exercise the system end-to-end without directly calling its internal code.

An end-to-end test interacts with the system only from the outside: through its interface…”

Testing End-to-End

Page 82: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Amazon CloudSearchAmazon API Gateway Amazon Lambda

Page 83: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Amazon CloudSearchAmazon API Gateway Amazon Lambda

Test Input

Page 84: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Legacy Monolith Amazon Kinesis Amazon Lambda

Amazon CloudSearchAmazon API Gateway Amazon Lambda

Test Input

Validate

Page 85: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

integration tests exercise system’s Integration with its

external dependencies

Page 86: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

acceptance tests exercise system End-to-End from

the outside

Page 87: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

integration tests differ from acceptance tests only in HOW the

Lambda functions are invoked

observation

Page 88: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 89: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 90: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 91: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CI + CD PIPELINE

Page 92: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“the earlier you consider CI + CD, the more time you save in the long run”

- me

Page 93: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“…We prefer to have the end-to-end tests exercise both the system and the process by which it’s built and deployed…

This sounds like a lot of effort (it is), but has to be done anyway repeatedly during the software’s lifetime…”

Testing End-to-End

Page 94: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“deployment scripts that only live on the CI

box is a disaster waiting to happen”

- me

Page 95: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Jenkins build config deploys and tests

unit + integration tests

deploy

acceptance tests

Page 96: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

if [ "$1" = "deploy" ] && [ $# -eq 4 ]; then STAGE=$2 REGION=$3 PROFILE=$4

npm install AWS_PROFILE=$PROFILE 'node_modules/.bin/sls' deploy -s $STAGE -r $REGION elif [ "$1" = "int-test" ] && [ $# -eq 4 ]; then STAGE=$2 REGION=$3 PROFILE=$4

npm install AWS_PROFILE=$PROFILE npm run int-$STAGE elif [ "$1" = "acceptance-test" ] && [ $# -eq 4 ]; then STAGE=$2 REGION=$3 PROFILE=$4

npm install AWS_PROFILE=$PROFILE npm run acceptance-$STAGE else usage exit 1 fi

Page 97: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

build.sh allows repeatable builds on both local & CI

Page 98: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 99: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Auto Auto Manual

Page 100: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

LOGGING

Page 101: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 102: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

2016-07-12T12:24:37.571Z 994f18f9-482b-11e6-8668-53e4eab441ae GOT is off air, what do I do now?

Page 103: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

2016-07-12T12:24:37.571Z 994f18f9-482b-11e6-8668-53e4eab441ae GOT is off air, what do I do now?

UTC Timestamp API Gateway Request Id

your log message

Page 104: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

function name

date

function version

Page 105: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

me

Logs are not easily searchable in CloudWatch Logs.

Page 106: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

LOG OVERLOAD

Page 107: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CENTRALISE LOGS

Page 108: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CENTRALISE LOGS

MAKE THEM EASILYSEARCHABLE

Page 109: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

+ +the elk stack

Page 110: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Logs

Page 111: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Logs AWS Lambda ELK stack

Page 112: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Events

Page 113: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 114: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2f3zxQG

Page 115: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

DISTRIBUTED TRACING

Page 116: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 117: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“my followers didn’t receive my new post!”

- a user

Page 118: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

where could the problem be?

Page 119: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

correlation IDs*

* eg. request-id, user-id, yubl-id, etc.

Page 120: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

ROLL YOUR OWNCLIENTS

Page 121: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

kinesis client

http client

sns client

Page 122: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2k93hAj

Page 123: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

ROLL YOUR OWNCLIENTS

X-RAY

Page 124: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Amazon X-Ray

Page 125: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Amazon X-Ray

Page 126: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

traces do not span over API Gateway

Page 127: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2s9yxmA

Page 128: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

MONITORING + ALERTING

Page 129: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“where do I install monitoring agents?”

Page 130: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

you can’t

Page 131: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

• invocation Count• error Count• latency• throttling• granular to the minute• support custom metrics

Page 132: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

• same metrics as CW• better dashboard• support custom metrics

https://www.datadoghq.com/blog/monitoring-lambda-functions-datadog/

Page 133: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 134: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 135: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 136: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

my code

Page 137: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

my code

Page 138: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

my codeinternet internet

press button something happens

Page 139: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“how do I batch up and send logs in the

background?”

Page 140: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

you can’t (kinda)

Page 141: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

console.log(“hydrating yubls from db…”);

console.log(“fetching user info from user-api”);

console.log(“MONITORING|1489795335|27.4|latency|user-api-latency”);

console.log(“MONITORING|1489795335|8|count|yubls-served”);

timestamp metric value

metric type

metric namemetrics

logs

Page 142: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Logs AWS Lambda

ELK stacklogs

metrics

CloudWatch

Page 143: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2gGredx

Page 144: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

DASHBOARDS

Page 145: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

DASHBOARDS

SET ALARMS

Page 146: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

DASHBOARDS

SET ALARMS

TRACK APP-LEVELMETRICS

Page 147: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Not Only CloudWatch

Page 148: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 149: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

“you really don't want your monitoring

system to fail at the same time as the

system it monitors” - me

Page 150: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CONFIG MANAGEMENT

Page 151: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

easily and quickly propagate config changes

Page 152: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 153: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

me

Environment variables make it hard to share configurations

across functions.

Page 154: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

me

Environment variables make it hard to implement fine-grained

access to sensitive info.

Page 155: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CENTRALISEDCONFIG SERVICE

Page 156: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

config servicegoes here

Page 157: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 158: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 159: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017
Page 160: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

SSM Parameter

Store

Page 161: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

sensitive data should be encrypted in-flight, and at rest

(credentials, connection string, etc.)

Page 162: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

role-based access

Page 163: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

SSM Parameter Store

HTTPS

role-based access

encrypted in-flight

Page 164: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

SSM Parameter Store

encrypt

role-based access

Page 165: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

SSM Parameter Store

encrypted at-rest

Page 166: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

HTTPS

role-based access

SSM Parameter Store

encrypted in-flight

Page 167: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CENTRALISEDCONFIG SERVICE

CLIENT LIBRARY

Page 168: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

fetch & cache at Cold Start

Page 169: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

invalidate at interval + signal

Page 170: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2yLUjwd

Page 171: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

PRO TIPS

Page 172: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

max 75 GB total deployment package size*

* limit is per AWS region

Page 173: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Janitor Monkey

Page 174: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Janitor Lambda

http://bit.ly/2xzVu4a

Page 175: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

disable versionFunctions in

Page 176: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

install Serverless framework as dev dependency at project level

dev dependencies are excluded since 1.16.0

Page 177: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2vzBqhC

Page 178: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://amzn.to/2vtUkDU

Page 179: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

UNDERSTANDCOLDSTARTS

Page 180: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Amazon X-Ray1st invocation

2nd invocation

cold start

Page 181: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

source: http://bit.ly/2oBEbw2

Page 182: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

http://bit.ly/2rtCCBz

Page 183: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

C#

http://bit.ly/2rtCCBz

Page 184: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

Java

http://bit.ly/2rtCCBz

Page 185: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

NodeJs, Python

http://bit.ly/2rtCCBz

Page 186: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

AVOIDCOLDSTARTS

Page 187: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Event AWS Lambda

Page 188: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Event AWS Lambda

ping

ping

ping

ping

Page 189: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Event AWS Lambda

ping

ping

ping

ping

Page 190: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

CloudWatch Event AWS Lambda

ping

ping

ping

ping

HEALTH CHECKS?

Page 191: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

AVOID HARDASSUMPTIONS

ABOUT FUNCTIONLIFETIME

Page 192: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

USE STATE FOR

OPTIMISATION

Page 193: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

max 5 mins execution time

Page 194: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

USE RECURSIONFOR LONG

RUNNING TASKS

Page 195: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

@theburningmonktheburningmonk.comgithub.com/theburningmonk

Page 196: Yan Cui - Serverless in production, an experience report - Codemotion Milan 2017

@theburningmonktheburningmonk.comgithub.com/theburningmonk

http://bit.ly/2yQZj1H

all my blog posts on Lambda