一直都知道 Yan Cui, 這位很厲害的開發者,曾經在某次的 seminar 聽過他的演講,說的很好的
這次就買他的課程來學習 Lambda best practice
紀錄一下,看的筆記囉

  • 跑 powertune-lambda 的範例
    1
    $ lumigo-cli powertune-lambda -n cup-bound-example -r us-east-1 -s balanced

Tools

Lambda Cold Start

  • CloudWatch 顯示的 “Init Duration”,就是 Clod Start 的時間
    1
    REPORT RequestId: f8ac1208... Init Duration: 48.26 ms   Duration: 237.17 ms   Billed Duration: 300 ms   Memory Size: 128 MB   Max Memory Used: 26 MB
  • 分析 clod start 的範例
    1
    $ lumigo-cli analyze-lambda-cold-starts -r us-west-2 -h 6 -p power-dev-serverless
  • AWS Lambda Cold Start Language Comparisons, 2019 edition

What affects the initialization time

  • memory allocation doesn’t affect initialization time duing cold start
  • it’s faster to load dependencies from a layer
  • unused dependencies don’t add to initialization time
  • only you explicit require matters

評估 cold start 的方式

  • sample
    1
    $ lumigo-cli measure-lambda-cold-starts -r us-west-2 -n function_name -i 100 

Cost

Reference

Comments

2020-03-20