SlideShare a Scribd company logo
淺談
SERVERLESS
Focusing on AWS Lambda
No server is easier to
manage than no server.
Werner Vogels
http://martinfowler.com/articles/serverless.html
https://youtu.be/U8ODkSCJpJU?t=240
AWS Lambda
什麼是 Serverless ? 什麼是 Lambda ?
▸Serverless can also mean applications where some amount
of server-side logic is still written by the application
developer but unlike traditional architectures is run in
stateless compute containers that are event-triggered,
ephemeral (may only last for one invocation)
▸AWS Lambda is a compute service that lets you run code
without provisioning or managing servers
http://martinfowler.com/articles/serverless.html
现在的微服务架构是
container 级别的。lambda把
这个粒度做到function级别了
阳衡锋
文字
https://www.zhihu.com/question/29490143
Let's Talk About Serverless - Focusing on AWS Lambda
Let's Talk About Serverless - Focusing on AWS Lambda
Let's Talk About Serverless - Focusing on AWS Lambda
Event handler 內的兩個參數
▸Event
▸Trigger lambda 的 event 來源
▸s3, sns, API gateway, DynamoDB…etc.
▸Context
▸跟 Lambda service 溝通可拿到的 runtime information
▸AWS 停掉 function 前剩餘的時間
▸Cloudwatch log group and log stream
▸觸發 function 執行的 requestID (可用來查詢 Support)
▸AWS mobile SDK 可以拿到 mobile 的資訊
DEMO
01-HelloWorld-Lambda
文字
Lambda 的限制 1/3
▸必須設計成 stateless
▸有最大memory限制
▸有最大執行時間限制
文字
Lambda 的限制 2/3
文字
Lambda 的限制 3/3
Lambda 到底是怎麼搞的?
▸每個 function 在獨立 container sandbox 中執行,resource,
configuration 與其他 function 分開
▸Lambda Container Reuse (freeze-thaw cycle)
▸Lambda Host 在運行 Function 時,會重覆利用 Container
;Container 若正常結束,Lambda 會保存當下狀態
(freeze) 備日後復用
▸Function 再次執行時,若該 Frozen Container 仍然可用,
Lambda 會重新啟動 (thaw) 並執行 handler,無需再初始化
https://aws.amazon.com/tw/blogs/compute/container-reuse-in-lambda/
Lambda 到底是怎麼搞的?
▸對岸神人自幹 Lambda
▸Lambda Docker
▸Docker + Swarm
▸event-driven code runtime like AWS Lambda service
▸https://github.com/tobegit3hub/lambda-docker
Retries on Errors
▸Lambda fail 的三種原因
▸Times out
▸Fails to parse input data
▸Reaches resource constraints: memory, other timeout
▸Retry
▸Non-stream-based event source
▸SYNC: invoking application receive 429 error
▸ASYNC: DLQ (Dead Letter Queue) 沒設定 event 會被 discard
▸Stream-based even source
▸Kinesis, DynamoDB
▸lambda 會持續 retry 拉資料直到 data expired,為了確保 order 會是 blocking 狀態
(不會繼續讀新資料直到 failed batch 成功做完或 expired)
Avoid Chaos
▸Lambda version control
▸stage variable
▸良好且固定的 naming rule
▸加上 prefix,參考
arn 命名規則
▸使用 deployment tool
▸aws cli
▸cloudformation
▸serverless framework: serverless, Apex…etc
▸Orchestration生態尚未成熟,需暫時自己手刻
API Gateway Lambda FQDN
/prod/Resources auth:stable https://api.diamond
/dev/Resources auth:$LATEST
https://api-
dev.diamond
/qa/Resources auth:qa
https://api-
qa.diamond
DEMO
02-HelloWorld-APIGW-Lambda
JAWS Serverless
各種 Use case
▸使用者註冊 : API GW + Lambda + DynamoDB + SES
▸使用者認證 : API GW + Lambda + Cognito/IAM
▸RESTful API : API GW + Lambda
▸各種 event-driven 使用 lambda
▸Static website hosting : Cloudfront + S3 + Lambda
▸Log parsing/monitoring : Cloudwatch + Lambda
▸Data Analyzing : Kinesis + Lambda
DEMO
03-Rate-Based blacklisting with
AWS WAF and Lambda
SCENARIO
Without AWS WAF
Web server
User
Attacker
SCENARIO
With AWS WAF
Web server
User
Attacker
Let's Talk About Serverless - Focusing on AWS Lambda
Block request
Pros & Cons
▸Cost could be reduced
▸Demand based 的計價方式更適合 bursty traffic 類型
▸Scale 更容易
▸更容易 maintain 每個 component
▸Cost could be increased
▸在 design 的時候就必須有拆分小 service 的 overhead
▸Local development and unit testing 不容易
▸realtime end-to-end testing
▸docker-lambda (很像 AWS lambda 環境的 docker image, test runners)
文字
以 Nebula 舉個例子
▸可以將 task 拆分為兩大類
▸event-driven: security event, user-triggered event, scan result
reporting…etc.
▸periodical event: profile pulling, HW health reporting, daily scan
reporting…etc.
▸拆開以後 (decoupled)
▸easier to deploy
▸easier to try new things
▸降低 long-run EC2 instance 的規格
ONE
MORE
THING
AWS STEP FUNCTIONS

