Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Azure Serverless 2019 Summer edition

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.
Avatar for miyake miyake
July 30, 2019

Azure Serverless 2019 Summer edition

Serverless Meetup Tokyo #13 で発表させていただいたスライドです。

Avatar for miyake

miyake

July 30, 2019
Tweet

More Decks by miyake

Other Decks in Technology

Transcript

  1. About Me 三宅 和之 @kazuyukimiyake 株式会社ゼンアーキテクツ CTO Microsoft MVP (

    for Microsoft Azure ) Azure/azure-functions-durable-extension Contributer Vue.js-jp, typescript-jp コアスタッフ PaaS がかりの部屋(Blog): https://k-miyake.github.io/blog/ 2
  2. Serverless の定義 (※ このセッションでの定義) Serverless = BaaS ( Backend as

    a Service) + FaaS ( Functions as a Service) martinfowler.com 記事 4
  3. Azure Serverless アーキテクチャ例#2 グローバルにスケールするアプリケーションを Serverless で構築 MS 本社の Matias Quaranta

    が Azure Friday でデモを実施したアーキテクチャ 動画( Azure Friday )https://youtu.be/cfZUiVQIhTw 7
  4. Azure Functions は V2 へ進化(更新を推奨) Runtime を Host process と

    Worker process に分離 新機能はほとんどが V2 のみをサポート (V1 はほぼメンテナンスされていない) 11
  5. TypeScript サポート Node.js ベースでの Azure Functions 開発が安全・快適に︕ import { AzureFunction,

    Context, HttpRequest } from "@azure/functions"; // API のペイロード定義 type Member = { name: string; isMember: boolean; }; // Function (HTTP トリガー) の実装 const httpTrigger: AzureFunction = async function( context: Context, req: HttpRequest): Promise<void> { const member = { name: req.body.name, isMember: true }; context.res = { status: 200, body: member }; }; export default httpTrigger; 13
  6. KEDA Kubernetes-based Event Driven Autoscaling Azure Functions のスケールコントローラ ーを応⽤して OSS

    化 Microsoft と Redhat で共同開発 イベント駆動型 Pod をオートスケール可能 KEDA: イベント連動でスケール(0->1) HPC: リソースに応じたスケール(1->n) 15
  7. キーテクノロジー: Azure Cosmos DB A globally distributed, massively scalable, multi-model

    database service. 主な特⻑ サーバーレス - No infrastructure or VM management グローバル分散 - Turnkey geo-replication マルチモデル, マルチ API ストレージとスループットをエラスティックにスケール可能 99th パーセンタイル内に 10ms 以下のレイテンシーを SLA で保証 16
  8. Azure Functions CosmosDB Trigger Cosmos DB のデータ変更によって Azure Functions が発⽕する

    複数の Change Feed を独⽴して配置可能 クロスパーテーションでデータにアクセスしたい場合に便利 18
  9. CosmosDB トリガー + SignalR バインディングの例 import { AzureFunction, Context }

    from "@azure/functions"; const cosmosDBTrigger: AzureFunction = async function( context: Context, documents: Tweet[] ): Promise<void> { // CosmosDB からのデータ⼊⼒確認 if (!!documents && documents.length > 0) { context.log("Document: ", documents[0].tweetText); } // SignalR へのメッセージ登録 context.bindings.signalRMessages = [ { target: "newMessage", arguments: [documents] } ]; }; 20
  10. signalr.js によるクライアント側の実装 created: async function(): Promise<void> { // SignalRとコネクションを作成 const

    connection = new HubConnectionBuilder() .withUrl(this.baseUrl) .configureLogging(LogLevel.Information) .build(); console.log("connecting..."); // SignalR Serviceへの接続 connection .start() .then(() => console.log("connected!")) .catch(console.error); // SignalRからの呼び出し connection.on("newMessage", (tweets: Tweet[]) => this.displayTweet(tweets)); // 切断 connection.onclose(() => console.log("disconnected")); } 21
  11. Azure Serverless の課題(個⼈的⾒解) フロントエンド SPA ベース Web アプリのデプロイ先が。。 SPA にとって

    App Service はオーバースペック Static Website ホスティング機能がショボい Firebase や Netlify 相当の機能が求められる 23
  12. 本⽇のまとめ Azure Serverless は FaaS (Azure Functions) だけではない Serverless だけでも幅広いシナリオに対応したアーキテクチャを実現できる

    OSS プロダクトが多いので、コントリビュートしましょう︕ 本⽇話せなかったこと Serverless での分散トレーシング(App Insights) Serverless なマイクロサービスの⼀括デプロイ(ARM Template) Smart Store リファレンスアーキテクチャ 24