SlideShare a Scribd company logo
1 of 22
AWS
COMMUNI
TY DAY
ISTANBUL
2023
AWS Lambda SnapStart
Goran Opacic
AWS Hero
1
Lambda SnapStart
• Initialize your function during deployment
process
• Make a snapshot of the entire function
space/VM
• Restore on first execution
2
3
Lambda Runtime
LifeCycle
APIGW
SQS
…
VM
SERVE
R
VM
VM
WARM POOL
INIT RUNTIME
EXECUTE LAMBDA
HANDLER CODE
INIT FUNCTION
CALL RUNTIME API / GET
REQUEST PAYLOAD
CALL RUNTIME API / SEND
RESPONSE OR ERROR
VM
X
LOOP
VM
LAMBDA
SERVICE
4
#!/bin/sh
set -euo pipefail
# Initialization - load function handler
source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh"
# Processing
while true
do
HEADERS="$(mktemp)"
# Get an event. The HTTP request will block until one is received
EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-
01/runtime/invocation/next")
# Extract request ID by scraping response headers received above
REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2)
# Run the handler function from the script
RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA")
# Send the response
curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d
"$RESPONSE"
done
BASH RUNTIME
ColdStart
• Rust – Python – NodeJs – Java -
.net
• 100ms - 10 sec – 15 min
• Most affected
• Front facing lamba fns
• Lambda fns in Pipelines
• Spiky workloads
Code Migration / Business Value
SpringBoot,…
5
Java Solutions For ColdStart Problem
• CDS - Class Data Sharing
• Ahead Of Time Compilation - AOT
• Oracle GraalVM
• RedHat Quarkus & Micronaut frameworks
• Coordinated Restore at Checkpoint - CRaC
6
FIRECRACKER VM
SNAPSHOT
Firecracker VM
Snapshot of a full OS VM
Linux CRIU
Checkpoint/Restore In Userspace
7
https://github.com/firecracker-
microvm/firecracker/blob/main/docs/snapshotting/snapsho
t-support.md
8
Snapshot Lifecycle
VM
SERVE
R
VM
VM
WARM POOL
INIT RUNTIME
INIT FUNCTION
VM
CLOUD
FORMATION
STACK DEPLOYMENT
BEFORE CHECKPOINT
SAVE SNAPSHOT
14 DAYS
9
Lambda Runtime
LifeCycle With
Snapstart
APIGW
SQS
…
VM
SERVE
R
VM
VM
WARM POOL
EXECUTE LAMBDA
HANDLER CODE
CALL RUNTIME API / GET
REQUEST PAYLOAD
CALL RUNTIME API / SEND
RESPONSE OR ERROR
VM
X
LOOP
VM
LAMBDA
SERVICE
RESTORE SNAPSHOT
AFTER RESTORE
STREAMING
Results
ColdStart ~ 1-2 seconds
No High Variability
Low energy
10
2 part series by Mike Roberts
• No SnapStart - 4 seconds cold start
• SnapStart without hook-based optimization - 2
seconds cold start
• SnapStart with first pass of hook-based
optimization - 1.2 seconds cold start
11
https://blog.symphonia.io/posts/2023-01-11_snapstart-what-why
• Nuances of hooks
• SnapStart adds about 2 minutes to deployment time at time of writing, so you may not want to use it
in development environments.
6 part series by Vadym Kazulkin
12
https://dev.to/vkazulkin/measuring-java-11-lambda-cold-
starts-with-snapstart-part-1-first-impressions-30a4
Measuring Java 11 Lambda cold starts with SnapStart
Pure Java, Quarkus, Micronaut, SpringBoot
Priming
* Direct Lambda function Invoke with PRIMING
New Stuff / Snapshot hooks
Before Snapshot
• Load Data
• Load Params and Secrets (instead of using ENV)
• Priming / + framework support
• Compile Java ? jbang.dev
• 15 min
After Restore
• Reset: cache expiration
* Coordinated Restore at Checkpoint - CRaC
13
Side effects
• Slower deployment – ~2 min per function
• Stack deployment fails if you have bugs in Init phase
• Snapshot is generated once for every AZ
• Extra LOG keywords and numbers / not comparable
14
15
INIT_REPORT
This record shows duration details for the Init phase, including the duration of any beforeCheckpoint runtime
hooks.
REPORT
Restore Duration: The time it takes for Lambda to restore a snapshot, load the runtime (JVM), and run any
afterRestore runtime hooks.
Billed Restore Duration: The time it takes for Lambda to load the runtime (JVM) and run any afterRestore
hooks. You are not charged for the time it takes to restore a snapshot.
Cold Start = Restore Duration + Duration
Lambda SnapStart / LOG
Not Supported
• provisioned concurrency
• arm64 architecture
• the Lambda Extensions API
• EFS
• X-Ray
• Ephemeral storage up to 512 MB
Presentation Title 16
Problems
• Lambda Versions
• CloudFormation - Two step migration from ARM
• Random number generators
• Network Connections
• LOG numbers don’t match
17
LOG
AWS SnapStart - AWS Community Day Istanbul 2023 18
14 days Snapshot Expiration
• Snapshot of a not used Lambda is deleted
• On first invoke Snapshot creation is initiated
• Takes ~2 minutes to create a snapshot
• Error 500 with info
• S3 Events / connect via SQS
• Different Developer eXperience
19
Community discussion
Why not cold start after 14 days?
Why not Snapshot after first call?
Why don’t you let me pay for my snapshot
storage instead of deleting it?
Why don’t you set SnapStart as default?
Why can’t I decide when the snapshot will be
created?
This is better than GraalVM
Self refreshing lambda?
20
https://youtu.be/nhwgm9J4F9A
Takeaways
• This is just the beginning for SnapStart
• SnapStart eliminates ColdStart just make
sure your workload doesn’t get too cold
• Time of VM snapshots is coming
21
Thank you
22
@goranopacic
Youtube.com/@awsugbelgrade

