Advertisement

サーバーレスの今とこれから

CEO at Section9
Mar. 11, 2017
Advertisement

More Related Content

Slideshows for you(20)

Viewers also liked(20)

Advertisement

Similar to サーバーレスの今とこれから(20)

More from 真吾 吉田(20)

Advertisement

サーバーレスの今とこれから

  1. サーバーレスの今とこれから JAWS DAYS 2017 株式会社セクションナイン 吉田真吾 Serverless
  2. 吉田真吾 n バックグラウンド 証券システム基盤開発 p 基盤開発、Oracleチューニングなど エバンジェリスト p 講演年間113回(2013年実績) p AWS設計・構築・移行(2014-2015) n 現在のしごと (株) セクションナイン 代表取締役社長 p AWSコンサルティング・設計・構築 p DevOps、Dockerize、Serverless 支援 (株) Cloud Payment p 技術顧問 n 実績等 p AWSウルトラクイズ 初代チャンピオン (2012年) p AWS Samurai 2014 / 2017 p AWSエキスパート養成読本 執筆 p AWS認定資格 全5種 p Oracle Database 11g (Gold, Performance Tuning)
  3. 本日お伝えしたいこと • サーバーレスってなに? • サーバーレスアーキテクチャってなに? • サーバーレスのエコシステム • サーバーレスで実現すべきこと • サーバーレスの運用の考えかた • サーバーレスの活用事例 • サーバーレスでSPAを開発するときの流れ
  4. AWS売上高 $0 $5,000 $10,000 2013 2014 2015 2016 百万 (x100万) サービス数 l 2006 : 4 l 2007 : 5 l 2008 : 6 l 2009 : 11 l 2010 : 13 l 2011 : 20 l 2012 : 27 l 2013 : 35 l 2014 : 46 l 2015 : 61 l 2016:95 l 2017:>100 APNプレミアコンサルティングパートナー 2013 17 2014 22 2015 28 2016 46 2017 55
  5. パラダイムシフト • Why The Future Of Software And Apps Is Serverless by Ken Fromm, VP of Business Development at Iron.io • コンピューティングリソースの調達リードタイムの短縮 • スタンダローンアプリからの変化(現在のMicroservices) • クラウドで柔軟にコンピューティングリソースをサービスとして 利用することができる • サーバーが要らないということではなく、開発者はサーバーにつ いて「考えなくてもよくなる」 http://readwrite.com/2012/10/15/why-the-future-of-software-and-apps-is-serverless/
  6. AWS Lambda • 2014年末 re:Invent にて発表 • サポート言語 2016.12.11現在 • Node.js – v0.10.36, v4.3.2 • Java – Java 8 • Python – Python 2.7 • C# - .NET Core 1.0.1 • ホスト • Amazon Linux (時々バージョンアップ) • 実行環境は再利用される • 初回起動が遅いが再利用時は高速 • 一時ストレージとして /tmp 利用可能(スケールしたり破棄されたりするので 頼らないこと) • 課金は使った分だけ • 確保(指定)したメモリ(128MB〜1.5GB) x 実行時間(100ms単位) x 実行回数 • メモリに比例してCPUの割当ても多くなる http://docs.aws.amazon.com/ja_jp/lambda/latest/dg/welcome.html
  7. Functions as a Service の台頭 • 特徴 • 実行環境は隠蔽&プラットフォーム 管理で、必要なのはコードのみ • コンテナベースで調達リードタイム を短縮 • 分散実行環境による可用性の確保 • 実行時間のみ課金によるコスト低減 • アーキテクチャにおける責務 • Stateful >> Statelessへ • 永続データ >> 揮発性 • モノリシック >> Microservices • バッチ処理 >> イベントドリブン https://aws.amazon.com/jp/about-aws/events/reinvent-report-2014-pt2/
  8. Lambda goes everywhere!! Snowball Edge Greengrass AWS IoT Greengrass Core IoT SDK Gateway edge location edge location Origin Lambda@Edge Step Functions Inline processing for Kinesis Firehose
  9. なにがサーバーレス? FaaS と Functional SaaS について
  10. http://www.slideshare.net/acloudguru/ant-stanley-being-serverless
  11. 代表的な2つの サーバーレスアーキテクチャ UIドリブン、イベント(メッセージ)ドリブン
  12. UIドリブンアプリケーション • Backend For Frontendでサーバー レス活用 1. 認証ロジックをBaaSで置換え 2. DynamoDBにクライアントから直 接アクセスするように 3. 大半のロジックをクライアントの シングルページアプリケーション に(UXに気をつける)してサーバー 側はAPI Gatewayで束ねる 4. 検索機能をFaaS上に 5. セキュリティの考慮で課金は別DB に別FaaSでアクセスするように http://martinfowler.com/articles/serverless.html
  13. メッセージドリブンアプリケーション • オンライン広告システム • 素早い配信(と同時に) アクティビティ記録 • 非同期にサーバーに送信してい た部分をスケーラビリティを気 にしなくていいFaaSに送信 • コンテンツのサムネイル作成 • ログのストリームプロセッシン グ http://martinfowler.com/articles/serverless.html
  14. サーバーレス エコシステム プラットフォーム 開発・運用フレームワーク 開発者
  15. プラットフォーム事業者 フレームワークやツール アプリケーション開発者 サーバーレスエコシステム • サーバー構築不要 • スケーラブル • 従量課金 etc… • API定義と関数コード の一体管理 • チーム開発(テスト、 デプロイ) etc… • 企画→開発→デリバリーに 集中 • サービスマネジメント • etc…
  16. Serverlessでの開発にどんなツールを使ってますか? # ツール名 ⽤途 ⼈数 1 Serverless Framework 開発フレームワーク・デプロイ(Node) 35 2 Apex 複数Lambda関数のデプロイ(Node) 12 3 Lamvery 複数Lambda関数のデプロイ(Python) 9 4 Swagger API定義・設計 8 5 AWS Serverless Application Model(SAM) 開発フレームワーク・デプロイ (CloudFormation) 7 6 Postman RESTのリクエスター・テストツール 7 7 Microsoft Visual Studio 統合開発環境(IDE) 5 8 AWS CLI コマンドラインツール 5 9 Eclipse 統合開発環境(IDE) 3 10 Python Serverless Microframework for AWS (chalice) 開発フレームワーク・デプロイ(Python) 2 Serverless Community(JP) https://www.facebook.com/groups/813718382095265/
  17. 多彩なエコシステムフレームワーク Chalice (Python Serverless Microframework for AWS)
  18. AWS Serverless Application Model (SAM) • サーバーレスアプリケーション全体 を CloudFormation テンプレートで 管理できる • 現在 Lambda、API Gateway、 DynamoDB がサポートされている • 個人的には今後チーム開発はこれが もっともやりやすく(Serverless FrameworkやChaliceより)なるん じゃないかと想定 https://github.com/awslabs/serverless-application-model
  19. AWS Serverless Application Model (SAM) functions app-spec (template) functions.zip Lambda bucket DynamoDB stack CloudFormation API Gateway SAM http://yoshidashingo.hatenablog.com/entry/2016/12/05/024120
  20. サーバーレス だからこそできることをやる 開発の高速化 運用の省力化
  21. 10X Product Development • 製品がマーケットにフィットす るかどうかが最も重要である • ビジネスに関連するコードの開 発時間に極力時間を使うべきで ある • 顧客とまわすイテレーションを 最大化すべきである • 依存性を最小化すべきである: 仕様確定待ちで開発者を待たせ たり、運用やDBAやその他の開 発者の影響で待たせることを極 力避けるべきである http://www.slideshare.net/ServerlessConf/joe-emison-10x-product-development
  22. 10X Product Development Commercial Search • 開発者2人x4ヶ月 • TypeScript 13,307行 • 開発者の稼働 95%以上(待ち時間なし) 構成 • Auth: Firebase • Static Site Hosting: Netlify • 画像管理: Cloudinary • 検索: Algolia ペインポイント • Firebaseのダッシュボードでは大きなデータセッ トが扱えない • RDBMSからFirebaseに移行する開発者のラーニン グカーブ http://www.slideshare.net/ServerlessConf/joe-emison-10x-product-development
  23. サーバーレス まかせっきりでよい?
  24. Serverlessness, NoOps and the Tooth Fairy 来たるサーバーレスな未来では、アプリケーショ ン開発者がもっと運用品質に対する責任を担うこ とになる "In the glorious Future, we will be Serverless, and there will be NoOps. - thought leaders" http://www.slideshare.net/ServerlessConf/charity-hound-serverless-noops-the-tooth-fairy
  25. Serverlessness, NoOps and the Tooth Fairy ベストプラクティス • 自分のプロダクトの問題はちゃん と直せる人は自分しかいない • クリティカルパスを理解する • できるかぎり小さく維持する • プロバイダの技術情報や、内部技 術が何に依存しているか理解する • アウトソース先に問題が起きても、 自身のサービスにおけるそれによる 結果については依然としてあなたが 責任を持たなければいけない http://www.slideshare.net/ServerlessConf/charity-hound-serverless-noops-the-tooth-fairy
  26. https://aws.amazon.com/jp/message/41926/
  27. Serverlessness, NoOps and the Tooth Fairy トレードオフ • 可視性が下がる • 自分自身で問題をfixできない し、新機能を実装することも できない • サービスはあなたの支払うお 金で維持されている • 制限や制約は公開されること もあるし、公開されないこと もある http://www.slideshare.net/ServerlessConf/charity-hound-serverless-noops-the-tooth-fairy
  28. https://speakerdeck.com/ikait/serverless-architecture-supports-nikkeis-paper-viewer
  29. https://speakerdeck.com/ikait/serverless-architecture-supports-nikkeis-paper-viewer
  30. https://speakerdeck.com/ikait/serverless-architecture-supports-nikkeis-paper-viewer
  31. Lambdaを活用するための心構え システムをリアクティブに設計する • イベントの発火やWebhookなどに対応している周 辺のマネージド・サービスとうまくつないでいく • シンプルなマイクロサービスとして(複雑なシス テムにしない) やっていく気持ち • 一度トライアルしておき、いざ活用する前にハマ りどころなど判断
  32. Serverlessのどんな話が聞きたい? # ツール名 ⼈数 1 Serverless開発の⼿法・ツール・CI/CDパイプライン 32 2 どう選ぶ? VM vs コンテナ vs サーバーレス 2017 (事例/パネル) 25 3 Voice/Bot/Text Analytics/Cognitive in Serverless 11 4 Serverless API(REST/GraphQL) 10 5 Serverless Single Page Applications 7 6 Serverless ストリームデータプロセッシング 5 7 IoT分野でのサーバーレスの活⽤ 3 8 Serverless Machine Learning 3 Serverless Community(JP) https://www.facebook.com/groups/813718382095265/
  33. Serverlessのどんな話が聞きたい? # ツール名 ⼈数 1 Serverless開発の⼿法・ツール・CI/CDパイプライン 32 2 どう選ぶ? VM vs コンテナ vs サーバーレス 2017 (事例/パネル) 25 3 Voice/Bot/Text Analytics/Cognitive in Serverless 11 4 Serverless API(REST/GraphQL) 10 5 Serverless Single Page Applications 7 6 Serverless ストリームデータプロセッシング 5 7 IoT分野でのサーバーレスの活⽤ 3 8 Serverless Machine Learning 3 Serverless Community(JP) https://www.facebook.com/groups/813718382095265/
  34. Serverless Single Page Apps 開発の流れ Step by Step
  35. www.example.com Amazon Route 53 Amazon S3 (Static Website) Google+ profile Cognito Identity Pools Lambda DynamoDB SPA
  36. 流れ • ビュー/アプリ開発 • ビューの作成 • テスト駆動でアプリコードを追加 • Cognitoを使った認証+フェデレーション • DynamoDBを使ったデータの管理 • Lambdaでシステム強化
  37. public ├── index.html ├── app.js ├── tests │ ├── SpecHelper.js │ ├── app_spec.js │ ├── index.html │ └── lib │ ├── jasmine-2.3.4 │ │ ├── boot.js │ │ ├── console.js │ │ ├── jasmine-html.js │ │ ├── jasmine.css │ │ ├── jasmine.js │ │ └── jasmine_favicon.png │ └── jquery-2.1.4.js └── vendor.js • ライブラリ:jQuery (他のものでもよい) • テストフレームワーク:Jasmine ビュー/アプリ開発
  38. ビュー/アプリ開発 • アプリ(js)開発 • ローカルで開発可能 • チーム開発がはじまっ たらS3で • 気をつけること • テスト時のブラウザ キャッシュ [index.html] イベント ループ Javascript [app.js] [app_spec.js] イベントを トリガする リクエスト コールバック 関数の起動 入力の取得 マークアップの変更 マークアップのテスト
  39. ビュー/アプリ開発 • テスト駆動 describe('LearnJS', function() { it('can show a problem view', function() { learnjs.showView('#problem-1'); expect($('.view-container .problem-view').length).toEqual(1); }); }); 'use strict'; var learnjs = {}; learnjs.showView = function(hash) { var problemView = $('<div class="problem-view">').text('Coming soon!'); $('.view-container').empty().append(problemView); } [app.js] [tests/app_spec.js] 一行書いたら 一行テスト
  40. ビュー/アプリ開発 • テスト駆動 [app.js] [tests/app_spec.js] 'use strict'; var learnjs = {}; learnjs.problemView = function() { return $('<div class="problem-view">').text('Coming soon!'); } learnjs.showView = function(hash) { var routes = { '#problem-1': learnjs.problemView }; var viewFn = routes[hash]; if (viewFn) { $('.view-container').empty().append(viewFn()); } } describe('LearnJS', function() { it('can show a problem view', function() { learnjs.showView('#problem-1'); expect($('.view-container .problem-view').length).toEqual(1); }); it('shows the landing page view when there is no hash', function() { learnjs.showView(''); expect($('.view-container .landing-view').length).toEqual(1); }); }); 一行書いたら 一行テスト
  41. CognitoをつかったID管理 ログイン ID取得 検証 認証情報取得 検証 APIコール
  42. CognitoをつかったIDフェデレーション
  43. CognitoをつかったIDフェデレーション
  44. CognitoをつかったIDフェデレーション
  45. DynamoDB • NoSQLデータベース サービス learnjs.saveAnswer = function(problemId, answer) { return learnjs.identity.then(function(identity) { var db = new AWS.DynamoDB.DocumentClient(); var item = { TableName: 'learnjs', Item: { userId: identity.id, problemId: problemId, answer: answer } }; return learnjs.sendDbRequest(db.put(item), function() { return learnjs.saveAnswer(problemId, answer); }) }); }; ユーザーID, 問題番号, 解答をDynamoDBに保存
  46. Lambda • 今回のアプリでの利用目的 • DynamoDB直接読み書きでは「不正なクエリからの保護」 • DynamoDB直接読み書きできない「ユーザー全員分の集計」 などの情報提供のため www.example.com Amazon Route 53 Amazon S3 (Static Website) Google+ profile Cognito Identity Pools Lambda DynamoDB SPA
  47. Serverless Single Page Apps 今日紹介したアプリが読み進 めていくだけで作成できる Step by Step ガイド • Author: Ben Rady • Published: 2016-06-20 • ISBN: 978-1-68050-149-0
  48. 4X PRE-CONFERENCE WORKSHOPS 26 April THE CONFERENCE 27-28 April World class speakers, panels, lightning talks, 2 days. Serverless Apps, Data Pipelines, & Configuration. Just real world experience building things without harming servers.

Editor's Notes

  1. コミュニティやってます。フィードバックください
  2. セクションナインという会社で社長兼平社員をやってます クラウドの導入からDockerizeやServerless化の相談から実装まで幅広くやってます まずはサーバーレスについて簡単に紹介
  3. 大半のアプリがコンテナ+サーバーレスに VMの置換え⇒VMでは実現できないエッジコンピューティングや
  4. アップするときは抜く
Advertisement