Share
Embed
とりあえずサーバーレス/Do Serverless First
最近、とある会社様の勉強会で話した内容です。もとはFukuoka.devでお話した内容に修正とアップデートをいれたものです。
こだわりないならとりあえずサーバーレスで始めたみたら?っていう軽いノリです。
Keisuke69
January 31, 2020
Transcript
53 slides
-
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. とりあえずサーバーレス Keisuke Nishitani (@Keisuke69) Solutions Architect Amazon Web Services Japan K.K. -
© 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/ -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. いかに速く、 価値のある、 システムを作るか ⽬指すべきこと -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コンピューティングの進化 LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC PHYSICAL MACHINES プランニングに「推測」が必要 オンプレで数年稼働 ⼊念な調査 低いイノベーション要素 数ヶ⽉単位でのデプロイ -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コンピューティングの進化 LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC VIRTUAL MACHINES HWの独⽴性 迅速なプロビジョニング よりスケール Elasticなリソース 迅速かつ俊敏 メンテナンス時間がいる -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コンピューティングの進化 LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC CONTAINERIZATION プラットフォーム⾮依存 ⼀貫したランタイム環境 リソースの利⽤効率⾼ 簡単かつ迅速なデプロイ 隔離とサンドボックス 起動時の速度 (数秒でのデプロイ) -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コンピューティングの進化 AWS Lambda AWS Fargate LEVEL OF ABSTRACTION FOCUS ON BUSINESS LOGIC 連続的なスケール 組み込み済の耐障害性 イベント・ドリブン 使⽤量に応じた課⾦ ゼロメンテナンス SERVERLESS -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. おさらい: サーバーレスとは インフラのプロビジョニング不要 管理不要 ⾃動でスケール 価値に対する⽀払い ⾼可⽤かつ安全 -
© 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クラスタ • セキュリティの構成とアップデート、ネット ワーク構成、ファイアウォール、タスク管理 • 物理ハードウェア、ソフトウェ ア、ネットワーキングとファシ リティ • アプリケーションコード • データソースとのインテグレーション • スケーリング • セキュリティの構成とアップデート、ネット ワーク構成、ファイアウォール、タスク管理 • プロビジョニング、スケーリング管理とサー バ管理 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. -
© 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 Lambda@Edge 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. かつてのAnti-Pattern -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda と RDBMS Amazon RDS Amazon Aurora Lambda function -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambda と RDBMS Amazon RDS Amazon Aurora Lambda function -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Photo on Visualhunt.com -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. Using Amazon RDS Proxy with AWS Lambda Amazon RDS Amazon Aurora Lambda function -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. RDSのコネクションプールマネージャ 東京を含む5リージョンで利用可能 (Public Preview) Lambdaからも利⽤可能 Amazon RDS Proxy -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambdaのネットワーキング AWS Lambda Service VPC AWS Lambda Execution Environment -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambdaのネットワーキング AWS Lambda Service VPC ユーザが所有するVPC -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Hyperplane Internal network load balancing service Graphic Option 3 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AMAZON Elastic File System AWS Managed NAT AWS PrivateLink AWS Network Load Balancer -
© 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 -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. コールドスタートレイテンシの改善 スケーリング ネットワークインターフェースの共有 VPC環境の改善 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. 幅広いアプリケーション実⾏環境 Amazon EC2 AWS Lambda AWS Fargate Amazon ECS Amazon EKS -
© 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 -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. APIはMicroservicesの⽞関 -
© 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管理 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. イベントドリブンアーキテクチャ -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. データと処理の状態を トラッキング 冗⻑なコードを削除 ワークフローを構築してすべてを オーケストレーション -
© 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 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. クラウドネイティブなアーキテクチャは ⼩さいピースで構成され、疎結合 -
© 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) -
© 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 … • マネージドなコンテナ実⾏環境 • コンテナイメージのポータビリティ -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. AWS Lambdaを活⽤するケース When you need … • イベントに応じたアクションの実⾏ • 様々な利⽤率のサポート • 不透明な需要を処理する能⼒ • より軽量でアプリケーションにフォーカスしたステートレスなコンピューティング When you want to … • ITオペレーションではなくビジネスロジックにフォーカスしたい • シンプルなIT⾃動化 • リアルタイムなデータ処理やサーバーレスなバックエンド • オペレーションの複雑性(パッチ適⽤、スケーリング、⾼可⽤性など)をAWSに任せ たい • 開発とオペレーションの複雑性の軽減 -
S U M M I T © 2019, Amazon Web
Services, Inc. or its affiliates. All rights reserved. -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved. まとめ 明確に使い分けたいニーズがない場合 とりあえずサーバーレス うまくいかなかったらコンテナ、EC2と検討していく 明確に使い分けたいニーズがある場合 特性に応じて幅広い選択肢から選択 悩んだらSolution Architectに相談 -
© 2019, Amazon Web Services, Inc. or its affiliates. All
rights reserved.