More Related Content

What's hot (11)

PDF
AWS Serverless Introduction (Lambda)
Ashish Kushwaha
 
PDF
AWS Lambda Containers - bridging the gap between serverless and containers on...
Yun Zhi Lin
 
PPTX
Serverless Architecture
Michał Kurzeja
 
PPTX
Serverless Architecture
Elana Krasner
 
PDF
Serverless presentation
jasonsich
 
PPTX
Using AWS Lambda for Infrastructure Automation and Beyond
SoftServe
 
PPTX
Serverless Architecture
Saul Caganoff
 
PDF
Serverless computing
Om Vikram Thapa
 
PDF
Getting Started with Amazon EventBridge
Srushith Repakula
 
PDF
Serverless computing with AWS Lambda
Apigee | Google Cloud
 
PDF
AWS Lambda
Danilo Poccia
 
AWS Serverless Introduction (Lambda)
Ashish Kushwaha
 
AWS Lambda Containers - bridging the gap between serverless and containers on...
Yun Zhi Lin
 
Serverless Architecture
Michał Kurzeja
 
Serverless Architecture
Elana Krasner
 
Serverless presentation
jasonsich
 
Using AWS Lambda for Infrastructure Automation and Beyond
SoftServe
 
Serverless Architecture
Saul Caganoff
 
Serverless computing
Om Vikram Thapa
 
Getting Started with Amazon EventBridge
Srushith Repakula
 
Serverless computing with AWS Lambda
Apigee | Google Cloud
 
AWS Lambda
Danilo Poccia
 

Similar to Let's Talk About Serverless - Focusing on AWS Lambda (20)

PDF
Serverless architecture with AWS Lambda (June 2016)
Julien SIMON
 
PDF
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
it-people
 
PDF
Python in the Serverless Era (PyCon IL 2016)
Benny Bauer
 
PPTX
Going Serverless with AWS Lambda at ReportGarden
Jay Gandhi
 
PDF
Introduciendo Serverless en Proyectos Python
Carlos Hernando
 
PDF
Lambda local - A local server for developing AWS Lambda function in Java
Yenwen Feng
 
PDF
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
AWS Chicago
 
PDF
Čtvrtkon #64 - AWS Serverless - Michal Haták
Ctvrtkoncz
 
PDF
Building serverless applications (April 2018)
Julien SIMON
 
PDF
AWS Serverless Workshop
Mikael Puittinen
 
PDF
What can you do with lambda in 2020
Yan Cui
 
PPTX
Mainframe to Serverless Architectures
Maksim Djackov
 
PDF
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PDF
Microservices with AWS Lambda and the Serverless Framework
Rowell Belen
 
PDF
Origins of Serverless
Andrii Soldatenko
 
PPTX
Auto Retweets Using AWS Lambda
CodeOps Technologies LLP
 
PPTX
Scheduled Retweets Using AWS Lambda
Srushith Repakula
 
PDF
AWS Lambda with Serverless Framework and Java
Manish Pandit
 
PDF
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PDF
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Serverless architecture with AWS Lambda (June 2016)
Julien SIMON
 
«Что такое serverless-архитектура и как с ней жить?» Николай Марков, Aligned ...
it-people
 
Python in the Serverless Era (PyCon IL 2016)
Benny Bauer
 
Going Serverless with AWS Lambda at ReportGarden
Jay Gandhi
 
Introduciendo Serverless en Proyectos Python
Carlos Hernando
 
Lambda local - A local server for developing AWS Lambda function in Java
Yenwen Feng
 