More Related Content

Similar to AWS SnapStart at Community Day Istanbul 2023

Adopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonAdopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonVadym Kazulkin
 
murakumo Cloud Controller
murakumo Cloud Controllermurakumo Cloud Controller
murakumo Cloud ControllerShingo Kawano
 
Serverless in java Lessons learnt
Serverless in java Lessons learntServerless in java Lessons learnt
Serverless in java Lessons learntKrzysztof Pawlowski
 
Autoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know HowAutoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know Howaragavan
 
Adopting Java for the Serverless world at Serverless Meetup Singapore
Adopting Java for the Serverless world at Serverless Meetup SingaporeAdopting Java for the Serverless world at Serverless Meetup Singapore
Adopting Java for the Serverless world at Serverless Meetup SingaporeVadym Kazulkin
 
Stream Processing using Apache Spark and Apache Kafka
Stream Processing using Apache Spark and Apache KafkaStream Processing using Apache Spark and Apache Kafka
Stream Processing using Apache Spark and Apache KafkaAbhinav Singh
 
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Arthur Berezin
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011Lance Ball
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixDiana Tkachenko
 
Distributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops MeetupDistributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops Meetuparagavan
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationSuresh Kumar
 
Autoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUpAutoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUparagavan
 
Adopting Java for the Serverless world at AWS User Group Pretoria
Adopting Java for the Serverless world at AWS User Group PretoriaAdopting Java for the Serverless world at AWS User Group Pretoria
Adopting Java for the Serverless world at AWS User Group PretoriaVadym Kazulkin
 
Adopting Java for the Serverless world at JUG London
Adopting Java for the Serverless world at  JUG LondonAdopting Java for the Serverless world at  JUG London
Adopting Java for the Serverless world at JUG LondonVadym Kazulkin
 
Flying Server-less on the Cloud with AWS Lambda
Flying Server-less on the Cloud with AWS LambdaFlying Server-less on the Cloud with AWS Lambda
Flying Server-less on the Cloud with AWS LambdaSerkan Özal
 
How to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thriveHow to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thriveNatan Silnitsky
 
Running Spark on Cloud
Running Spark on CloudRunning Spark on Cloud
Running Spark on CloudQubole
 
Spark on Yarn
Spark on YarnSpark on Yarn
Spark on YarnQubole
 

Similar to AWS SnapStart at Community Day Istanbul 2023 (20)

Adopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and BostonAdopting Java for the Serverless world at Serverless Meetup New York and Boston
Adopting Java for the Serverless world at Serverless Meetup New York and Boston
 
murakumo Cloud Controller
murakumo Cloud Controllermurakumo Cloud Controller
murakumo Cloud Controller
 
Serverless in java Lessons learnt
Serverless in java Lessons learntServerless in java Lessons learnt
Serverless in java Lessons learnt
 
Autoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know HowAutoscaled Distributed Automation Expedia Know How
Autoscaled Distributed Automation Expedia Know How
 
