Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
serverless-elixir-intro
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ohr486
April 17, 2019
Programming
670
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
serverless-elixir-intro
ohr486
April 17, 2019
More Decks by ohr486
See All by ohr486
負荷試験Night#1 負荷試験2023年トレンド
ohr486
17
4.9k
Elixir/PhoenixによるWeb開発の現場から
ohr486
1
680
Hacking Phoenix Performance
ohr486
1
430
Plug & WAF
ohr486
2
570
elixirをプロダクションに導入する
ohr486
1
760
IEx maniacs
ohr486
4
700
Hack and Read Elixir
ohr486
2
830
Running App on AppRunner
ohr486
0
890
sponsor-talk-drecom-heisei-ruby-kaigi
ohr486
0
930
Other Decks in Programming
See All in Programming
Findy - エンジニア向け会社紹介/Findy Company Deck
findyinc
6
400k
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
110
ソニーのクラウド共通基盤の変遷とAI時代の開発スタイルに合わせた進化 / The Journey of Sony’s Common Cloud Platform and Its Evolution for AI-Native Development
kenjiyoneyama
0
200
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
430
JPUG勉強会 OSSデータベースの内部構造を理解しよう(第2回)
oga5
0
280
AHC070解法紹介
eijirou
0
140
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
240
そのリトライ、死んだコネクションを使い回していませんか ── GoのHTTPクライアントとHTTP/2を実プロダクト障害から学び直す
myus4a
0
340
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
5.1k
iOSDC2026登壇資料.pdf
riofujimon
0
200
AI が書く Go コードの品質を劇的に向上させる Linter: “declscope”
mpyw
0
450
IBM Bob Dojo #1 仕様駆動開発入門
oniak3ibm
PRO
0
320
Featured
See All Featured
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
560
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
960
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
KATA
mclloyd
PRO
35
16k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
33
5k
Exploring anti-patterns in Rails
aemeredith
4
520
30 Presentation Tips
portentint
PRO
1
410
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.4k
The agentic SEO stack - context over prompts
schlessera
0
950
GitHub's CSS Performance
jonrohan
1033
470k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
340
Transcript
Serverless Elixirを 動かすまで 2019/04/17 fukuoka.ex#21 おーはら@tokyo.ex
agenda • about me • (ちょっとだけお礼と宣伝) • goal • サーバーレスアーキテクチャとは
• AWS Lambdaのアーキテクチャ • カスタムランタイムのシーケンス • ElixirをAWS Lambdaで実行するには • まとめ
about me • Tsunenori Ohara/おーはら ◦ Twitter: @ohrdev ◦ Github:
ohr486 • Work ◦ (株)目黒のIT企業 プラットフォーム開発 1部 部長(※エンジニアリングもやってます ) ◦ CTO室(仮) NEW! ◦ インフラ/基盤/アーキテクチャ設計 ,Elixir/Erlang/HCL/SL/Ruby/Golang • Community ◦ tokyo.ex, ElixirConfJapan, Erlang&ElixirFest オーガナイザー ◦ Japan Elixir Association ◦ meguro.rb, meguro.es • Hobby ◦ 仏像制作, 丸太収集, 写経, 寺社仏閣 ◦ 人工衛星/アマチュア無線
(ちょっとだけお礼と宣伝) fukuoka.exコミュニティの皆さまへ いつも日本のElixirの活動を盛り上げていただいて ありがとうございます。 JEA, tokyo.ex, ElixirFestのオーガナイザーとし て、また、Elixirを使う1エンジニアとしてお礼申し上 げます。
https://elixir-fest.jp
goal • サーバーレスアーキテクチャの概要を理解する • AWS Lambdaのアーキテクチャを理解する • ElixirをAWS Lambdaで動かす方法を知る
サーバーレスアーキテクチャとは • 簡単に言うと、以下のようなアーキテクチャ ◦ 「サーバーを自前運用せずに、マネージドサービスの組み合わせで構築する」 ◦ 「リクエスト単位で必要な CPUリソースをリアルタイムで確保し処理できる」 • よく利用されるマネージドサービスは以下
◦ AWS Lambda, API Gateway (AWS) ※今日の発表はこのあたりを話します ◦ Cloud Function (GCP) ◦ Azure Function (Aure) • 何が嬉しいのか? ◦ スケールを意識しなくてよい(勝手にスケールイン・アウトしてくれる) ◦ 費用が安い(使ったぶんだけ費用を払えば良い)
サーバーレスアーキテクチャとは • サーバー運用のトレンド ◦ 物理サーバーによる運用 : オンプレ ◦ 仮想VMによる運用 :
ex) VMware, etc ◦ クラウドによる運用 : ex) AWS EC2, etc ◦ コンテナによる運用 : ex) Docker, Kubernetes いまは、ここから ◦ マネージドなコンテナサービス : ex) AWS ECS, GKE, EKS このあたりまで ◦ Function as a Service : ex) AWS Lambda, Cloud Function, Azure Function これからは • Webサービスのアーキテクチャの文脈で語られる事が多い(気がする)
webサービス サーバーレスアーキテクチャとは • Elixirとサーバーレスアーキテクチャの関係性 inet cloud Reqイベント リソース確保 イベント毎の計算 Resp返却
リソース解放 Respデータ request response ・マネージドサービスで構築 ・自動でスケールイン・アウト
webサービス サーバーレスアーキテクチャとは • Elixirとサーバーレスアーキテクチャの関係性 inet cloud Reqイベント リソース確保 イベント毎の計算 Resp返却
リソース解放 Respデータ request response API G/W ALB AWS Lambda Custom Runtime
AWS Lambdaのアーキテクチャ • 今まででAWS Lambdaのアーキテクチャの情報はあまりなかったが、 re:Invent2018でアーキテクチャ詳細の発表があった。詳しくは以下を参照 ◦ https://www.youtube.com/watch?v=QdzV04T_kec&feature=youtu.be ◦ https://www.slideshare.net/AmazonWebServices/a-serverless-journey-aws-lambda-under-the-
hood-srv409r1-aws-reinvent-2018 • 内部的にはFirecrackerが基盤となっている ◦ https://firecracker-microvm.github.io/ ▪ 超軽量VM(microVM)をセキュア・高速・大量に起動できるコンテナマシン ▪ KVM上で動作、Rust実装、OSS
AWS Lambdaのアーキテクチャ
ElixirをAWS Lambda上で実行するには • カスタムランタイムを利用 ◦ AWS Lambdaで任意の言語ランタイムを実行させる機能 ◦ 実行環境はAmazon Linux、利用できる環境変数は以下
▪ https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/current-supported-versions.html ◦ 必要なもの ▪ bootstrap : Lambda起動時に実行されるファイル ▪ function handler : 関数呼び出し時に実行するハンドラ ◦ 内部的にはAWS Lambdaランタイムインターフェース (HTTP API)をcall ▪ https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/runtimes-api.html ◦ パッケージングについては割愛、以下のドキュメントをご参照ください ▪ https://docs.aws.amazon.com/ja_jp/lambda/latest/dg/runtimes-walkthrough.html
カスタムランタイムのシーケンス Runtime API bootstrap λ start /invocation/next runtimeの初期化処理 request handler
{payload} /invocation/{req-id}/response /invocation/next response start
Runtime API bootstrap /invocation/next runtimeの初期化処理 request handler {payload} /invocation/{req-id}/response /invocation/next
response init phase invoke cycle start λ start カスタムランタイムのシーケンス
Runtime API bootstrap /invocation/next runtimeの初期化処理 request handler {payload} /invocation/{req-id}/response /invocation/next
response init phase invoke cycle 呼び出しイベント取得 呼び出しレスポンスを Lambdaに送信 start λ start カスタムランタイムのシーケンス
ElixirをAWS Lambda上で実行するには Runtime API λ start /invocation/next elixir handler Erlang
RTS start OTP App start elixir lambda core start bootstrap start OTP App
ElixirをAWS Lambda上で実行するには Runtime API request /invocation/next elixir handler Erlang RTS
{payload} elixir lambda core bootstrap :ok | {:ok, result} handle(Event, Context) /invocation/{req-id}/response response
ElixirをAWS Lambda上で実行するには Runtime API request /invocation/next elixir handler Erlang RTS
{payload} elixir lambda core bootstrap :ok | {:ok, result} handle(Event, Context) /invocation/{req-id}/response response
ElixirをAWS Lambda上で実行するには Runtime API elixir handler Erlang RTS elixir lambda
core bootstrap AWS Lambdaのカスタムランタイム Elixir/ErlangのRTS AWS Lambdaを扱うコアライブラリ Elixir実装の ハンドラ
まとめ • サーバーレスアーキテクチャの概要を紹介しました • AWS Lambdaのアーキテクチャを紹介しました • カスタムランタイムのアーキテクチャを紹介しました • Elixirをカスタムランタイムを使って動作させた場合の概要を紹介しました
◦ 既存実装として、erllambdaがあります、詳しくはこちらを参考にすると理解しやすいです ▪ https://github.com/alertlogic/erllambda • Lambdaのコアライブラリ(開発中)や、内部実装についてはElixirFestで紹介する予 定です • ServerlessベースのWAFについてはElixirFestで紹介する予定です
最後に fukuoka.ex様、発表の機会を頂きありがとうございました 引き続きよろしくお願いいたします。