Serverless Framework Workshop - Tyler Hendrickson, Chicago/burbs
AWS Chicago
 
Čtvrtkon #64 - AWS Serverless - Michal Haták
Ctvrtkoncz
 
Building serverless applications (April 2018)
Julien SIMON
 
AWS Serverless Workshop
Mikael Puittinen
 
What can you do with lambda in 2020
Yan Cui
 
Mainframe to Serverless Architectures
Maksim Djackov
 
Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Microservices with AWS Lambda and the Serverless Framework
Rowell Belen
 
Origins of Serverless
Andrii Soldatenko
 
Auto Retweets Using AWS Lambda
CodeOps Technologies LLP
 
Scheduled Retweets Using AWS Lambda
Srushith Repakula
 
AWS Lambda with Serverless Framework and Java
Manish Pandit
 
PyConIT 2018 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
PyConIE 2017 Writing and deploying serverless python applications
Cesar Cardenas Desales
 
Ad

More from Okis Chuang (7)

PDF
Make Your Own IoT Device by ZigBee
Okis Chuang
 
PPTX
Introduction to HTTP/2
Okis Chuang
 
PPTX
Connected vehicle in_serverless_architecture
Okis Chuang
 
PPTX
Neural Network Basics
Okis Chuang
 
PPTX
Microservice - Data Management
Okis Chuang
 
PPTX
Oh K8s Is Swag - Kubernetes Basics
Okis Chuang
 
PPTX
Experiences sharing about Lambda, Kinesis, and Postgresql
Okis Chuang
 
Make Your Own IoT Device by ZigBee
Okis Chuang
 
Introduction to HTTP/2
Okis Chuang
 
Connected vehicle in_serverless_architecture
Okis Chuang
 
Neural Network Basics
Okis Chuang
 
Microservice - Data Management
Okis Chuang
 
Oh K8s Is Swag - Kubernetes Basics
Okis Chuang
 
Experiences sharing about Lambda, Kinesis, and Postgresql
Okis Chuang
 
Ad

Recently uploaded (20)

PPTX
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
PDF
Zilliz Cloud Demo for performance and scale
Zilliz
 
PDF
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PPTX
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PDF
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
PDF
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
PPTX
Thermal runway and thermal stability.pptx
godow93766
 
PPTX
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
PPTX
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPT
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PPTX
Big Data and Data Science hype .pptx
SUNEEL37
 
MATLAB : Introduction , Features , Display Windows, Syntax, Operators, Graph...
Amity University, Patna
 
Zilliz Cloud Demo for performance and scale
Zilliz
 
Halide Perovskites’ Multifunctional Properties: Coordination Engineering, Coo...
TaameBerhe2
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Product Development & DevelopmentLecture02.pptx
zeeshanwazir2
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Water Industry Process Automation & Control Monthly July 2025
Water Industry Process Automation & Control
 
MAD Unit - 2 Activity and Fragment Management in Android (Diploma IT)
JappanMavani
 
Thermal runway and thermal stability.pptx
godow93766
 
Element 11. ELECTRICITY safety and hazards
merrandomohandas
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
Heart Bleed Bug - A case study (Course: Cryptography and Network Security)
Adri Jovin
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPT2_Metal formingMECHANICALENGINEEIRNG .ppt
Praveen Kumar
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
Big Data and Data Science hype .pptx
SUNEEL37
 

Let's Talk About Serverless - Focusing on AWS Lambda

Editor's Notes

  • #4: 3-tier v.s. micro-services (serverless)
  • #13: 这些限制要求你把每个lambda函数设计得尽可能简单,一次只做一件事,但把它做到最好。很符合unix的哲学。反过来,这些限制强迫你接受极简主义之外,为你带来了无限扩容的好处。
  • #14: 这些限制要求你把每个lambda函数设计得尽可能简单,一次只做一件事,但把它做到最好。很符合unix的哲学。反过来,这些限制强迫你接受极简主义之外,为你带来了无限扩容的好处。
  • #15: 这些限制要求你把每个lambda函数设计得尽可能简单,一次只做一件事,但把它做到最好。很符合unix的哲学。反过来,这些限制强迫你接受极简主义之外,为你带来了无限扩容的好处。
  • #18: Therefore, if a Lambda function fails, AWS Lambda attempts to process the erring batch of records until the time the data expires, which can be up to seven days for Amazon Kinesis Streams.
  • #23: idea is raised from diamond au package cdn