Contenu connexe Similaire à Serverless Patterns (20) Plus de Cliff Chao-kuan Lu (10) Serverless Patterns2. Cliff Chao-kuan Lu
•Sr. Architect @ 104 Corp.
•AWS Community Hero
•Organizer, AWS User GroupTaiwan
•Certified AWS ALL-5
•Loves Cloud Computing
5. Lambda ECS
Function-as-a-Service Docker Scheduler
Infrastructure Managed EC2 Instances
Housekeeping Concurrency
Auto Scaling
Healthcheck
Reservation / Spot
Access Control IAM / VPC
Monitoring Cloudwatch / Cloudwatch Logs
vs.
7. Cost Comparison
•t2.nano: $0.008
•Lambda – 128 mb / 100 ms:
•36000 Calls – $0.0072
•450 GB-s – $0.0075
•Managed service = Highly available + Scalable
* 2 (scaling factor)
* 0.25 (Spot)
* 0.7 (RI)
/ 5% (CPU Credit)
9. Lambda Runtime Limits
•Time
• Max timeout = 300 s*
•Environment
• Max RAM = 1,536 MB
• Max Storage = 500 MB**
•Payload: 6 MB
•Concurrency: 100 600 (per account-region)
10. Lambda Event Source and Retry
•Stream-based Source
•Synchronous invocation
•Asynchronous invocation
11. Lambda Event Source
•Stream-based Source
•Kinesis, DynamoDB Stream
•Others
•Synchronous invocation
• API Gateway, SDK
•Asynchronous invocation
• Cloudwatch Events
13. Lambda Retry on Error
•Stream-based Source
•Cursor-based reads, spontaneous retry
•Synchronous invocation
•Client retry
•Asynchronous invocation
•Retry twice -> DLQ {SQS, SNS}
20. Crontab
•CloudWatch Event: Schedule
•Minimal interval: 1min
cron(fields)
Minutes 0-59 , - * /
Hours 0-23 , - * /
Day-of-month 1-31 , - * ? / L W
Month 1-12 or JAN-DEC , - * /
Day-of-week 1-7 or SUN-SAT , - * ? / L
Year 1970-2199 , - * /
26. Event-Driven
•Base of all patterns
•Triggered by CloudWatch Events
•Supports EBS, EC2, EMR,AutoScaling, CodeDeploy,
Console Sign-in, Health, KMS,Trusted Advisor, …
•`PutEvent`
37. Gotcha
•Lambda scales. How about your resources?
•Connection pool
•EC2-based resources that scales much slower
•Throttle, queue, and retry
40. Gotcha
•How do I know if I’m throttled?
•Feature request:
Per-function concurrency cap!
43. Take Home Message
•Lambda is a glue service
•Event-driven and streaming
•Public endpoint <->VPC / EC2
•The only limit is your imagination
Notes de l'éditeur PaaS: Automation, Elasticity, Monitoring, Network, Scalability according to NIST Defn Lambda
Request: $2E-7 calls
Duration: $1.667E-5 / GB-s
Workarounds: Divide and conquer
* InvokeAsync or Step Function
** Pack static files with function
Pattern 之間不互斥
最基本的模式,one-off jobs
Cron 的寫法與 crontab 稍有不同,DoM 與 DoW 互斥,提供一者時,另外一項要寫 ? Pattern 之間不互斥
Pattern 之間不互斥
Poll interval: 1s
1 process per shard Pattern 之間不互斥
透過 Schedule 觸發,可自定 Interval 與輸出資料量;但仍有 透過 Schedule 觸發,可自定 Interval 與輸出資料量;但仍有 Black belt question. Especially after deploying new versions.
* A-B Deploy: leverage container reuse