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

必要十分な設計をデザインし続けるコト ~ ECS の Blue/Green デプロイを添えて ~

必要十分な設計をデザインし続けるコト ~ ECS の Blue/Green デプロイを添えて ~

Talked at AWS Summit Tokyo 2023.
https://aws.amazon.com/jp/summits/tokyo/

このプレゼンの完全版:https://speakerdeck.com/track3jyo/blue-green-deploy-devday

はまーん
PRO

April 21, 2023
Tweet

More Decks by はまーん

Other Decks in Programming

Transcript

  1. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    必要⼗分な設計をデザインし続けるコト
    ~ ECS の Blue/Green デプロイを添えて ~
    D E V E L O P E R L O U N G E : M I N I - 9
    Shinichi Hama(はまーん) / track3jyo
    Sr. Startup Solutions Architect
    Amazon Web Services Japan G.K.

    View Slide

  2. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    本ミニセッションの完全版を観たい⽅は・・・
    Ø 動画: https://youtu.be/PRQgvdVravw
    Ø 資料: https://speakerdeck.com/track3jyo/blue-green-deploy-devday
    Ø 解説記事: https://speakerdeck.com/track3jyo/blue-green-deploy-devday

    View Slide

  3. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    本ミニセッションの完全版を観たい⽅は・・・
    Ø 動画: https://youtu.be/PRQgvdVravw
    Ø 資料: https://speakerdeck.com/track3jyo/blue-green-deploy-devday
    Ø 解説記事: https://speakerdeck.com/track3jyo/blue-green-deploy-devday
    この10分の中で伝えたいことだけ⾔います

    View Slide

  4. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    みなさんがエンジニアとして
    信念を持っていることはありますか︖

    View Slide

  5. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    「必要⼗分な」設計をデザインし続ける
    • 必要⼗分な設計 ≒ シンプルな設計
    • 逆にいうと、必要以上に複雑な設計は避ける
    • 簡易な設計を作って、その後何もしないわけではない。
    フェーズに合わせてデザインし続けましょう

    View Slide

  6. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    本当に最初からその⾼度な仕組みが必要ですか
    例えば、まだまだ成熟していないプロダクトやチームにおいて…
    • 複雑なデプロイプロセスやフローを導⼊することで満⾜していませんか︖
    • チームやプロダクトに沿わない、わたしの考えた最強デプロイフローや
    アーキテクチャになっていませんか︖
    • 「安全性」や「質」のような⾔葉を振りかざして、問題の本質を先延ばししてい
    ませんか︖
    安全性を⽬指して設計したはずの仕組みが、結果安全性を損なうのは、多くの場合
    チーム/プロダクトに沿わない、必要以上な仕組みを導⼊したことに起因します
    例)Blue/ Green デプロイ、DB のライブマイグレーション、派⼿なピタゴラスイッチアーキテクチャ

    View Slide

  7. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Keep it simple, stupid.
    • Kelly Johnson
    • American aeronautical and systems engineer
    KISS の原則
    設計の単純性(簡潔性)は成功への鍵である、「不必要な複雑性」は避けるべきだ

    View Slide

  8. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    シンプルとは何か︖
    • 無駄がない
    Ø 「やるべきことに対して」無駄がない
    • 理解しやすい
    Ø 誰が⾒てもわかるということ
    Ø 「可読性が⾼い」「再利⽤しやすい」「変更しやすい」

    View Slide

  9. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Amazon ECS の Blue/Green デプロイを例に

    View Slide

  10. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Amazon ECS におけるデプロイ戦略
    ローリングアップデート
    CodeDeploy による Blue / Green デプロイ
    (+Canary デプロイ、線形デプロイ)
    External デプロイ

    View Slide

  11. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Blue / Green デプロイと安全性
    • ⼀度新しい環境でテスト/動作確認をした上で切り替えができ、
    安全を確認した上で切り替えが可能
    • 問題が発⽣した際も、トラフィックを元のバージョンの環境に切り替
    えるだけなので、迅速にトラフィックの切り戻しが可能

    View Slide

  12. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Blue / Green デプロイと複雑性
    Health checks
    ・何をトリガーに切
    り替えを⾏うのか︖
    ・何をトリガーに
    切り戻すのか
    ・どうやって切り替
    えを⾃動化するか︖
    ・どんなメトリクス
    で判断するのか︖

    View Slide

  13. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    問題の本質から⽬を背けて、デプロイ戦略に押し付けていませんか︖
    リリース時に起きる障害が多く、⼼配なので
    安全な Blue / Green デプロイを採⽤します︕
    破壊的変更とかビッグバンリリースをしやすいので
    とりあえず Blue / Green デプロイにします︕
    この技術選定はシンプルでしょうか︖

    View Slide

  14. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    「とりあえず Blue /Green にしておきたい」という思考
    • Blue / Green デプロイというデプロイ戦略は安全性が⾼く、
    多機能なデプロイ戦略
    • 「とりあえず Blue /Green にしておきたい」というメンタルモデル
    に課題がある
    • 多機能がゆえに、いろんなことをやりたくなり、
    結果フローやプロセスの複雑性が増しがち
    • 今ある課題は本当にデプロイ戦略で解決すべき課題なのか

    View Slide

  15. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Amazon ECS ローリングアップデートの
    デプロイサーキットブレーカー
    v1 v2
    v2
    ...
    v1 v1
    v1
    ...
    New Deployment
    Rollback
    v1 v1
    v1
    ...
    • ECS サービスのデプロイで異常が発⽣した際、
    以前のバージョンへの⾃動ロールバックが可能
    • ⾃動ロールバックの実装を ECS に委ねて、
    マネージドな⾃動化が可能
    • 異常が発⽣したタスクの起動によるコストの発⽣や
    コンピューティングリソースの消費を抑える

    View Slide

  16. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    デプロイ失敗の判定
    • ステージ 1、ステージ 2 の⼆段階で評価される
    • ステージ 1
    Ø RUNNING 状態に遷移することなく、
    タスクの起動が “しきい値” まで連続して失敗する
    • ステージ 2
    Ø ヘルスチェック #1 の失敗により
    リプレースされたタスク数が “しきい値” に到達する
    #1: ELB / Cloud Map / コンテナ のヘルスチェック

    View Slide

  17. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Automate rollbacks for Amazon ECS
    rolling deployments with CloudWatch alarms
    https://aws.amazon.com/blogs/containers/automate-rollbacks-for-amazon-ecs-rolling-deployments-with-cloudwatch-alarms/

    View Slide

  18. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    「必要⼗分な」設計をデザインし続ける
    • 必要⼗分な設計 ≒ シンプルな設計
    • 逆にいうと、必要以上に複雑な設計は避ける
    • 簡易な設計を作って、その後何もしないわけではない。
    フェーズに合わせてデザインし続けましょう

    View Slide

  19. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    本ミニセッションの完全版を観たい⽅は・・・
    Ø 動画: https://youtu.be/PRQgvdVravw
    Ø 資料: https://speakerdeck.com/track3jyo/blue-green-deploy-devday
    Ø 解説記事: https://speakerdeck.com/track3jyo/blue-green-deploy-devday

    View Slide

  20. © 2023, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    Thank you!
    © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved.
    はまーん
    track3jyo

    View Slide