SlideShare une entreprise Scribd logo
1  sur  79
Télécharger pour lire hors ligne
Flying Server-less on the
Cloud with AWS Lambda
Serkan ÖZAL
Who Am I?
● Senior Software Engineer @ OpsGenie
● Co-organizer of Serverless Meetup Turkey
● Oracle Open-Source Contributor
● PhD. Cand. @ METU Computer Eng.
● 8+ years in software development
● Hard-core JVM ninja
● Actively working on Serverless and AWS Lambda
● Part-time Big Data researcher
● Building a new product Thundra
2
Volume I
Agenda
● Road to Serverless
● The Motivation
● Under the Hood
● Integrations
● Limitations
● Logging
● Config Management
● Security
● Error Handling
4
5
“If your PaaS can efficiently start
instances in 20 ms that run for half
a second, then call it serverless.”
Adrian Cockcroft, VP Cloud Architecture Strategy at AWS
6
What is AWS Lambda?
- AWS’s FaaS (Function as a Service)
- Run code without provisioning or managing servers
- Support invocation types:
- Request/response (sync)
- Event driven (async)
- Supported languages:
- Go
- C#
- Java
- Node.js
- Python
7
The Motivation
8
Why AWS Lambda?
- PAYG - pay as you go
- Highly available
- Scale fast
- Horizontally
- Vertically
- Don’t manage servers
- Built-in integration with other AWS services
- Security
9
Under the Hood
10
The Devil is in the Detail
- Container reuse
- Container freeze
- More memory => More CPU
- One execution per container at any time
- At least one delivery guarantee
- New container for
- new deployments
- configuration updates
- even for environment variable updates
- Destroy container when timeout 11
How to Limit Container?
- cgroup (Control Group)
- Engineers at Google started the work in 2006
- Merged into Linux kernel in January 2008
- Can limit
- CPU
- Memory
- Disk bandwidth
- Network bandwidth
12
CPU Throttling
- cgcreate
- cgcreate -g cpu:/cg1
- cgcreate -g cpu:/cg2
- cpu.cfs_quota_us / cpu.cfs_period_us
- how to configure cg1 to run 0.2 seconds out of every 1 second?
- cgset -r cpu.cfs_quota_us=200000 cpu.cfs_period_us=1000000 cg1
- cpu.shares
- how to configure 1:2 CPU usage ratio between cg1 and cg2?
- cgset -r cpu.shared=512 cg1
- cgset -r cpu.shared=1024 cg2
- why not used by AWS Lambda? 13
Integrations
14
Built-in Integrations
- Direct
- DynamoDB
- Kinesis
- Firehose
- SNS
- S3
- API Gateway
- CloudWatch Logs
- CloudWatch Events
- Scheduled
- SES
- Cognito
- CodeCommit
- CloudFormation
- CloudFront
- Config
- Alexa
- Lex
- IoT Button
15
Limitations
16
Resource Limits
Max execution time 5 minutes
Memory allocation range 128 MB - 3 GB
Ephemeral disk capacity ("/tmp" space) 512 MB
Invoke request body payload size (sync invocation) 6 MB
Invoke request body payload size (async invocation) 128 K
Number of file descriptors 1024
Number of processes and threads (combined total) 1024
17
Deployment Limits
Function deployment package size (compressed .zip/.jar file) 50 MB
Size of code/dependencies that you can zip into a deployment
package (uncompressed .zip/.jar size)
250 MB
Total size of all the deployment packages per region 75 GB
Total size of environment variables set 4 KB
18
Execution Limits
- Account level concurrent execution limit is 1000
- It per region
- It is soft limit
- Function level concurrent execution limit
- It is reserved
- the value is deducted from the unreserved concurrency pool
- ENI Limit is 350
- It is for Lambda function in VPC
- It is per region
- It is soft limit
19
Logging
20
Writing Logs
- Logs are written to CloudWatch asynchronously
- Log group per function
- /aws/lambda/my-func
- Log stream per container under log group
- 2018/01/27/[$LATEST]f95da1aaf0384ed6ad642d8299f7503d
- How to log
- Standard output/error
- Lambda API
21
22
Collecting Logs
- Subscribe to CloudWatch log groups
- Only one subscription per log group
- Filter by pattern
- Stream to AWS Lambda
- Stream to AWS Elasticsearch
23
Config Management
24
Environment Variables
- No limit to the number of env. variables
- Max total size is 4 KB
- Must start with letters [a-zA-Z]
- Can only contain alphanumeric char. and “_” [a-zA-Z0-9_]
- KMS
- Encrypt at rest (default)
- Encrypt in transit
25
SSM
- Centralized config management
- share between functions
- update once
- Fine-grained access to sensitive data via IAM
- Integrates with KMS out-of-the-box
- Records a history of changes
26
Security
27
VPC
- Define/select VPC and configure
- Subnets (recommended one subnet in each AZ)
- Security Groups
- To be able to access internet
- NAT Gateway
- Internet Gateway
- Route table configuration
- Be aware of ENI limit (default 350)
- Sure that subnet has enough IP address range for ENI
28
Role
- Each Lambda function has an associated IAM role
- For accessing AWS resources
- grant the role the necessary permissions that your Lambda function needs
- for ex. permission to Lambda for putting item to DynamoDB table
- For non-stream based event sources
- grant the event source permissions to invoke function
- for ex. perm. to S3 bucket for invoking Lambda on upload
- For stream based event sources
- grant AWS Lambda permissions for the relevant stream actions
- for ex. perm. to Lambda for getting Kinesis stream records to be invoked
29
Others
- Inbound connections are blocked
- For outbound connections only TCP/IP sockets are
supported
- “ptrace” (debugging) system calls are blocked
- TCP port 25 is also blocked as an anti-spam measure
30
Error Handling
31
Retries
- For sync invocations (Lambda API call, …)
- client is responsible for retries
- For async invocations
- Non-Stream based events (S3, SNS, CloudWatch, …)
- retry a few times (2 or more) with delays
- If still fails, put in to DLQ (if specified=
- Stream based events (Kinesis , DynamoDB streams)
- retry until succeeded or
- retry until data expires
32
DLQ - Dead Letter Queue
- Can be
- SNS topic
- SQS queue
- Requests are redirected if the invocation is
- Asynchronous and
- Event source is non-stream based (S3, SNS, …)
- Requires permission to access to the DLQ resource
- Monitor “DeadLetterErrors” metrics
33
Volume II
Agenda
● Monitoring
● Alerting
● Testing
● Deployment
● Performance & Cold Start
● AWS Lambda @ OpsGenie
35
Monitoring
36
CloudWatch Metrics
- Following metrics are supported per function basis:
- Invocation
- Errors
- Duration
- Dead Letter Error
- Throttles
- Iterator Age
- Following metrics are supported across all functions:
- Concurrent Executions
- Unreserved Concurrent Executions
37
Distributed Tracing with AWS X-Ray
- Shows durations, responses and errors
- Segment for Lambda invocation
- Sub-Segments for
- initialization
- calls to external services
- custom ones
- Custom properties
- can be queried over “Annotation”
- can be stored on “Metadata” as raw
38
39
40
API Logging with CloudTrail
- CloudTrail can log
- function definition/configuration CRUD
- function invocations
- log entry contains information about
- who generated the request
- the requested action
- the action parameters
- ...
- CloudTrail logs can be published to
- S3
- SNS 41
Full Observability with Thundra
- Provides three pillars of observability:
- Trace
- Metric
- Log
- Zero overhead with async data publishing
- Has automated instrumentation and profiling support
- Integrated with AWS X-Ray
- www.thundra.io
42
43
44
Alerting
45
Creating Alarm
- Create alarm on CloudWatch by metrics
- Following metrics are supported per function basis:
- Following metrics are supported across all functions:
- Concurrent Executions
- Unreserved Concurrent Executions
- Notify through SNS
- E-Mail
- Lambda
- ...
- Duration
- Errors
- Invocations
- Throttles
46
Testing
47
Writing Test
- Unit Test
- do our objects works as expected themselves?
- Integration Test
- does our objects work well together?
- Functional Test
- does the whole system work from end to end?
- Local Lambda development
- SAM Local
- LocalStack
- Cloud9 48
SAM Local
- Works with SAM template
- Simulates some AWS service events (not services)
- S3, Kinesis, DynamoDB, Cloudwatch, Scheduled Event, API GW
- Runs API Gateway locally
- Allows debugging on local
- https://github.com/awslabs/aws-sam-local
49
LocalStack
- Spins up the many core Cloud APIs on your local
- Lambda, API GW, DynamoDB, Kinesis, Firehose, S3, SNS, SQS, ...
- Supports error injection
- ProvisionedThroughputExceededException, ...
- Can be run on docker
- Integrated with some test frameworks
- JUnit for Java
- nosetests for Python
- https://github.com/localstack/localstack
50
Deployment
51
Tools
- Serverless
- SAM (Serverless Application Model)
- APEX
- Zappa
- Sparta
52
Versioning
- Each deploy/upload is a new version
- Aliases map to versions
- There is N:1 relation
- An alias can only be mapped to only one version
- A version can be mapped by multiple aliases
- By default latest version (“$LATEST”) is invoked
- Shift traffic using aliases with weighted versions
53
New Version Release
v1
prod
Alias Mapping
Alias Version
prod v1
54
New Version Release
v1
prod
Alias Mapping
Alias Version
prod v1
v2
55
New Version Release
v1
prod
Alias Mapping
Alias Version
prod v2
v2
56
Canary Deployment
Alias Mapping
Alias Version
prod v1v1
prod
app
57
Canary Deployment
Alias Mapping
Alias Version
prod v1v1
prod
app
v2
58
Canary Deployment
Alias Mapping
Alias Version
prod v1
prod2 v2
v1
prod
app
v2
59
Canary Deployment
Alias Mapping
Alias Version
prod v1
prod2 v2
v1
prod
app
v2
app2
prod2
60
Canary Deployment
Alias Mapping
Alias Version
prod v1
prod2 v2
v1
app
v2
app2
prod2
61
Canary Deployment
Alias Mapping
Alias Version
prod2 v2
v2
app2
prod2
62
Performance
&
Cold Start
63
What Does Affect Cold Start?
- Depends on language
- Java and C# has more cold start overhead
- Depends on code size
- Smaller artifact size = less cold start (not significantly)
- Depends on memory size
- More memory = less cold start
- Depends on network configuration
- VPC has more cold start overhead (because of ENI)
- SSL handshake has more cold start overhead
- Depends on application and 3rd party libs 64
Cold start times by language + memory
read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
65
Response times by language
read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76
Average response time
Maximum response time
66
Cold Start on JVM
- Loading and initializing
- Application classes
- Core JDK classes
- Security (SSL, encryption, …) related JDK classes
- Initializing 3rd party libraries/frameworks
- AWS SDK
- Spring, Jackson, ...
67
How to Startup Faster on JVM? [1]
- Enable CDS (Class Data Sharing)
- -Xshare:on
- Already enabled by AWS Lambda
- Enable AppCDS (Application Class Data Sharing)
- -XX:+UseAppCDS -XX:SharedArchiveFile=hello.jsa
- For OpenJDK only available at Java 9 :(
- Use AOT (Ahead of Time Compilation)
- Build custom runtime image with “jlink”
- Only available at Java 9 :(
68
How to Startup Faster on JVM? [2]
- Use Tiered Compilation
- Tiered compilation is disabled on AWS Lambda
- -XX:+TieredCompilation -XX:TieredStopAtLevel=1
- Disable bytecode verification
- -Xverify:none
- No classpath scan
- Prefer programmatic or XML configuration for Spring
- Prefer lightweight libraries if possible
- Spring => Guava, Dagger, ...
- Jackson => Gson, ...
69
Warmup
- Periodically send empty messages
- So AWS Lambda might think that container is active
- Not perfect solution for cold start
- AWS’s new experimental container pre-initializer
- How to keep multiple containers up?
- https://github.com/opsgenie/sirocco
70
Lambda @ OpsGenie
71
Incident Management
On
Lambda
72
73
74
Lambda Monitoring
75
76
Data Replication
77
78
&
Thanks
79

Contenu connexe

Tendances

Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembBuilding a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembStreamNative
 
Strata London 2018: Multi-everything with Apache Pulsar
Strata London 2018:  Multi-everything with Apache PulsarStrata London 2018:  Multi-everything with Apache Pulsar
Strata London 2018: Multi-everything with Apache PulsarStreamlio
 
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...confluent
 
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)Amazon Web Services
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystemconfluent
 
Stream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStreamlio
 
(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests
(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests
(GAM402) Turbine: A Microservice Approach to 3 Billion Game RequestsAmazon Web Services
 
The best of Apache Kafka Architecture
The best of Apache Kafka ArchitectureThe best of Apache Kafka Architecture
The best of Apache Kafka Architecturetechmaddy
 
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUANatan Silnitsky
 
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)Amazon Web Services
 
Scaling customer engagement with apache pulsar
Scaling customer engagement with apache pulsarScaling customer engagement with apache pulsar
Scaling customer engagement with apache pulsarStreamNative
 
Netflix Container Runtime - Titus - for Container Camp 2016
Netflix Container Runtime - Titus - for Container Camp 2016Netflix Container Runtime - Titus - for Container Camp 2016
Netflix Container Runtime - Titus - for Container Camp 2016aspyker
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSAmazon Web Services
 
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARN
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARNKafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARN
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARNDataWorks Summit
 
Livy: A REST Web Service For Apache Spark
Livy: A REST Web Service For Apache SparkLivy: A REST Web Service For Apache Spark
Livy: A REST Web Service For Apache SparkJen Aman
 
AWS BaseCamp: AWS Architecture Fundamentals
AWS BaseCamp: AWS  Architecture FundamentalsAWS BaseCamp: AWS  Architecture Fundamentals
AWS BaseCamp: AWS Architecture FundamentalsNicole Maus
 
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...confluent
 
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker ContainersKafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containersconfluent
 
DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureAntons Kranga
 

Tendances (20)

Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre ZembBuilding a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
Building a Messaging Solutions for OVHcloud with Apache Pulsar_Pierre Zemb
 
Strata London 2018: Multi-everything with Apache Pulsar
Strata London 2018:  Multi-everything with Apache PulsarStrata London 2018:  Multi-everything with Apache Pulsar
Strata London 2018: Multi-everything with Apache Pulsar
 
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...
KSQL and Security: The Current State of Affairs (Victoria Xia, Confluent) Kaf...
 
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)
AWS re:Invent 2016: ↑↑↓↓←→←→ BA Lambda Start (SVR305)
 
Building Out Your Kafka Developer CDC Ecosystem
Building Out Your Kafka Developer CDC  EcosystemBuilding Out Your Kafka Developer CDC  Ecosystem
Building Out Your Kafka Developer CDC Ecosystem
 
Stream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar FunctionsStream-Native Processing with Pulsar Functions
Stream-Native Processing with Pulsar Functions
 
(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests
(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests
(GAM402) Turbine: A Microservice Approach to 3 Billion Game Requests
 
The best of Apache Kafka Architecture
The best of Apache Kafka ArchitectureThe best of Apache Kafka Architecture
The best of Apache Kafka Architecture
 
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
10 Lessons Learned from using Kafka in 1000 microservices - ScalaUA
 
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
AWS re:Invent 2016: Development Workflow with Docker and Amazon ECS (CON302)
 
Scaling customer engagement with apache pulsar
Scaling customer engagement with apache pulsarScaling customer engagement with apache pulsar
Scaling customer engagement with apache pulsar
 
Netflix Container Runtime - Titus - for Container Camp 2016
Netflix Container Runtime - Titus - for Container Camp 2016Netflix Container Runtime - Titus - for Container Camp 2016
Netflix Container Runtime - Titus - for Container Camp 2016
 
Continuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECSContinuous Delivery with Docker and Amazon ECS
Continuous Delivery with Docker and Amazon ECS
 
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARN
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARNKafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARN
Kafka On YARN (KOYA): An Open Source Initiative to integrate Kafka & YARN
 
Livy: A REST Web Service For Apache Spark
Livy: A REST Web Service For Apache SparkLivy: A REST Web Service For Apache Spark
Livy: A REST Web Service For Apache Spark
 
AWS BaseCamp: AWS Architecture Fundamentals
AWS BaseCamp: AWS  Architecture FundamentalsAWS BaseCamp: AWS  Architecture Fundamentals
AWS BaseCamp: AWS Architecture Fundamentals
 
Apache Kafka Security
Apache Kafka Security Apache Kafka Security
Apache Kafka Security
 
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
Show Me Kafka Tools That Will Increase My Productivity! (Stephane Maarek, Dat...
 
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker ContainersKafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
Kafka Summit SF 2017 - Best Practices for Running Kafka on Docker Containers
 
DevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless ArchitectureDevOps Days Tel Aviv - Serverless Architecture
DevOps Days Tel Aviv - Serverless Architecture
 

Similaire à Flying Server-less on the Cloud with AWS Lambda

SoCal NodeJS Meetup 20170215_aws_lambda
SoCal NodeJS Meetup 20170215_aws_lambdaSoCal NodeJS Meetup 20170215_aws_lambda
SoCal NodeJS Meetup 20170215_aws_lambdaStefan Deusch
 
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유Soowan Lee
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasMongoDB
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureMikhail Prudnikov
 
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-endGOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-endIan Massingham
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudIan Massingham
 
Introduction to the Serverless paradigm
Introduction to the Serverless paradigmIntroduction to the Serverless paradigm
Introduction to the Serverless paradigmAlex Casalboni
 
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Amazon Web Services
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingTom Creighton
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudAmazon Web Services
 
Apache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel QuarkusApache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel QuarkusClaus Ibsen
 
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...Claus Ibsen
 
Chalice microframework 101 (eng)
Chalice microframework 101 (eng)Chalice microframework 101 (eng)
Chalice microframework 101 (eng)Maciej Dziergwa
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)Paweł Pikuła
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersAmazon Web Services
 
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018Amazon Web Services Korea
 

Similaire à Flying Server-less on the Cloud with AWS Lambda (20)

SoCal NodeJS Meetup 20170215_aws_lambda
SoCal NodeJS Meetup 20170215_aws_lambdaSoCal NodeJS Meetup 20170215_aws_lambda
SoCal NodeJS Meetup 20170215_aws_lambda
 
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
[AWSKRUG 아키텍처 모임] 세일즈부스트 인프라스트럭처 사례 공유
 
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB AtlasWebinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
Webinar: Serverless Architectures with AWS Lambda and MongoDB Atlas
 
DevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless ArchitectureDevOps, Microservices and Serverless Architecture
DevOps, Microservices and Serverless Architecture
 
AWS Lambda and Serverless Cloud
AWS Lambda and Serverless CloudAWS Lambda and Serverless Cloud
AWS Lambda and Serverless Cloud
 
AWS Lambda Features and Uses
AWS Lambda Features and UsesAWS Lambda Features and Uses
AWS Lambda Features and Uses
 
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-endGOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
GOTO Stockholm - AWS Lambda - Logic in the cloud without a back-end
 
Getting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless CloudGetting Started with AWS Lambda & Serverless Cloud
Getting Started with AWS Lambda & Serverless Cloud
 
Introduction to the Serverless paradigm
Introduction to the Serverless paradigmIntroduction to the Serverless paradigm
Introduction to the Serverless paradigm
 
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
Infrastructure at Scale: Apache Kafka, Twitter Storm & Elastic Search (ARC303...
 
KnativeCon 2022 - Knative Functions
KnativeCon 2022 - Knative FunctionsKnativeCon 2022 - Knative Functions
KnativeCon 2022 - Knative Functions
 
Utah Codecamp Cloud Computing
Utah Codecamp Cloud ComputingUtah Codecamp Cloud Computing
Utah Codecamp Cloud Computing
 
Getting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless CloudGetting Started with AWS Lambda and the Serverless Cloud
Getting Started with AWS Lambda and the Serverless Cloud
 
Apache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel QuarkusApache Camel v3, Camel K and Camel Quarkus
Apache Camel v3, Camel K and Camel Quarkus
 
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
Cloud-Native Integration with Apache Camel on Kubernetes (Copenhagen October ...
 
Chalice microframework 101 (eng)
Chalice microframework 101 (eng)Chalice microframework 101 (eng)
Chalice microframework 101 (eng)
 
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)Serverless cat detector   workshop - cloudyna 2017 (16.12.2017)
Serverless cat detector workshop - cloudyna 2017 (16.12.2017)
 
What's New in AWS Serverless and Containers
What's New in AWS Serverless and ContainersWhat's New in AWS Serverless and Containers
What's New in AWS Serverless and Containers
 
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
게임을 위한 Cloud Native on AWS (김일호 솔루션즈 아키텍트, AWS) :: Gaming on AWS 2018
 
Svc 202-netflix-open-source
Svc 202-netflix-open-sourceSvc 202-netflix-open-source
Svc 202-netflix-open-source
 

Plus de Serkan Özal

Improving performance of decision support queries in columnar cloud database ...
Improving performance of decision support queries in columnar cloud database ...Improving performance of decision support queries in columnar cloud database ...
Improving performance of decision support queries in columnar cloud database ...Serkan Özal
 
JVM Under the Hood
JVM Under the HoodJVM Under the Hood
JVM Under the HoodSerkan Özal
 
Ankara JUG Big Data Presentation
Ankara JUG Big Data PresentationAnkara JUG Big Data Presentation
Ankara JUG Big Data PresentationSerkan Özal
 
AWS EMR - Amazon Elastic Map Reduce
AWS EMR - Amazon Elastic Map ReduceAWS EMR - Amazon Elastic Map Reduce
AWS EMR - Amazon Elastic Map ReduceSerkan Özal
 

Plus de Serkan Özal (7)

MySafe
MySafeMySafe
MySafe
 
Improving performance of decision support queries in columnar cloud database ...
Improving performance of decision support queries in columnar cloud database ...Improving performance of decision support queries in columnar cloud database ...
Improving performance of decision support queries in columnar cloud database ...
 
JVM Under the Hood
JVM Under the HoodJVM Under the Hood
JVM Under the Hood
 
Big data on aws
Big data on awsBig data on aws
Big data on aws
 
Ankara JUG Big Data Presentation
Ankara JUG Big Data PresentationAnkara JUG Big Data Presentation
Ankara JUG Big Data Presentation
 
AWS EMR - Amazon Elastic Map Reduce
AWS EMR - Amazon Elastic Map ReduceAWS EMR - Amazon Elastic Map Reduce
AWS EMR - Amazon Elastic Map Reduce
 
Big data concepts
Big data conceptsBig data concepts
Big data concepts
 

Dernier

Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jNeo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...Bert Jan Schrijver
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonApplitools
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogueitservices996
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecturerahul_net
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shardsChristopher Curtin
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingShane Coughlan
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalLionel Briand
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesVictoriaMetrics
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLionel Briand
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxAndreas Kunz
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldRoberto Pérez Alcolea
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?Alexandre Beguel
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptxVinzoCenzo
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxRTS corp
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorTier1 app
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencessuser9e7c64
 

Dernier (20)

Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4jGraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
GraphSummit Madrid - Product Vision and Roadmap - Luis Salvador Neo4j
 
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
JavaLand 2024 - Going serverless with Quarkus GraalVM native images and AWS L...
 
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + KobitonLeveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
Leveraging AI for Mobile App Testing on Real Devices | Applitools + Kobiton
 
Ronisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited CatalogueRonisha Informatics Private Limited Catalogue
Ronisha Informatics Private Limited Catalogue
 
Understanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM ArchitectureUnderstanding Flamingo - DeepMind's VLM Architecture
Understanding Flamingo - DeepMind's VLM Architecture
 
2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards2024 DevNexus Patterns for Resiliency: Shuffle shards
2024 DevNexus Patterns for Resiliency: Shuffle shards
 
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full RecordingOpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
OpenChain AI Study Group - Europe and Asia Recap - 2024-04-11 - Full Recording
 
Precise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive GoalPrecise and Complete Requirements? An Elusive Goal
Precise and Complete Requirements? An Elusive Goal
 
What’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 UpdatesWhat’s New in VictoriaMetrics: Q1 2024 Updates
What’s New in VictoriaMetrics: Q1 2024 Updates
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Large Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and RepairLarge Language Models for Test Case Evolution and Repair
Large Language Models for Test Case Evolution and Repair
 
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptxUI5ers live - Custom Controls wrapping 3rd-party libs.pptx
UI5ers live - Custom Controls wrapping 3rd-party libs.pptx
 
Keeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository worldKeeping your build tool updated in a multi repository world
Keeping your build tool updated in a multi repository world
 
SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?SAM Training Session - How to use EXCEL ?
SAM Training Session - How to use EXCEL ?
 
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News UpdateVictoriaMetrics Q1 Meet Up '24 - Community & News Update
VictoriaMetrics Q1 Meet Up '24 - Community & News Update
 
Osi security architecture in network.pptx
Osi security architecture in network.pptxOsi security architecture in network.pptx
Osi security architecture in network.pptx
 
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptxReal-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
Real-time Tracking and Monitoring with Cargo Cloud Solutions.pptx
 
Effectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryErrorEffectively Troubleshoot 9 Types of OutOfMemoryError
Effectively Troubleshoot 9 Types of OutOfMemoryError
 
Patterns for automating API delivery. API conference
Patterns for automating API delivery. API conferencePatterns for automating API delivery. API conference
Patterns for automating API delivery. API conference
 

Flying Server-less on the Cloud with AWS Lambda

  • 1. Flying Server-less on the Cloud with AWS Lambda Serkan ÖZAL
  • 2. Who Am I? ● Senior Software Engineer @ OpsGenie ● Co-organizer of Serverless Meetup Turkey ● Oracle Open-Source Contributor ● PhD. Cand. @ METU Computer Eng. ● 8+ years in software development ● Hard-core JVM ninja ● Actively working on Serverless and AWS Lambda ● Part-time Big Data researcher ● Building a new product Thundra 2
  • 4. Agenda ● Road to Serverless ● The Motivation ● Under the Hood ● Integrations ● Limitations ● Logging ● Config Management ● Security ● Error Handling 4
  • 5. 5
  • 6. “If your PaaS can efficiently start instances in 20 ms that run for half a second, then call it serverless.” Adrian Cockcroft, VP Cloud Architecture Strategy at AWS 6
  • 7. What is AWS Lambda? - AWS’s FaaS (Function as a Service) - Run code without provisioning or managing servers - Support invocation types: - Request/response (sync) - Event driven (async) - Supported languages: - Go - C# - Java - Node.js - Python 7
  • 9. Why AWS Lambda? - PAYG - pay as you go - Highly available - Scale fast - Horizontally - Vertically - Don’t manage servers - Built-in integration with other AWS services - Security 9
  • 11. The Devil is in the Detail - Container reuse - Container freeze - More memory => More CPU - One execution per container at any time - At least one delivery guarantee - New container for - new deployments - configuration updates - even for environment variable updates - Destroy container when timeout 11
  • 12. How to Limit Container? - cgroup (Control Group) - Engineers at Google started the work in 2006 - Merged into Linux kernel in January 2008 - Can limit - CPU - Memory - Disk bandwidth - Network bandwidth 12
  • 13. CPU Throttling - cgcreate - cgcreate -g cpu:/cg1 - cgcreate -g cpu:/cg2 - cpu.cfs_quota_us / cpu.cfs_period_us - how to configure cg1 to run 0.2 seconds out of every 1 second? - cgset -r cpu.cfs_quota_us=200000 cpu.cfs_period_us=1000000 cg1 - cpu.shares - how to configure 1:2 CPU usage ratio between cg1 and cg2? - cgset -r cpu.shared=512 cg1 - cgset -r cpu.shared=1024 cg2 - why not used by AWS Lambda? 13
  • 15. Built-in Integrations - Direct - DynamoDB - Kinesis - Firehose - SNS - S3 - API Gateway - CloudWatch Logs - CloudWatch Events - Scheduled - SES - Cognito - CodeCommit - CloudFormation - CloudFront - Config - Alexa - Lex - IoT Button 15
  • 17. Resource Limits Max execution time 5 minutes Memory allocation range 128 MB - 3 GB Ephemeral disk capacity ("/tmp" space) 512 MB Invoke request body payload size (sync invocation) 6 MB Invoke request body payload size (async invocation) 128 K Number of file descriptors 1024 Number of processes and threads (combined total) 1024 17
  • 18. Deployment Limits Function deployment package size (compressed .zip/.jar file) 50 MB Size of code/dependencies that you can zip into a deployment package (uncompressed .zip/.jar size) 250 MB Total size of all the deployment packages per region 75 GB Total size of environment variables set 4 KB 18
  • 19. Execution Limits - Account level concurrent execution limit is 1000 - It per region - It is soft limit - Function level concurrent execution limit - It is reserved - the value is deducted from the unreserved concurrency pool - ENI Limit is 350 - It is for Lambda function in VPC - It is per region - It is soft limit 19
  • 21. Writing Logs - Logs are written to CloudWatch asynchronously - Log group per function - /aws/lambda/my-func - Log stream per container under log group - 2018/01/27/[$LATEST]f95da1aaf0384ed6ad642d8299f7503d - How to log - Standard output/error - Lambda API 21
  • 22. 22
  • 23. Collecting Logs - Subscribe to CloudWatch log groups - Only one subscription per log group - Filter by pattern - Stream to AWS Lambda - Stream to AWS Elasticsearch 23
  • 25. Environment Variables - No limit to the number of env. variables - Max total size is 4 KB - Must start with letters [a-zA-Z] - Can only contain alphanumeric char. and “_” [a-zA-Z0-9_] - KMS - Encrypt at rest (default) - Encrypt in transit 25
  • 26. SSM - Centralized config management - share between functions - update once - Fine-grained access to sensitive data via IAM - Integrates with KMS out-of-the-box - Records a history of changes 26
  • 28. VPC - Define/select VPC and configure - Subnets (recommended one subnet in each AZ) - Security Groups - To be able to access internet - NAT Gateway - Internet Gateway - Route table configuration - Be aware of ENI limit (default 350) - Sure that subnet has enough IP address range for ENI 28
  • 29. Role - Each Lambda function has an associated IAM role - For accessing AWS resources - grant the role the necessary permissions that your Lambda function needs - for ex. permission to Lambda for putting item to DynamoDB table - For non-stream based event sources - grant the event source permissions to invoke function - for ex. perm. to S3 bucket for invoking Lambda on upload - For stream based event sources - grant AWS Lambda permissions for the relevant stream actions - for ex. perm. to Lambda for getting Kinesis stream records to be invoked 29
  • 30. Others - Inbound connections are blocked - For outbound connections only TCP/IP sockets are supported - “ptrace” (debugging) system calls are blocked - TCP port 25 is also blocked as an anti-spam measure 30
  • 32. Retries - For sync invocations (Lambda API call, …) - client is responsible for retries - For async invocations - Non-Stream based events (S3, SNS, CloudWatch, …) - retry a few times (2 or more) with delays - If still fails, put in to DLQ (if specified= - Stream based events (Kinesis , DynamoDB streams) - retry until succeeded or - retry until data expires 32
  • 33. DLQ - Dead Letter Queue - Can be - SNS topic - SQS queue - Requests are redirected if the invocation is - Asynchronous and - Event source is non-stream based (S3, SNS, …) - Requires permission to access to the DLQ resource - Monitor “DeadLetterErrors” metrics 33
  • 35. Agenda ● Monitoring ● Alerting ● Testing ● Deployment ● Performance & Cold Start ● AWS Lambda @ OpsGenie 35
  • 37. CloudWatch Metrics - Following metrics are supported per function basis: - Invocation - Errors - Duration - Dead Letter Error - Throttles - Iterator Age - Following metrics are supported across all functions: - Concurrent Executions - Unreserved Concurrent Executions 37
  • 38. Distributed Tracing with AWS X-Ray - Shows durations, responses and errors - Segment for Lambda invocation - Sub-Segments for - initialization - calls to external services - custom ones - Custom properties - can be queried over “Annotation” - can be stored on “Metadata” as raw 38
  • 39. 39
  • 40. 40
  • 41. API Logging with CloudTrail - CloudTrail can log - function definition/configuration CRUD - function invocations - log entry contains information about - who generated the request - the requested action - the action parameters - ... - CloudTrail logs can be published to - S3 - SNS 41
  • 42. Full Observability with Thundra - Provides three pillars of observability: - Trace - Metric - Log - Zero overhead with async data publishing - Has automated instrumentation and profiling support - Integrated with AWS X-Ray - www.thundra.io 42
  • 43. 43
  • 44. 44
  • 46. Creating Alarm - Create alarm on CloudWatch by metrics - Following metrics are supported per function basis: - Following metrics are supported across all functions: - Concurrent Executions - Unreserved Concurrent Executions - Notify through SNS - E-Mail - Lambda - ... - Duration - Errors - Invocations - Throttles 46
  • 48. Writing Test - Unit Test - do our objects works as expected themselves? - Integration Test - does our objects work well together? - Functional Test - does the whole system work from end to end? - Local Lambda development - SAM Local - LocalStack - Cloud9 48
  • 49. SAM Local - Works with SAM template - Simulates some AWS service events (not services) - S3, Kinesis, DynamoDB, Cloudwatch, Scheduled Event, API GW - Runs API Gateway locally - Allows debugging on local - https://github.com/awslabs/aws-sam-local 49
  • 50. LocalStack - Spins up the many core Cloud APIs on your local - Lambda, API GW, DynamoDB, Kinesis, Firehose, S3, SNS, SQS, ... - Supports error injection - ProvisionedThroughputExceededException, ... - Can be run on docker - Integrated with some test frameworks - JUnit for Java - nosetests for Python - https://github.com/localstack/localstack 50
  • 52. Tools - Serverless - SAM (Serverless Application Model) - APEX - Zappa - Sparta 52
  • 53. Versioning - Each deploy/upload is a new version - Aliases map to versions - There is N:1 relation - An alias can only be mapped to only one version - A version can be mapped by multiple aliases - By default latest version (“$LATEST”) is invoked - Shift traffic using aliases with weighted versions 53
  • 54. New Version Release v1 prod Alias Mapping Alias Version prod v1 54
  • 55. New Version Release v1 prod Alias Mapping Alias Version prod v1 v2 55
  • 56. New Version Release v1 prod Alias Mapping Alias Version prod v2 v2 56
  • 57. Canary Deployment Alias Mapping Alias Version prod v1v1 prod app 57
  • 58. Canary Deployment Alias Mapping Alias Version prod v1v1 prod app v2 58
  • 59. Canary Deployment Alias Mapping Alias Version prod v1 prod2 v2 v1 prod app v2 59
  • 60. Canary Deployment Alias Mapping Alias Version prod v1 prod2 v2 v1 prod app v2 app2 prod2 60
  • 61. Canary Deployment Alias Mapping Alias Version prod v1 prod2 v2 v1 app v2 app2 prod2 61
  • 62. Canary Deployment Alias Mapping Alias Version prod2 v2 v2 app2 prod2 62
  • 64. What Does Affect Cold Start? - Depends on language - Java and C# has more cold start overhead - Depends on code size - Smaller artifact size = less cold start (not significantly) - Depends on memory size - More memory = less cold start - Depends on network configuration - VPC has more cold start overhead (because of ENI) - SSL handshake has more cold start overhead - Depends on application and 3rd party libs 64
  • 65. Cold start times by language + memory read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76 65
  • 66. Response times by language read.acloud.guru/does-coding-language-memory-or-package-size-affect-cold-starts-of-aws-lambda-a15e26d12c76 Average response time Maximum response time 66
  • 67. Cold Start on JVM - Loading and initializing - Application classes - Core JDK classes - Security (SSL, encryption, …) related JDK classes - Initializing 3rd party libraries/frameworks - AWS SDK - Spring, Jackson, ... 67
  • 68. How to Startup Faster on JVM? [1] - Enable CDS (Class Data Sharing) - -Xshare:on - Already enabled by AWS Lambda - Enable AppCDS (Application Class Data Sharing) - -XX:+UseAppCDS -XX:SharedArchiveFile=hello.jsa - For OpenJDK only available at Java 9 :( - Use AOT (Ahead of Time Compilation) - Build custom runtime image with “jlink” - Only available at Java 9 :( 68
  • 69. How to Startup Faster on JVM? [2] - Use Tiered Compilation - Tiered compilation is disabled on AWS Lambda - -XX:+TieredCompilation -XX:TieredStopAtLevel=1 - Disable bytecode verification - -Xverify:none - No classpath scan - Prefer programmatic or XML configuration for Spring - Prefer lightweight libraries if possible - Spring => Guava, Dagger, ... - Jackson => Gson, ... 69
  • 70. Warmup - Periodically send empty messages - So AWS Lambda might think that container is active - Not perfect solution for cold start - AWS’s new experimental container pre-initializer - How to keep multiple containers up? - https://github.com/opsgenie/sirocco 70
  • 73. 73
  • 74. 74
  • 76. 76
  • 78. 78