Adopting Java for the Serverless world at Serverless Meetup Singapore
Adopting Java for the Serverless world at Serverless Meetup SingaporeAdopting Java for the Serverless world at Serverless Meetup Singapore
Adopting Java for the Serverless world at Serverless Meetup Singapore
 
Serverless computing
Serverless computingServerless computing
Serverless computing
 
Stream Processing using Apache Spark and Apache Kafka
Stream Processing using Apache Spark and Apache KafkaStream Processing using Apache Spark and Apache Kafka
Stream Processing using Apache Spark and Apache Kafka
 
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
Kubernetes vs dockers swarm supporting onap oom on multi-cloud multi-stack en...
 
Where is my scalable API?
Where is my scalable API?Where is my scalable API?
Where is my scalable API?
 
TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011TorqueBox - Ruby Hoedown 2011
TorqueBox - Ruby Hoedown 2011
 
Making Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch FixMaking Spinnaker Go @ Stitch Fix
Making Spinnaker Go @ Stitch Fix
 
Distributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops MeetupDistributed Automation(2018) - London Test Automation in Devops Meetup
Distributed Automation(2018) - London Test Automation in Devops Meetup
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Autoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUpAutoscaled Distributed Automation using AWS at Selenium London MeetUp
Autoscaled Distributed Automation using AWS at Selenium London MeetUp
 
Adopting Java for the Serverless world at AWS User Group Pretoria
Adopting Java for the Serverless world at AWS User Group PretoriaAdopting Java for the Serverless world at AWS User Group Pretoria
Adopting Java for the Serverless world at AWS User Group Pretoria
 
Adopting Java for the Serverless world at JUG London
Adopting Java for the Serverless world at  JUG LondonAdopting Java for the Serverless world at  JUG London
Adopting Java for the Serverless world at JUG London
 
Flying Server-less on the Cloud with AWS Lambda
Flying Server-less on the Cloud with AWS LambdaFlying Server-less on the Cloud with AWS Lambda
Flying Server-less on the Cloud with AWS Lambda
 
How to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thriveHow to build 1000 microservices with Kafka and thrive
How to build 1000 microservices with Kafka and thrive
 
Running Spark on Cloud
Running Spark on CloudRunning Spark on Cloud
Running Spark on Cloud
 
Spark on Yarn
Spark on YarnSpark on Yarn
Spark on Yarn
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsHyundai Motor Group
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter RoadsSnow Chain-Integrated Tire for a Safe Drive on Winter Roads
Snow Chain-Integrated Tire for a Safe Drive on Winter Roads
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

