最近、とある会社様の勉強会で話した内容です。もとはFukuoka.devでお話した内容に修正とアップデートをいれたものです。 こだわりないならとりあえずサーバーレスで始めたみたら?っていう軽いノリです。
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.とりあえずサーバーレスKeisuke Nishitani (@Keisuke69)Solutions ArchitectAmazon Web Services Japan K.K.
View Slide
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.Keisuke Nishitani (@Keisuke69)Manager, Senior Solutions ArchitectAmazon Web Service Japan K.KEverything will be serverless.⾳楽 x キャンプ x マンガフジロッカーブログ: https://www.keisuke69.net/
ではない
「お⾦で時間を買う」
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.いかに速く、価値のある、システムを作るか⽬指すべきこと
「差別化に繋がらない重労働」を「⾃分でやらない」
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コンピューティングの進化LEVEL OF ABSTRACTIONFOCUS ON BUSINESS LOGICPHYSICAL MACHINESプランニングに「推測」が必要オンプレで数年稼働⼊念な調査低いイノベーション要素数ヶ⽉単位でのデプロイ
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コンピューティングの進化LEVEL OF ABSTRACTIONFOCUS ON BUSINESS LOGICVIRTUAL MACHINESHWの独⽴性迅速なプロビジョニングよりスケールElasticなリソース迅速かつ俊敏メンテナンス時間がいる
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コンピューティングの進化LEVEL OF ABSTRACTIONFOCUS ON BUSINESS LOGICCONTAINERIZATIONプラットフォーム⾮依存⼀貫したランタイム環境リソースの利⽤効率⾼簡単かつ迅速なデプロイ隔離とサンドボックス起動時の速度 (数秒でのデプロイ)
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コンピューティングの進化AWS LambdaAWS FargateLEVEL OF ABSTRACTIONFOCUS ON BUSINESS LOGIC連続的なスケール組み込み済の耐障害性イベント・ドリブン使⽤量に応じた課⾦ゼロメンテナンスSERVERLESS
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.おさらい: サーバーレスとはインフラのプロビジョニング不要管理不要⾃動でスケール価値に対する⽀払い ⾼可⽤かつ安全
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.オペレーションの責任範囲AWS LambdaServerless functionsAWS FargateServerless containersECS/EKSContainer-management as aserviceEC2Infrastructure-as-a-ServiceMore opinionatedLess opinionatedAWSの管理範囲 お客様の管理範囲• データソースとのインテグレーション• 物理ハードウェア、ソフトウェア、ネットワークとファシリティ• プロビジョニング• アプリケーションコード• コンテナオーケストレーションとプロビジョニング• クラスタのスケーリング• 物理ハードウェア、ホストOS/カーネル、ネットワーキングとファシリティ• アプリケーションコード• データソースとのインテグレーション• セキュリティの構成とアップデート、ネットワーク構成、タスク管理• コンテナオーケストレーションのコントロールプレーン• 物理ハードウェア、ソフトウェア、ネットワーキングとファシリティ• アプリケーションコード• データソースとのインテグレーション• Workerクラスタ• セキュリティの構成とアップデート、ネットワーク構成、ファイアウォール、タスク管理• 物理ハードウェア、ソフトウェア、ネットワーキングとファシリティ• アプリケーションコード• データソースとのインテグレーション• スケーリング• セキュリティの構成とアップデート、ネットワーク構成、ファイアウォール、タスク管理• プロビジョニング、スケーリング管理とサーバ管理
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS Lambda release historyLambda PreviewAnnouncementLambda GA1.5 GB RAMAmazon API Gateway LaunchAmazon DynamoDB StreamSupport300s Execution DurationPython 2.7 SupportJava SupportAlexa IntegrationFunction VersioningScheduled CloudWatchEvents SupportAmazon SWF SupportAmazon VPC SupportAPI Gateway ProxyEnvironment VariablesAWS SAM[email protected]AnnouncementNode 4.2 SupportAWS CodeCommit SupportC# .Net SupportAWS GreenGrassLambda SupportSAMEnhancementsPython 3.61000 Concurrency LimitPCI CertificationAWS SAMLocal (now AWSCLI)SOC CertificationPer Function ConcurrencyControlsNode.js 6.10TaggingAWS X-Ray3 GB RAM SupportHIPAA EligibleTraffic Shifting/WeightedAliasesAWS Serverless ApplicationRepository Announcement.Net Core v2.0AWS CLI relaunchFedRAMP CertificationAWS CLI—Lambda Local,Log tailingPowerShell Support15-Minute Execution DurationGo SupportNode.js v8Amazon SQS Support.Net 2.1 SupportAWS CLI Go DebuggingConsole AppView99.95%SLA*As of Dec 2019, does not include region launches2015 2016 2017 2018 2019VPC ImprovementCloudWatch Logs Insights integrationAmazon Linux 2018.03Node.js 10RubyLayersCustomruntimesALBtriggersKinesis HTTP/2 streamconsumersPython 3.7Stream batch settingsCreate app in ConsoleRDS ProxyProvisioned ConcurrencyNode.js 12, Java 11, andPython 3.8Customize retry behaviorDestinations for Async Invokation
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.かつてのAnti-Pattern
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS Lambda と RDBMSAmazon RDSAmazon AuroraLambda function
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.Photo on Visualhunt.com
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.Using Amazon RDS Proxy with AWS LambdaAmazon RDSAmazon AuroraLambda function
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.Using Amazon RDS Proxy with AWS LambdaAmazon RDSAmazon AuroraLambda functionAmazon RDS Proxy
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.RDSのコネクションプールマネージャ東京を含む5リージョンで利用可能(Public Preview)Lambdaからも利⽤可能Amazon RDS Proxy
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS LambdaのネットワーキングAWS Lambda Service VPCAWS LambdaExecution Environment
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS LambdaのネットワーキングAWS Lambda Service VPCAWS LambdaExecution Environmentユーザが所有するVPCElastic network interface
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS LambdaのネットワーキングAWS Lambda Service VPC ユーザが所有するVPC
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS HyperplaneInternal network load balancing serviceGraphic Option3
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AMAZON Elastic File SystemAWS Managed NATAWS PrivateLinkAWS Network Load Balancer
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.AWS LambdaのネットワーキングAWS Lambda Service VPC ユーザが所有するVPCElastic network interfaceVPC to VPC NAT
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コールドスタートレイテンシの改善スケーリングネットワークインターフェースの共有VPC環境の改善
Photo on Visual Hunt
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.幅広いアプリケーション実⾏環境Amazon EC2 AWS LambdaAWS FargateAmazon ECSAmazon EKS
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.モダンアプリケーション開発を⽀援するサービスOn-Premises CloudMore LessCompute Virtual MachineAmazon EC2 AWS LambdaAWS FargateAmazon ECS Amazon EKSDatabases MySQL MySQL on EC2Amazon RDS MySQL Amazon RDS AuroraAmazon AuroraServerless Amazon DynamoDBStorage StorageAmazon S3Messaging ESBAmazon MQ Amazon Kinesis Amazon SQS / Amazon SNSAnalyticsHadoop Hadoop on EC2 Amazon EMR Amazon Elasticsearch Service Amazon Athenaオペレーション負荷Serverless
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.MICROSERVICEAPIAPIMICROSERVICEMICROSERVICEEVENTAPIMICROSERVICEEVENTAPIMICROSERVICEAPPLICATIONMobile clientClientIoTPERSISTENCE PERSISTENCEMicroservices architectures
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.APIはMicroservicesの⽞関
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.Mobile appsWebsitesServicesInternet AmazonCloudFrontAmazon CloudWatchmonitoringAPIGatewaycacheAny otherAWS serviceAll publiclyaccessibleendpointsAWSLambdafunctionsEndpointsin your VPCRegional API EndpointsAWS LambdafunctionsEndpoints onAmazon EC2Your VPCAWSAPI Gatewayを利⽤したAPI管理
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.イベントドリブンアーキテクチャ
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.メッセージングを活⽤してコードからステートを取り除くQueuesSimpleFully-managedAny volumePub/subSimpleFully-managedFlexibleAmazon SimpleQueue ServiceAmazon SimpleNotificationServiceMessagingSynchronizationRapidFully-managedReal-timeAmazonCloudWatchEvents
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.データと処理の状態をトラッキング冗⻑なコードを削除ワークフローを構築してすべてをオーケストレーション
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.コードを減らし、よりシンプルなインテグレーションAWS LambdaでポーリングStep FunctionsによるインテグレーションStartSubmit JobWait X SecondsGet Job StatusJob Complete?Set Job Failed Set Job SucceededSent Message to SNSEndAWSLambdafunctionsSynchronously Run a Batch JobPublish Success to SNS Publish Error to SNSStartEndNoLambdafunctions
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.クラウドネイティブなアーキテクチャは⼩さいピースで構成され、疎結合
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.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 rightsreserved.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 rightsreserved.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 rightsreserved.
© 2019, Amazon Web Services, Inc. or its affiliates. All rightsreserved.まとめ明確に使い分けたいニーズがない場合とりあえずサーバーレスうまくいかなかったらコンテナ、EC2と検討していく明確に使い分けたいニーズがある場合特性に応じて幅広い選択肢から選択悩んだらSolution Architectに相談