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

とりあえずサーバーレス/Do Serverless First

Keisuke69
January 31, 2020

とりあえずサーバーレス/Do Serverless First

最近、とある会社様の勉強会で話した内容です。もとはFukuoka.devでお話した内容に修正とアップデートをいれたものです。
こだわりないならとりあえずサーバーレスで始めたみたら?っていう軽いノリです。

Keisuke69

January 31, 2020
Tweet

More Decks by Keisuke69

Other Decks in Technology

Transcript

  1. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    とりあえずサーバーレス
    Keisuke Nishitani (@Keisuke69)
    Solutions Architect
    Amazon Web Services Japan K.K.

    View Slide

  2. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Keisuke Nishitani (@Keisuke69)
    Manager, Senior Solutions Architect
    Amazon Web Service Japan K.K
    Everything will be serverless.
    ⾳楽 x キャンプ x マンガ
    フジロッカー
    ブログ: https://www.keisuke69.net/

    View Slide

  3. View Slide

  4. View Slide

  5. View Slide

  6. ではない

    View Slide

  7. 「お⾦で時間を買う」

    View Slide

  8. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    いかに速く、
    価値のある、
    システムを作るか
    ⽬指すべきこと

    View Slide

  9. 「差別化に繋がらない重労働」

    「⾃分でやらない」

    View Slide

  10. 「差別化に繋がらない重労働」

    「⾃分でやらない」

    View Slide

  11. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コンピューティングの進化
    LEVEL OF ABSTRACTION
    FOCUS ON BUSINESS LOGIC
    PHYSICAL MACHINES
    プランニングに「推測」が必要
    オンプレで数年稼働
    ⼊念な調査
    低いイノベーション要素
    数ヶ⽉単位でのデプロイ

    View Slide

  12. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コンピューティングの進化
    LEVEL OF ABSTRACTION
    FOCUS ON BUSINESS LOGIC
    VIRTUAL MACHINES
    HWの独⽴性
    迅速なプロビジョニング
    よりスケール
    Elasticなリソース
    迅速かつ俊敏
    メンテナンス時間がいる

    View Slide

  13. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コンピューティングの進化
    LEVEL OF ABSTRACTION
    FOCUS ON BUSINESS LOGIC
    CONTAINERIZATION
    プラットフォーム⾮依存
    ⼀貫したランタイム環境
    リソースの利⽤効率⾼
    簡単かつ迅速なデプロイ
    隔離とサンドボックス
    起動時の速度 (数秒でのデプロイ)

    View Slide

  14. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コンピューティングの進化
    AWS Lambda
    AWS Fargate
    LEVEL OF ABSTRACTION
    FOCUS ON BUSINESS LOGIC
    連続的なスケール
    組み込み済の耐障害性
    イベント・ドリブン
    使⽤量に応じた課⾦
    ゼロメンテナンス
    SERVERLESS

    View Slide

  15. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    おさらい: サーバーレスとは
    インフラのプロビジョニング不要
    管理不要
    ⾃動でスケール
    価値に対する⽀払い ⾼可⽤かつ安全

    View Slide

  16. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    オペレーションの責任範囲
    AWS Lambda
    Serverless functions
    AWS Fargate
    Serverless containers
    ECS/EKS
    Container-management as a
    service
    EC2
    Infrastructure-as-a-Service
    More opinionated
    Less opinionated
    AWSの管理範囲 お客様の管理範囲
    • データソースとのインテグレーション
    • 物理ハードウェア、ソフトウェア、ネット
    ワークとファシリティ
    • プロビジョニング
    • アプリケーションコード
    • コンテナオーケストレーションとプロビ
    ジョニング
    • クラスタのスケーリング
    • 物理ハードウェア、ホストOS/カーネル、
    ネットワーキングとファシリティ
    • アプリケーションコード
    • データソースとのインテグレーション
    • セキュリティの構成とアップデート、ネットワー
    ク構成、タスク管理
    • コンテナオーケストレーションのコン
    トロールプレーン
    • 物理ハードウェア、ソフトウェア、
    ネットワーキングとファシリティ
    • アプリケーションコード
    • データソースとのインテグレーション
    • Workerクラスタ
    • セキュリティの構成とアップデート、ネット
    ワーク構成、ファイアウォール、タスク管理
    • 物理ハードウェア、ソフトウェ
    ア、ネットワーキングとファシ
    リティ
    • アプリケーションコード
    • データソースとのインテグレーション
    • スケーリング
    • セキュリティの構成とアップデート、ネット
    ワーク構成、ファイアウォール、タスク管理
    • プロビジョニング、スケーリング管理とサー
    バ管理

    View Slide

  17. View Slide

  18. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.

    View Slide

  19. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambda release history
    Lambda Preview
    Announcement
    Lambda GA
    1.5 GB RAM
    Amazon API Gateway Launch
    Amazon DynamoDB Stream
    Support
    300s Execution Duration
    Python 2.7 Support
    Java Support
    Alexa Integration
    Function Versioning
    Scheduled CloudWatch
    Events Support
    Amazon SWF Support
    Amazon VPC Support
    API Gateway Proxy
    Environment Variables
    AWS SAM
    [email protected]
    Announcement
    Node 4.2 Support
    AWS CodeCommit Support
    C# .Net Support
    AWS GreenGrass
    Lambda Support
    SAM
    Enhancements
    Python 3.6
    1000 Concurrency Limit
    PCI Certification
    AWS SAM
    Local (now AWS
    CLI)
    SOC Certification
    Per Function Concurrency
    Controls
    Node.js 6.10
    Tagging
    AWS X-Ray
    3 GB RAM Support
    HIPAA Eligible
    Traffic Shifting/Weighted
    Aliases
    AWS Serverless Application
    Repository Announcement
    .Net Core v2.0
    AWS CLI relaunch
    FedRAMP Certification
    AWS CLI—Lambda Local,
    Log tailing
    PowerShell Support
    15-Minute Execution Duration
    Go Support
    Node.js v8
    Amazon SQS Support
    .Net 2.1 Support
    AWS CLI Go Debugging
    Console AppView
    99.95%
    SLA
    *As of Dec 2019, does not include region launches
    2015 2016 2017 2018 2019
    VPC Improvement
    CloudWatch Logs Insights integration
    Amazon Linux 2018.03
    Node.js 10
    Ruby
    Layers
    Custom
    runtimes
    ALB
    triggers
    Kinesis HTTP/2 stream
    consumers
    Python 3.7
    Stream batch settings
    Create app in Console
    RDS Proxy
    Provisioned Concurrency
    Node.js 12, Java 11, and
    Python 3.8
    Customize retry behavior
    Destinations for Async Invokation

    View Slide

  20. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    かつてのAnti-Pattern

    View Slide

  21. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambda と RDBMS
    Amazon RDS
    Amazon Aurora
    Lambda function

    View Slide

  22. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambda と RDBMS
    Amazon RDS
    Amazon Aurora
    Lambda function

    View Slide

  23. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Photo on Visualhunt.com

    View Slide

  24. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.

    View Slide

  25. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Using Amazon RDS Proxy with AWS Lambda
    Amazon RDS
    Amazon Aurora
    Lambda function

    View Slide

  26. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Using Amazon RDS Proxy with AWS Lambda
    Amazon RDS
    Amazon Aurora
    Lambda function
    Amazon RDS Proxy

    View Slide

  27. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    RDSのコネクションプールマネージャ
    東京を含む5リージョンで利用可能
    (Public Preview)
    Lambdaからも利⽤可能
    Amazon RDS Proxy

    View Slide

  28. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaのネットワーキング
    AWS Lambda Service VPC
    AWS Lambda
    Execution Environment

    View Slide

  29. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaのネットワーキング
    AWS Lambda Service VPC
    AWS Lambda
    Execution Environment
    ユーザが所有するVPC
    Elastic network interface

    View Slide

  30. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaのネットワーキング
    AWS Lambda Service VPC ユーザが所有するVPC

    View Slide

  31. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Hyperplane
    Internal network load balancing service
    Graphic Option
    3

    View Slide

  32. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AMAZON Elastic File System
    AWS Managed NAT
    AWS PrivateLink
    AWS Network Load Balancer

    View Slide

  33. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaのネットワーキング
    AWS Lambda Service VPC ユーザが所有するVPC
    Elastic network interface
    VPC to VPC NAT

    View Slide

  34. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaのネットワーキング
    AWS Lambda Service VPC ユーザが所有するVPC
    Elastic network interface
    VPC to VPC NAT

    View Slide

  35. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コールドスタートレイテンシの改善
    スケーリング
    ネットワークインターフェースの共有
    VPC環境の改善

    View Slide

  36. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.

    View Slide

  37. Photo on Visual Hunt

    View Slide

  38. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    幅広いアプリケーション実⾏環境
    Amazon EC2 AWS Lambda
    AWS Fargate
    Amazon ECS
    Amazon EKS

    View Slide

  39. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    モダンアプリケーション開発を⽀援するサービス
    On-Premises Cloud
    More Less
    Compute Virtual Machine
    Amazon EC2 AWS Lambda
    AWS Fargate
    Amazon ECS Amazon EKS
    Databases MySQL MySQL on EC2
    Amazon RDS MySQL Amazon RDS Aurora
    Amazon Aurora
    Serverless Amazon DynamoDB
    Storage Storage
    Amazon S3
    Messaging ESB
    Amazon MQ Amazon Kinesis Amazon SQS / Amazon SNS
    Analytics
    Hadoop Hadoop on EC2 Amazon EMR Amazon Elasticsearch Service Amazon Athena
    オペレーション負荷
    Serverless

    View Slide

  40. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    MICROSERVICE
    API
    API
    MICROSERVICE
    MICROSERVICE
    EVENT
    API
    MICROSERVICE
    EVENT
    API
    MICROSERVICE
    APPLICATION
    Mobile client
    Client
    IoT
    PERSISTENCE PERSISTENCE
    Microservices architectures

    View Slide

  41. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    APIはMicroservicesの⽞関

    View Slide

  42. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Mobile apps
    Websites
    Services
    Internet Amazon
    CloudFront
    Amazon CloudWatch
    monitoring
    API
    Gateway
    cache
    Any other
    AWS service
    All publicly
    accessible
    endpoints
    AWS
    Lambda
    functions
    Endpoints
    in your VPC
    Regional API Endpoints
    AWS Lambda
    functions
    Endpoints on
    Amazon EC2
    Your VPC
    AWS
    API Gatewayを利⽤したAPI管理

    View Slide

  43. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    イベントドリブンアーキテクチャ

    View Slide

  44. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    メッセージングを活⽤してコードからステート
    を取り除く
    Queues
    Simple
    Fully-managed
    Any volume
    Pub/sub
    Simple
    Fully-managed
    Flexible
    Amazon Simple
    Queue Service
    Amazon Simple
    Notification
    Service
    Messaging
    Synchronization
    Rapid
    Fully-managed
    Real-time
    Amazon
    CloudWatch
    Events

    View Slide

  45. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    データと処理の状態を
    トラッキング
    冗⻑なコードを削除
    ワークフローを構築してすべてを
    オーケストレーション

    View Slide

  46. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    コードを減らし、よりシンプルなインテグレー
    ション
    AWS Lambdaで
    ポーリング
    Step Functionsによる
    インテグレーション
    Start
    Submit Job
    Wait X Seconds
    Get Job Status
    Job Complete?
    Set Job Failed Set Job Succeeded
    Sent Message to SNS
    End
    AWS
    Lambda
    functions
    Synchronously Run a Batch Job
    Publish Success to SNS Publish Error to SNS
    Start
    End
    No
    Lambda
    functions

    View Slide

  47. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    クラウドネイティブなアーキテクチャは
    ⼩さいピースで構成され、疎結合

    View Slide

  48. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    Amazon ECS / Amazon EKSを活⽤するケース
    When you need …
    • ⻑時間実⾏のジョブ (> 15 minutes)
    • 予測可能な⾼トラフィック
    • 低いスタートアップレイテンシ(1秒未満)
    • HTTP/S以外のリスナーが必要なアプリ
    • ステートフルなアプリ(EFS連携含む)
    • サービスとともに実⾏するAgent/daemon/side car
    • 特定ハードウェア(GPUなど)やKernelのチューニング
    • Windowsコンテナやレガシーな.NETのサポート
    When you want …
    • コンピュート環境な完全な制御
    • ハイブリッドやオンプレとのポータビリティ
    • コンテナイメージのポータビリティ
    • 異なる購⼊オプション(On-demand、RI、Spot)

    View Slide

  49. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Fargateを活⽤するケース
    When you need …
    • ⻑時間実⾏のジョブ (> 15 minutes)
    • Lambdaが提供する必要のコンピューティングリソース (>3 GB memory)
    • HTTP/S以外のリスナーが必要なアプリ
    • サイドカーの実⾏
    • 予測可能もしくは少し⻑い開始時間が許容されるスケーリング
    When you want …
    • マネージドなコンテナ実⾏環境
    • コンテナイメージのポータビリティ

    View Slide

  50. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    AWS Lambdaを活⽤するケース
    When you need …
    • イベントに応じたアクションの実⾏
    • 様々な利⽤率のサポート
    • 不透明な需要を処理する能⼒
    • より軽量でアプリケーションにフォーカスしたステートレスなコンピューティング
    When you want to …
    • ITオペレーションではなくビジネスロジックにフォーカスしたい
    • シンプルなIT⾃動化
    • リアルタイムなデータ処理やサーバーレスなバックエンド
    • オペレーションの複雑性(パッチ適⽤、スケーリング、⾼可⽤性など)をAWSに任せ
    たい
    • 開発とオペレーションの複雑性の軽減

    View Slide

  51. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.

    View Slide

  52. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.
    まとめ
    明確に使い分けたいニーズがない場合
    とりあえずサーバーレス
    うまくいかなかったらコンテナ、EC2と検討していく
    明確に使い分けたいニーズがある場合
    特性に応じて幅広い選択肢から選択
    悩んだらSolution Architectに相談

    View Slide

  53. © 2019, Amazon Web Services, Inc. or its affiliates. All rights
    reserved.

    View Slide