Upload
others
View
1
Download
0
Embed Size (px)
Citation preview
How to reach a Global Audiencewith a world-class Music App
and AWS Lambda
Frank Schmid
Architect Stashimifrankstashimicom
httpsstashimicom
11092016
Stashimi
Stashimi is on a mission to create the best place for music lovers to find everything about an artist
Stashimi uses smart aggregation to keep you up-to-date with artists you care about Youcan choose from over 50000 artists including the biggest names in music to get real-time updates and browse news music video and social posts Youll never miss another musicmoment from your favorite artists ever again
ldquoA new Los Angeles-based music platform called Stashimi wants to help music lovers stay betterconnected with their favorite artists By using web crawlers that scan information across more than100000 data sources the Stashimi serves as a centralized hub to get real-time updates frommusicians breaking industry news and information about trending songs and artistsrdquo
Source Business Insider - httpwwwbusinessinsiderdestashimi-music-streaming-app-targets-avid-fans-2016-10
How it works
API Gateway
Cognito Backend Data storage
Aurora (RDS)
mySQL (RDS)
ElasticSearch
S3
Account
Backgroundmanagement
tasks
Events
Search
Data
ElastiCache
musicstashimicom
BotsFacebook Skype
Bot AI
CloudFront
API Gateway
Mobile client
Stashimi App
Live demo
iOS version currently available at the US Apple Storehttpsitunesapplecomusappstashimi-your-music-news-feedid1060170766ls=1ampmt=8amp_branch_match_id=299750350495397274
What is AWS Lambda
bull Cloud based functionmodule (serverless)
bull Can be invoked via multiple methods (see Invocation Sources)
bull JSON formatted input
bull JSON formatted result
bull Supports Nodejs Java or Python natively
bull Executes internally on EC2 instances (opaque to the lambda)
bull Advanced Native modules can be used too (eg binaries like OpenCV)
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Stashimi
Stashimi is on a mission to create the best place for music lovers to find everything about an artist
Stashimi uses smart aggregation to keep you up-to-date with artists you care about Youcan choose from over 50000 artists including the biggest names in music to get real-time updates and browse news music video and social posts Youll never miss another musicmoment from your favorite artists ever again
ldquoA new Los Angeles-based music platform called Stashimi wants to help music lovers stay betterconnected with their favorite artists By using web crawlers that scan information across more than100000 data sources the Stashimi serves as a centralized hub to get real-time updates frommusicians breaking industry news and information about trending songs and artistsrdquo
Source Business Insider - httpwwwbusinessinsiderdestashimi-music-streaming-app-targets-avid-fans-2016-10
How it works
API Gateway
Cognito Backend Data storage
Aurora (RDS)
mySQL (RDS)
ElasticSearch
S3
Account
Backgroundmanagement
tasks
Events
Search
Data
ElastiCache
musicstashimicom
BotsFacebook Skype
Bot AI
CloudFront
API Gateway
Mobile client
Stashimi App
Live demo
iOS version currently available at the US Apple Storehttpsitunesapplecomusappstashimi-your-music-news-feedid1060170766ls=1ampmt=8amp_branch_match_id=299750350495397274
What is AWS Lambda
bull Cloud based functionmodule (serverless)
bull Can be invoked via multiple methods (see Invocation Sources)
bull JSON formatted input
bull JSON formatted result
bull Supports Nodejs Java or Python natively
bull Executes internally on EC2 instances (opaque to the lambda)
bull Advanced Native modules can be used too (eg binaries like OpenCV)
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
How it works
API Gateway
Cognito Backend Data storage
Aurora (RDS)
mySQL (RDS)
ElasticSearch
S3
Account
Backgroundmanagement
tasks
Events
Search
Data
ElastiCache
musicstashimicom
BotsFacebook Skype
Bot AI
CloudFront
API Gateway
Mobile client
Stashimi App
Live demo
iOS version currently available at the US Apple Storehttpsitunesapplecomusappstashimi-your-music-news-feedid1060170766ls=1ampmt=8amp_branch_match_id=299750350495397274
What is AWS Lambda
bull Cloud based functionmodule (serverless)
bull Can be invoked via multiple methods (see Invocation Sources)
bull JSON formatted input
bull JSON formatted result
bull Supports Nodejs Java or Python natively
bull Executes internally on EC2 instances (opaque to the lambda)
bull Advanced Native modules can be used too (eg binaries like OpenCV)
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Stashimi App
Live demo
iOS version currently available at the US Apple Storehttpsitunesapplecomusappstashimi-your-music-news-feedid1060170766ls=1ampmt=8amp_branch_match_id=299750350495397274
What is AWS Lambda
bull Cloud based functionmodule (serverless)
bull Can be invoked via multiple methods (see Invocation Sources)
bull JSON formatted input
bull JSON formatted result
bull Supports Nodejs Java or Python natively
bull Executes internally on EC2 instances (opaque to the lambda)
bull Advanced Native modules can be used too (eg binaries like OpenCV)
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
What is AWS Lambda
bull Cloud based functionmodule (serverless)
bull Can be invoked via multiple methods (see Invocation Sources)
bull JSON formatted input
bull JSON formatted result
bull Supports Nodejs Java or Python natively
bull Executes internally on EC2 instances (opaque to the lambda)
bull Advanced Native modules can be used too (eg binaries like OpenCV)
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Sample client call
User searches forbdquoMetallicaldquo
AP
I Gat
eway
httpsq=MetallicaAWS V4 Signature
identity hellip
query bdquoMetallicaldquo
Search Lambda
artists [hellip]
const libCode = require(hellip)
function handler(event context)
return libCodecheckArgs(event)
then(query =gt libCodesearch(query))
asCallback(contextdone)
HTTP response
Lambda code uses Bluebird promises to simplify asynchronous callbacks
AWS_PROXY invoke
identity hellip
http request info
query bdquoMetallicaldquo
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Sample backend call
Event(CloudWatch)
optional lambda event data
BackendTask
Set lock in case of serial enforcement
DynamoDBState table
Initialize
Do Work
(Invoke self)
Lock management is simplified here for visbility reasons
Uninitialize
Self invocation is needed for tasksthat are likely to exceed the maximumlambda runtime (currently 300s)
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Invocation Sources
bull Lambda functions can be invoked through lots of services
bull AWS web console
bull API Gateway
bull AWS-SDK
bull HTTPS call with FQDN
bull Event sources
bull DynamoDB stream
bull Kinesis stream
bull Cognito Sync
bull CloudWatch events
bull see full list at httpdocsawsamazoncomlambdalatestdginvoking-lambda-functionhtml
bull NEW Aurora stored procedures
Shortened list of the main sources used by Stashimi
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Decisions to be made
bull Strongly dependent on use case
bull Take system (account) limits into accountbull Maximum of concurrently running lambdasbull Maximum of available network interfaces in VPCnetwork
bull Look at function call frequency and average durationbull Cold start problem (see Lambda Startup)bull Global objects can be reused (eg mySQLnode)
bull Important decisionbull Single lambda for micro functionsbull Micro routing to combine more functionality in one lambda
Lambda architecture = Microservices
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Lambda startup
bull Cold startbull Lambda environment is set up internallybull Time varies on ZIP size and globals initialization
bull Warm startbull Lambda environment is halted but still alivebull Globals are still initializedbull Depends on Lambda memory settings
bull Improvementsbull Move common objects into globals (eg mySQL connection pool)bull Reduce size of ZIP by using optimization tools (eg SLS optimizer plugin)bull Ping the lambda frequently with a CloudWatch Event
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Security
bull Individual Access (on invocation)
bull IAMbull Cognito and API Gatewaybull IAM roles policies (lambda statements)bull Configurable with CloudFormation
bull Custom authorizer lambda (with API Gateway)bull Processes Authorization request headersbull Automatically invoked by API Gatewaybull Result passed to context (PrincipalId)
bull Networkbull VPC support
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Deployment
bull Requirementsbull Documented
bull Versions should be documented (link from deployed versions to sources)
bull Reproduciblebull Must be able to redeploy the same source versions
bull Support stagesbull Different environments must be supported (dev prod etc)
bull Toolsbull AWS console (ZIP upload manual configuration)
bull CI server (eg Bamboo) together with the Serverless framework
bull Others
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Deployment (per stage)
Build
Deployment ndash CI server SLS
Run tests
Store as artifact
Get dependencies
Retrieve artifact
Deploy with SLS
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Deployment - Versioning
bull Versionsbull Fixed unique version applied on upload
bull $LATEST special version last upload
bull Aliasesbull Unique name
bull Points to a specific lambda version
bull Can be shifted on deployment
bull Callers always use the correct version
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Monitoring
bull Whybull Resources are limited (eg ENI memory timeouts)bull Statistics
bull Logsbull Automatically written to CloudWatch Logsbull CW Namespace awslambdaFUNCTION_NAME
bull Log stream prepended with lambda version
bull Metricsbull Can plot metrics for deployed stagesbull Can trigger CW alarmsbull Default metricsbull Custom metrics via CloudWatch API
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Monitoring - Logs
bull Contains Lambda runtime statisticsbull Invocation start and end timesbull Memory consumptionbull Usedbilled CPU times
bull Console output is captured (eg consolelog() in Nodejs)bull Exception call stacks
bull Can be processed by another lambda (log subscription)bull Analyze log entries and store statistics elsewhere (S3 ElasticSearch etc)
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Monitoring ndash Default Metrics
bull Invocations Errors Throttles and Duration
bull Provide general overview and resource information
bull Available out of the box
bull At no cost
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Monitoring ndash Custom metrics
bull Track data metricsbull Better insight than default metrics (one invoke can do multiple actions)
bull Use CloudWatch API (through AWS-SDK)
bull Implementation efforts needed
bull Costs involved (currently $050 per metric per month)
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Maintenance
bull Server basedbull Continuous costs for server maintenance
bull At least weekly OS updates
bull Scaling must be monitored and maintained (eg AWS Beanstalk)
bull Serverless (AWS Lambda)bull Pay on use (CPU time)
bull Less staff costs
bull Scales automatically
bull Occasionally need for upgrades (eg Node 43)
Questions
Questions