Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T B2Cビジネスの本番環境で必要な継続性と ⾼レスポンス性能を⽀えるコンテナアーキ テクチャ 前⽥ 卓俊 取締役 CTO 株式会社トクバイ I 1 - 0 4

Slide 3

Slide 3 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T ⾃⼰紹介 • 前⽥ 卓俊(@takatoshi-maeda) • 株式会社トクバイ 取締役CTO • 経歴 • SIer -> スタートアップCTO -> Web サービス事業会社 -> 2016年より現職 • インターネットサービス開発全般を担当

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 買い物情報サービス「トクバイ」 国内最⼤級のチラシ・買い物情報配信サービス

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 買い物情報サービス「トクバイ」 •جૅͱͳΔνϥγܝࡌ঎඼ͷ ࣄલ౤ߘ •౰೔ܾ·Δʮ΢Ϧʯ঎඼ͷ౰ ೔౤ߘ ΠϚͷ͓ങ͍ಘ঎඼Λಧ͚Δ

Slide 9

Slide 9 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 買い物情報サービス「トクバイ」 お店から⼊稿された情報をワンストップでマルチプラットフォームに展開

Slide 10

Slide 10 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 買い物情報サービス「トクバイ」

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T receipon digdag staff-admin ssh-gw redash zabbix staging ETL bargain-web kuroko2 stns prometheus tokubai-news kago ecs-scaler redash fluentd misc admin kinu batch-worker search mail backyard(API) logend mobile-pusher rproxy varnish batch background- job(sidekiq) loconavi-web remote-build prometheus

Slide 13

Slide 13 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T receipon digdag staff-admin ssh-gw redash zabbix staging ETL bargain-web kuroko2 stns prometheus tokubai-news kago ecs-scaler redash fluentd misc admin kinu batch-worker search mail backyard(API) logend mobile-pusher rproxy varnish batch background- job(sidekiq) loconavi-web remote-build prometheus

Slide 14

Slide 14 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T receipon digdag staff-admin ssh-gw redash zabbix staging ETL bargain-web kuroko2 stns prometheus tokubai-news kago ecs-scaler redash fluentd misc admin kinu batch-worker search mail backyard(API) logend mobile-pusher rproxy varnish batch background- job(sidekiq) loconavi-web remote-build prometheus

Slide 15

Slide 15 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 安全なシャットダウン ຊ൪؀ڥͰͷӡ༻Ͱͷ޻෉ϙΠϯτઃܭ൑அ͸ଟ͍

Slide 16

Slide 16 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 安全なシャットダウン ίϯςφ࣮ߦ؀ڥͷબ୒ͱΦʔτεέʔϦϯάʹϑΥʔΧε

Slide 17

Slide 17 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 "NB[PO&$εϙοτΠϯελϯεΛར༻ͨ͠ίετઓུ

Slide 18

Slide 18 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T オートスケーリング 4QPU'MFFUΛओ࣠ͱͨ͠ΦʔτεέʔϦϯά

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 AWS Fargate Amazon EC2 Elastic Container Service Service EC2 Cluster Fargate Cluster

Slide 21

Slide 21 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 Amazon EC2 Elastic Container Service Service EC2 Cluster

Slide 22

Slide 22 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 Elastic Container Service Service AWS Fargate Fargate Cluster

Slide 23

