Slide 1

Slide 1 text

NTT Tech Conference 2024 祝10周年! AWS Lambdaのトレンドを 5分で見る 2024-03-11

Slide 2

Slide 2 text

自己紹介 渡邉 洋平(watany) ● NTTテクノクロス株式会社 ● JAWS-UG東京 運営 ● Japan AWS Top Engineer 2023

Slide 3

Slide 3 text

Disclaimer ● Framework・Javascriptに偏ったネタが多い ○ HonoのContributorなので ● Hono? ○ Cloudflare Workersでも、AWS Lambdaでも動く Webフレームワーク ○ Express的に書けるし、組み込みのjsxやcssで柔 軟にレスポンスを返せる https://hono.dev/

Slide 4

Slide 4 text

最近の AWS Lambda 1. Function URLs 2. Response Streaming 3. Lambda Web Adaptor 4. LLRT(Beta)

Slide 5

Slide 5 text

最近の AWS Lambda 1. Function URLs 2. Response Streaming 3. Lambda Web Adaptor 4. LLRT(Beta)

Slide 6

Slide 6 text

1. Function URLs Built-in HTTPS Endpoints = 脱API Gateway ● 機能はシンプル ○ IAM Auth, CORS ● 最大900秒駆動 ○ API Gateway は29秒以下 https://aws.amazon.com/jp/blogs/aws/announcing-aws-lambda-function-urls-built-i n-https-endpoints-for-single-function-microservices/

Slide 7

Slide 7 text

Security? ワークアラウンド:CloudFront + WAF + Lambda@Edge https://aws.amazon.com/jp/blogs/compute/protecting-an-aws-lambda-function-url- with-amazon-cloudfront-and-lambdaedge/

Slide 8

Slide 8 text

最近の AWS Lambda 1. Function URLs 2. Response Streaming 3. Lambda Web Adaptor 4. LLRT(Beta)

Slide 9

Slide 9 text

2. Response Streaming ChatGPTでおなじみ「ヌルヌル返るやつ」 - Node.js 14.x ↑ or Custom Runtime - 最大20MB返せる(通常6MB) - 前述のLambda Function URLsで30秒の壁を超える

Slide 10

Slide 10 text

2. Response Streaming 注意)組み込みの独自関数を利用 https://aws.amazon.com/jp/blogs/news/introducing-aws-lambda-response-streaming/

Slide 11

Slide 11 text

※PR 実装前に、私のスライド読むのがおススメ https://speakerdeck.com/watany/aws-lambda-response-streaming-shi-zhuang-qian-nisiritaiyatu

Slide 12

Slide 12 text

最近の AWS Lambda 1. Function URLs 2. Response Streaming 3. Lambda Web Adaptor 4. LLRT(Beta)

Slide 13

Slide 13 text

3. Lambda Web Adaptor LambdaのRequest/Response ⇔ HTTP Request/Response -> 一般的なWebフレームワークがLambdaで動く! https://aws.amazon.com/jp/blogs/compute/using-response-streaming-with-aws-lambda-web-adapter-to-optimize-performance/

Slide 14

Slide 14 text

Detail Rust製で安全かつ高速なExtension ● 性能影響も軽微 ○ 平均レイテンシーは +0.8 ms 程度 ○ p99 でも +4 ms 程度 ● Docker on Lambdaなら1行足すだけ ○ Managed Runtimeだと少し面倒

Slide 15

Slide 15 text

https://aws.amazon.com/jp/builders-flash/202301/lambda-web-adapter/ Architecture

Slide 16

Slide 16 text

最近の AWS Lambda 1. Function URLs 2. Response Streaming 3. Lambda Web Adaptor 4. LLRT(Beta)

Slide 17

Slide 17 text

4. LLRT(Beta) LLRT (Low Latency Runtime) ● QuickJS + Rust ● Node.js互換、WinterJS互換を目指しAWSが開発

Slide 18

Slide 18 text

Node.js(1500ms) https://github.com/awslabs/llrt/tree/main/benchmarks

Slide 19

Slide 19 text

LLRT ( > 100ms) https://github.com/awslabs/llrt/tree/main/benchmarks

Slide 20

Slide 20 text

4. LLRT(Beta) > LLRT offers up to over 10x faster startup and up to 2x overall lower cost compared to other JavaScript runtimes running on AWS Lambda ● つまり ○ ColdStart性能の改善(Go on AWS Lambdaと同等) ○ メモリ使用料(& Cost)改善 ● 2024/3時点でBeta版なので動向を見守る

Slide 21

Slide 21 text

まとめ ● Lambda組み込みのEndpoint、Streaming Response、フレームワーク対 応という流れ ● Monolithでも強力に動くAWS Lambda ○ 右記Blogも参照 ● LLRTの動向によっては 「全部TypeScriptでいいじゃん」 https://zenn.dev/watany/articles/183d40f8e31a45