AWS SnapStart at Community Day Istanbul 2023

  • 1. AWS COMMUNI TY DAY ISTANBUL 2023 AWS Lambda SnapStart Goran Opacic AWS Hero 1
  • 2. Lambda SnapStart • Initialize your function during deployment process • Make a snapshot of the entire function space/VM • Restore on first execution 2
  • 3. 3 Lambda Runtime LifeCycle APIGW SQS … VM SERVE R VM VM WARM POOL INIT RUNTIME EXECUTE LAMBDA HANDLER CODE INIT FUNCTION CALL RUNTIME API / GET REQUEST PAYLOAD CALL RUNTIME API / SEND RESPONSE OR ERROR VM X LOOP VM LAMBDA SERVICE
  • 4. 4 #!/bin/sh set -euo pipefail # Initialization - load function handler source $LAMBDA_TASK_ROOT/"$(echo $_HANDLER | cut -d. -f1).sh" # Processing while true do HEADERS="$(mktemp)" # Get an event. The HTTP request will block until one is received EVENT_DATA=$(curl -sS -LD "$HEADERS" -X GET "http://${AWS_LAMBDA_RUNTIME_API}/2018-06- 01/runtime/invocation/next") # Extract request ID by scraping response headers received above REQUEST_ID=$(grep -Fi Lambda-Runtime-Aws-Request-Id "$HEADERS" | tr -d '[:space:]' | cut -d: -f2) # Run the handler function from the script RESPONSE=$($(echo "$_HANDLER" | cut -d. -f2) "$EVENT_DATA") # Send the response curl -X POST "http://${AWS_LAMBDA_RUNTIME_API}/2018-06-01/runtime/invocation/$REQUEST_ID/response" -d "$RESPONSE" done BASH RUNTIME
  • 5. ColdStart • Rust – Python – NodeJs – Java - .net • 100ms - 10 sec – 15 min • Most affected • Front facing lamba fns • Lambda fns in Pipelines • Spiky workloads Code Migration / Business Value SpringBoot,… 5
  • 6. Java Solutions For ColdStart Problem • CDS - Class Data Sharing • Ahead Of Time Compilation - AOT • Oracle GraalVM • RedHat Quarkus & Micronaut frameworks • Coordinated Restore at Checkpoint - CRaC 6
  • 7. FIRECRACKER VM SNAPSHOT Firecracker VM Snapshot of a full OS VM Linux CRIU Checkpoint/Restore In Userspace 7 https://github.com/firecracker- microvm/firecracker/blob/main/docs/snapshotting/snapsho t-support.md
  • 8. 8 Snapshot Lifecycle VM SERVE R VM VM WARM POOL INIT RUNTIME INIT FUNCTION VM CLOUD FORMATION STACK DEPLOYMENT BEFORE CHECKPOINT SAVE SNAPSHOT 14 DAYS
  • 9. 9 Lambda Runtime LifeCycle With Snapstart APIGW SQS … VM SERVE R VM VM WARM POOL EXECUTE LAMBDA HANDLER CODE CALL RUNTIME API / GET REQUEST PAYLOAD CALL RUNTIME API / SEND RESPONSE OR ERROR VM X LOOP VM LAMBDA SERVICE RESTORE SNAPSHOT AFTER RESTORE STREAMING
  • 10. Results ColdStart ~ 1-2 seconds No High Variability Low energy 10
  • 11. 2 part series by Mike Roberts • No SnapStart - 4 seconds cold start • SnapStart without hook-based optimization - 2 seconds cold start • SnapStart with first pass of hook-based optimization - 1.2 seconds cold start 11 https://blog.symphonia.io/posts/2023-01-11_snapstart-what-why • Nuances of hooks • SnapStart adds about 2 minutes to deployment time at time of writing, so you may not want to use it in development environments.
  • 12. 6 part series by Vadym Kazulkin 12 https://dev.to/vkazulkin/measuring-java-11-lambda-cold- starts-with-snapstart-part-1-first-impressions-30a4 Measuring Java 11 Lambda cold starts with SnapStart Pure Java, Quarkus, Micronaut, SpringBoot Priming * Direct Lambda function Invoke with PRIMING
  • 13. New Stuff / Snapshot hooks Before Snapshot • Load Data • Load Params and Secrets (instead of using ENV) • Priming / + framework support • Compile Java ? jbang.dev • 15 min After Restore • Reset: cache expiration * Coordinated Restore at Checkpoint - CRaC 13
  • 14. Side effects • Slower deployment – ~2 min per function • Stack deployment fails if you have bugs in Init phase • Snapshot is generated once for every AZ • Extra LOG keywords and numbers / not comparable 14
  • 15. 15 INIT_REPORT This record shows duration details for the Init phase, including the duration of any beforeCheckpoint runtime hooks. REPORT Restore Duration: The time it takes for Lambda to restore a snapshot, load the runtime (JVM), and run any afterRestore runtime hooks. Billed Restore Duration: The time it takes for Lambda to load the runtime (JVM) and run any afterRestore hooks. You are not charged for the time it takes to restore a snapshot. Cold Start = Restore Duration + Duration Lambda SnapStart / LOG
  • 16. Not Supported • provisioned concurrency • arm64 architecture • the Lambda Extensions API • EFS • X-Ray • Ephemeral storage up to 512 MB Presentation Title 16
  • 17. Problems • Lambda Versions • CloudFormation - Two step migration from ARM • Random number generators • Network Connections • LOG numbers don’t match 17
  • 18. LOG AWS SnapStart - AWS Community Day Istanbul 2023 18
  • 19. 14 days Snapshot Expiration • Snapshot of a not used Lambda is deleted • On first invoke Snapshot creation is initiated • Takes ~2 minutes to create a snapshot • Error 500 with info • S3 Events / connect via SQS • Different Developer eXperience 19
  • 20. Community discussion Why not cold start after 14 days? Why not Snapshot after first call? Why don’t you let me pay for my snapshot storage instead of deleting it? Why don’t you set SnapStart as default? Why can’t I decide when the snapshot will be created? This is better than GraalVM Self refreshing lambda? 20 https://youtu.be/nhwgm9J4F9A
  • 21. Takeaways • This is just the beginning for SnapStart • SnapStart eliminates ColdStart just make sure your workload doesn’t get too cold • Time of VM snapshots is coming 21