Slide 23 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T τΫόΠͰ͸"NB[PO&$ "NB[PO&$εϙοτΠϯελϯε Λར༻

Slide 24

Slide 24 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2 スポットインスタンス

Slide 25

Slide 25 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2 スポットインスタンスの中断 Private subnet VPC AWS Cloud Availability Zone 1 Elastic Container Service Service EC2 Cluster x x

Slide 26

Slide 26 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T AWS FargateとEC2 Launch Typeのコスト⽐較 ˞ݫີʹൺֱ͢ΔͱNγϦʔζͷΈ&$6͕ҟͳΔ

Slide 27

Slide 27 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T εϙοτΠϯελϯεͰՔಇͤͨ͞৔߹ͷ ίετޮՌ

Slide 28

Slide 28 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2インスタンス全体のスポット⽐率

Slide 29

Slide 29 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon ECSクラスタのSpot⽐率

Slide 30

Slide 30 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2 スポットインスタンスのコスト削減効果 Amazon EC2 スポットインスタンス適⽤後のAmazon EC2インスタンスコスト推移

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 Amazon EC2 Elastic Container Service Service EC2 Cluster

Slide 33

Slide 33 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 Amazon EC2 Elastic Container Service Service EC2 Cluster → オートスケーリングの仕組みで緩和

Slide 34

Slide 34 text

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

Slide 35

Slide 35 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T (改めて)なぜオートスケーリングが必要か ࣌ؒଳʹΑͬͯඞཁͳίϯϐϡʔςΟϯάϦιʔεྔ͸มಈ αʔϏε͸೥݄ͱͱ΋ʹ੒௕͢Δ

Slide 36

Slide 36 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 解決する問題 需要に応じたAmazon EC2インスタンスの調整 Amazon EC2スポットインスタンスの中断耐性

Slide 37

Slide 37 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Private subnet VPC AWS Cloud Availability Zone 1 Elastic Container Service Service EC2 Cluster 需給に応じたAmazon EC2インスタンスの調整 x

Slide 38

Slide 38 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2 スポットインスタンスの中断耐性 Private subnet VPC AWS Cloud Availability Zone 1 Elastic Container Service Service EC2 Cluster x x

Slide 39

Slide 39 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T ecs-scaler Private subnet VPC AWS Cloud Availability Zone 1 Availability Zone 2 ecs-scaler spotfleet(lowest) spotfleet (diversified) ondemand autoscaling group

Slide 40

Slide 40 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 解決する問題 需要に応じたAmazon EC2インスタンスの調整 Amazon EC2スポットインスタンスの中断耐性

Slide 41

Slide 41 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T スケールアウト ecs-scaler Cloudwatch Alarm

Slide 42

Slide 42 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T スケールイン ecs-scaler Cloudwatch Alarm

Slide 43

Slide 43 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 解決する問題 インスタンスプールの分散 Amazon EC2スポットインスタンスの中断耐性 需要に応じたAmazon EC2インスタンスの確保 稼働タスクのオフロード

Slide 44

Slide 44 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T インスタンスプールの分散 Private subnet VPC AWS Cloud Availability Zone 1 Availability Zone 2 ecs-scaler spotfleet(lowest) spotfleet (diversified) ondemand autoscaling group

Slide 45

Slide 45 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Amazon EC2 SpotFleet lowest fleet(m5.large, r5.large, c5.large) diversified fleet(m5.large, r5.large, c5.large) m5.large m5.large m5.large m5.large m5.large m5.large m5.large m5.large m5.large m5.large r5.large c5.large m5.large r5.large c5.large m5.large r5.large c5.large

Slide 46

Slide 46 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 稼働タスクのオフロード ecs-scaler spotfleet(lowest) spotfleet (diversified) ondemand autoscaling group Cloudwatch Alarm Cloudwatch Event

Slide 47

Slide 47 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 中断時タスク停⽌の注意点 ecs-scaler spotfleet(lowest) spotfleet (diversified) ondemand autoscaling group Cloudwatch Alarm Cloudwatch Event

Slide 48

Slide 48 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 解決する問題 需要に応じたAmazon EC2インスタンスの調整 Amazon EC2スポットインスタンスの中断耐性

Slide 49

Slide 49 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実⾏環境の選択 Amazon EC2 Elastic Container Service Service EC2 Cluster

Slide 50

Slide 50 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T オートスケーリングまとめ

Slide 51

Slide 51 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 現状の課題

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

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

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T エンジニア絶賛募集中です https://corp.tokubai.co.jp/recruit/

Slide 56

Slide 56 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Thank you! S U M M I T © 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. Takatoshi Maeda https://twitter.com/takatoshimaeda

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 安全なシャットダウン

Slide 59

Slide 59 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 安全なシャットダウン

Slide 60

Slide 60 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T CI CircleCI ECR CodeBuild build

Slide 61

Slide 61 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 安全なシャットダウン

Slide 62

Slide 62 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T Deployment & Rollback Slack AWS Cloud VPC Availability Zone 1 Availability Zone 2 Private subnet Ruboty(chatbot) Auto Scaling group Auto Scaling group Deploy Target

Slide 63

Slide 63 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 設定値の取扱

Slide 64

Slide 64 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 設定値の取扱

Slide 65

Slide 65 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 設定値の取扱

Slide 66

Slide 66 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 起動時に必要なリソースの取扱 Private subnet VPC AWS Cloud Availability Zone 1 Availability Zone 2 S3 Asset bucket

Slide 67

Slide 67 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 設定値の取扱

Slide 68

Slide 68 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T ログなどの⽣成物の取扱 Private subnet VPC AWS Cloud Availability Zone 1 Availability Zone 2 Fluentd S3 system logs bucket

Slide 69

Slide 69 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 設定値の取扱

Slide 70

Slide 70 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナの構成 front app fluentd haproxy xray

Slide 71

Slide 71 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T コンテナ実行環境の選択 コンテナの構成 配置戦略 Deployment & Rollback アプリ関連リソースの取扱 秘匿値の取扱 オートスケーリング CI ロギング 起動時処理 etc… 設定値の取扱

Slide 72

Slide 72 text

© 2019, Amazon Web Services, Inc. or its affiliates. All rights reserved. S U M M I T 配置戦略 Spread – InstanceId (HTTP Server / BackgroundJob) binpack – memory (BatchJob)

Slide 73

Slide 73 text

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

Slide 74

Slide 74 text

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