Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
新常識! Javascript×AWS Lambdaがアツい!!
Search
watany
June 27, 2024
Technology
3
240
新常識! Javascript×AWS Lambdaがアツい!!
color is クラウドLT大会vol.9 で発表させていただいた内容になります。
https://saison-coloris.connpass.com/event/320707/
watany
June 27, 2024
Tweet
Share
More Decks by watany
See All by watany
Adaptor, Helmet, SSG
watany
0
130
異次元のCloudFormation 拡張コマンド~Rain~
watany
0
130
祝10周年! AWS Lambdaのトレンドを 5分で見る
watany
2
140
なぜAWS向けのFrameworkに携わり続けるのか? ~クラウド時代のOSS活動~
watany
3
840
Hono is now AWS ready
watany
0
230
AWS Lambda response streaming 実装前にしりたいやつ
watany
1
380
Bun & Honoで始めるAmazon Bedrock入門 -完全版-
watany
4
1.2k
Cloudflare Workersたちのいるところ
watany
0
39
Web IDE環境を俺好みに準備するための技術
watany
1
95
Other Decks in Technology
See All in Technology
ビズリーチが目指す「開発生産性」ダッシュボード 〜 データ収集の壁と乗り越え方 〜 / dev-productivity-con2024
visional_engineering_and_design
6
2.2k
マルチエージェントで性能が上がったText-to-SQLのいま/Text-to-SQL
yoshidashingo
2
1.2k
LeanとDevOpsのためにE2Eテストができること
magicpod
2
510
半年かけてPHP5.6からPHP7.4までバージョンアップした苦労と工夫 PHPカンファレンス福岡2024
kechiiin
1
170
楽ありゃ苦もあるモノレポ化 / Goodness and Difficulties of Monorepo
henryofficial
2
710
State of Amazon Location Service
dayjournal
0
160
エムスリーMR君ファミリー開発チーム紹介資料 / Introduction of M3 MRkun Family Dev Team
m3_engineering
0
110
Oracle Modern Data Platform Reference Architecture (Autonomous Data Warehouse編)
oracle4engineer
PRO
0
490
俺的 Four Keys 解釈
tetsuya28
0
190
経営視点から捉えた開発生産性 / Development productivity from a management perspective
kyuns
5
1.2k
Kotlinらしいコードを書こう - Convert Java File to Kotlin File のあとにやること / What to do after Convert Java File to Kotlin File
yanzm
0
1.7k
20240621_フルリモート環境ざっくばらんにご紹介
1210yuichi0
0
310
Featured
See All Featured
Designing on Purpose - Digital PM Summit 2013
jponch
112
6.6k
Building Your Own Lightsaber
phodgson
101
5.8k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.2k
Art, The Web, and Tiny UX
lynnandtonic
290
19k
The World Runs on Bad Software
bkeepers
PRO
62
10k
Rebuilding a faster, lazier Slack
samanthasiow
75
8.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
27
2.1k
The Invisible Customer
myddelton
115
12k
How to Ace a Technical Interview
jacobian
273
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
261
12k
The Straight Up "How To Draw Better" Workshop
denniskardys
228
130k
Web Components: a chance to create the future
zenorocha
307
41k
Transcript
color is クラウドLT大会vol.9 新常識!JavaScript × AWS Lambdaがアツい!! 2024-06-27
自己紹介 • 渡邉 洋平(watany) ◦ NTTテクノクロス株式会社 ◦ JAWS-UG東京 運営 ◦
AWS Ambassadors (associate) • 合同で勉強会できる企業を探しています ◦ Jr. Champion/TopEngineer育成とか ◦ 普通にTechの勉強会とか
今日の目標 • AWS Lambda のJavaScript(TypeScript, Node.js)のトレンドを紹介する ◦ 従来、拘りなくLambdaを書く場合にはPythonがファーストチョイスだった(個人 研究) ◦
バックエンド、インフラでもJavaScript採用で効率化できそうなアップデート群を 紹介 • お詫び ◦ JavaScriptと言いつつ、TypeScript前提で話す
JavaScript × AWS Lambdaの新常識
JavaScript × AWS Lambdaの新常識 1. TypeScript × AWS CDK 2.
LLRT 3. Lambda Web Adaptor 4. Response Streaming
1. TypeScript × AWS CDK • AWS CDKとは? ◦ Framework
for CloudFormation ◦ 概要は右のグラレコが必要十分 • TypeScriptとは? ◦ JavaScriptのSuperset ◦ 強力かつ柔軟な型システム をJavascriptに付与 引用:使い慣れたプログラミング言語でクラウド環境を構築 ! AWS CDK をグラレコで解説 https://aws.amazon.com/jp/builders-flash/202309/awsgeek-aws-cdk/
1. TypeScript × AWS CDK AWS CDKは多言語対応とあるが…? • Toolネイティブ対応は”TypeScript” ◦
Python、GoなどはJsiiが変換して対応(まれにバグを踏む) • 2022年度の利用率は”72%”がJS/TS ◦ 2024年現在の肌感覚でも同様 ◦ JAWS-UG CDK支部も https://matthewbonig.com/posts/community-survey-2022/
1. TypeScript × AWS CDK 「NodejsFunction」でBundle部分をCDKに任せて、TypeScript ファーストのLambda開 発体験
JavaScript × AWS Lambdaの新常識 1. TypeScript × AWS CDK 2.
LLRT 3. Lambda Web Adaptor 4. Response Streaming
2. LLRT LLRT (Low Latency Runtime) • Node.js互換、WinterJS互換を目指し、AWSが開発するJS Runtime ◦
QuickJS + Rust ◦ 注)2024/6時点でBeta版
Cold Start:Node.js(1500ms) https://github.com/awslabs/llrt/tree/main/benchmarks
Cold Start:LLRT ( > 100ms) https://github.com/awslabs/llrt/tree/main/benchmarks
2. LLRT > LLRT offers up to over 10x faster
startup and up to 2x overall lower cost compared to other JavaScript runtimes running on AWS Lambda • つまりJS/TSのコードのままで ◦ ColdStart性能の改善 ▪ Go on AWS Lambdaと同等 ◦ メモリ使用量の改善 ▪ ≒ Costの改善
JavaScript × AWS Lambdaの新常識 1. TypeScript × AWS CDK 2.
LLRT 3. Lambda Web Adaptor 4. Response Streaming
3. Lambda Web Adaptor LambdaのEvents ⇔ HTTP Request/Response • Express.jsやNext.jsのWebフレームワークがAWS
Lambdaでそのまま動 く! https://aws.amazon.com/jp/blogs/compute/using-response-streaming-with-aws-lambda-web-adapter-to-optimize-performance/
3. Lambda Web Adaptor 安全かつ高速なLambda Extensions • Rust製で性能影響も軽微 ◦ 平均レイテンシーは
+0.8 ms 程度 ◦ p99 でも +4 ms 程度 • Docker on Lambdaなら1行足すだけ ◦ Managed Runtimeだと少し面倒
Extensionsのアーキテクチャ https://aws.amazon.com/jp/builders-flash/202301/lambda-web-adapter/ 3. Lambda Web Adaptor
JavaScript × AWS Lambdaの新常識 1. TypeScript × AWS CDK 2.
LLRT 3. Lambda Web Adaptor 4. Response Streaming
4. Response Streaming • 2024年時点で、世はLLM時代 ◦ つまり「ヌルヌル返却するやつ」時代ということ(?) • Lambda Response
Streaming ◦ FunctionsURLから、ペイロードをStreamingで返せる ◦ 最大20MB返せる(通常6MB)
4. Response Streaming 制約:動作条件 1.マネージドランタイム ◦ Node.js v16以降”のみ” 2.カスタムランタイムに実装 ◦
実装済はRust Runtime for AWS Lambdaのみ? 3.+ Lambda Extensions ◦ 後述のLambda Web Adaptorを使うと間接的に2.相当
4. Response Streaming Node.js Runtimeには、組み込みの独自関数が用意 https://aws.amazon.com/jp/blogs/news/introducing-aws-lambda-response-streaming/
4. Response Streaming Appendix. 組み込み関数は少し癖がある • 実装前に、↓のスライドを読むのがおススメ https://speakerdeck.com/watany/aws-lambda-response-streaming-shi-zhuang-qian-nisiritaiyatu
まとめ
まとめ • JS/TS × LambdaとCDKとで、技術スタックを統一しやすい • StreamingもNode.jsランタイムなら始めやすい • Lambda Web
AdaptorでJSの強力なWeb Flameworkを採用できる • LLRTが実用化されれば更なる最適化へ…! だから JavaScript × AWS Lambdaがアツい!!