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

AWS上に構築したマイクロサービスに対する効率的な性能・負荷テストの実行方法

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for ahiratan ahiratan
November 11, 2022

 AWS上に構築したマイクロサービスに対する効率的な性能・負荷テストの実行方法

Avatar for ahiratan

ahiratan

November 11, 2022
Tweet

Other Decks in Technology

Transcript

  1. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. AWS上に構築したマイクロサービスに対する 効率的な性能・負荷テストの実⾏⽅法 平⾕ 皓倫 D - 5 - 2 アマゾン ウェブ サービス ジャパン合同会社 クラウドアプリケーションアーキテクト ⼩深⽥ 翔⼀郎 アマゾン ウェブ サービス ジャパン合同会社 クラウドアプリケーションアーキテクト
  2. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. スピーカー紹介 平⾕ 皓倫 Akinori Hiratani 所属︓ アマゾン ウェブ サービス ジャパン合同会社 プロフェッショナルサービス本部 役職︓ クラウドアプリケーションアーキテクト ⼩深⽥ 翔⼀郎 Shoichiro Kobukata 所属︓ アマゾン ウェブ サービス ジャパン合同会社 プロフェッショナルサービス本部 役職︓ クラウドアプリケーションアーキテクト
  3. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 本セッションで扱う2つのテーマ 1. 性能・負荷テスト 2. マイクロサービス化されたシステムのテスト <考慮すべき点> • テスト環境の構築やテスト実⾏のほか、テスト結果 の収集、可視化、管理といった作業に⼯数がかかる • クライアント側のリソースやネットワーク帯域が ⼗分でないと期待通りテストできないことがある <考慮すべき点> • システム全体の性能や負荷耐性だけでなく、 ボトルネック箇所を特定できる必要がある 拠点 AWS マイクロ サービス マイクロ サービス マイクロ サービス マイクロ サービス テスト クライアント マイクロ サービス マイクロ サービス 性能・負荷テストの実⾏イメージ
  4. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. • プロフェッショナルサービスでの過去のお客様⽀援の事例をもとに、 AWS上のマイクロサービスに対して性能・負荷テストを⾏う際のTipsを紹介 • 本セッションで扱うAWSのソリューション/サービス – Distributed Load Testing on AWS – AWS X-Ray 本セッションの内容
  5. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 1. お客様事例の概要 2. Distributed Load Testing on AWS による性能・負荷テストの実⾏ 3. AWS X-Rayによる性能・負荷テスト実⾏結果の分析 4. まとめ ⽬次
  6. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 1. お客様事例の概要
  7. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. お客様事例の概要 (1 / 2) • お客様は 10〜15 のマイクロサービスで構成されるWebシステムを構築 • 以下のようなシステム要件に沿って、システム全体の性能・負荷テストを計画 Ø システム応答時間の⽬標値︓1リクエストあたり 1秒未満 ( 注: 業務ごとに値は異なる ) Ø ピーク時のクライアント同時接続数︓10,000 台 お客様拠点 AWS サービス1 クライアント サービス2 サービス3 サービス4 サービス5 ... 各サービスは Amazon ECSで構築
  8. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. お客様事例の概要 (2 / 2) • 性能・負荷テストの実施⽅針︓ ü 本番リリースに向けた準備が佳境のため、テスト環境構築は最⼩限の⼯数で実施する ü クライアント側のリソースやネットワーク環境が問題とならないよう、 AWS上にテスト環境を構築して性能・負荷テストを実⾏する ü マイクロサービスでボトルネックとなっている箇所を特定できる仕組みを整備する Distributed Load Testing on AWS を活⽤してAWS上にテスト環境を構築 AWS X-Ray を活⽤してより詳細にテスト結果を分析
  9. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 2. Distributed Load Testing on AWS による性能・負荷テストの実⾏
  10. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Distributed Load Testing on AWS とは • HTTP または HTTPS のエンドポイントに対して数万の同時接続をシミュレートし、 負荷テストを実⾏することが可能なソリューション • AWS CloudFormation で 必要なリソースをデプロイ後、 Amazon S3 にてホストされる Webコンソールにアクセスし テストを実⾏する CloudFormation テンプレート AWS
  11. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Distributed Load Testing on AWS の利⽤⼿順 STEP 1 AWS上に必要リソースをデプロイする STEP 2 Webコンソールにログインする STEP 3 パラメータを指定しテストを実⾏する STEP 4 実⾏結果を確認する
  12. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (1 / 4) AWS上に必要リソースをデプロイする Ø ソリューションのWebページから 「AWSコンソールで起動する」を実⾏ https://aws.amazon.com/jp/solutions/implement ations/distributed-load-testing-on-aws/ Ø デプロイ時に以下の情報を指定 Ø Webコンソールのユーザー名とメールアドレス Ø デプロイ時のVPC(既存または新規) STEP 1 AWS
  13. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (2 / 4) Webコンソールにログインする • 指定のメールアドレスに届いた メール本⽂に記載のURLにアクセス • メールに記載されたユーザー名と 初期パスワードを⼊⼒してログイン STEP 2 <メール本⽂>
  14. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (3 / 4) パラメータを指定しテストを実⾏する Ø パラメータには接続先エンドポイント、 並列実⾏数、テスト時間等を指定可能 Ø Test Typeで「JMeter」を指定すれば JMeter (テストフレームワーク) の シナリオファイルを利⽤可 STEP 3 Apache JMeter https://jmeter.apache.org/
  15. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (4 / 4) 実⾏結果を確認する Ø 応答時間やエラーの情報とともに、 テストの実⾏結果が表⽰される Ø 履歴画⾯から過去に実施した テスト結果にもアクセス可能 STEP 4
  16. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. お客様事例での活⽤ ü 本ソリューションを活⽤して、AWS上に迅速にテスト環境を構築 ü リリーススケジュールに影響を与えずに性能・負荷テストを実施できた AWS Distributed Load Testing on AWS お客様拠点 AWS サービス1 クライアント サービス2 サービス3 サービス4 サービス5 ...
  17. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 3. AWS X-Ray による 性能・負荷テスト実⾏結果の分析
  18. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS X-Ray とは • アプリケーションの分析およびデバッグのためのAWSサービス アプリケーションやその基盤となるサービスの実⾏状況を把握し、 パフォーマンスの問題やエラーの根本原因の特定に活⽤できる
  19. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS X-Ray の主な機能①︓サービスマップ • 成功した呼び出し • 4xx エラー • 5xx エラー • スロットリングエラー 平均レイテンシ (ms) トレース数 (trace/min) サービス名 サービスの分類 サービスマップ 収集したトレースデータを 元にサービス間で⾏われて いるリクエストを可視化
  20. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS X-Ray の主な機能②︓トレースリスト トレースリスト (詳細) トレースリスト (⼀覧) サービスマップ (再掲) トレースデータの詳細を表⽰ 収集されたトレースデータの⼀覧を表⽰
  21. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. AWS X-Ray の利⽤⼿順 STEP 1 アプリケーションコードを修正する STEP 2 各種AWSサービスでトレース有効化設定を⾏う STEP 3 AWS X-Ray の設定を変更する STEP 4 リクエストを実⾏後、結果を確認する
  22. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (1 / 4) アプリケーションコードを修正する Ø 受信リクエスト / 送信リクエストを トレースするための記述が必要 Ø 利⽤する⾔語、フレームワーク、 ライブラリに応じてコードを修正 STEP 1 AWS Fargate Application Load Balancer Amazon DynamoDB AWS Fargate 上流側 (Upstream) 下流側 (Downstream) <アプリケーションの構成例> 利⽤⾔語 フレームワーク ( 受信リクエストで利⽤ ) ライブラリ ( 送信リクエストで利⽤ ) Node.js express axios, aws-sdk それぞれに応じたコードの修正を⾏う 受信リクエスト 送信リクエスト
  23. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 修正例 (Node.js の例) 受信リクエストをトレースする場合の例 ( 利⽤フレームワーク: express ) const app = express(); const AWSXRay = require('aws-xray-sdk’); app.use(AWSXRay.express.openSegment('MyApp')); app.get('/', function (req, res) { res.render('index'); }); app.use(AWSXRay.express.closeSegment()); const AWSXRay = require('aws-xray-sdk’); AWSXRay.captureHTTPsGlobal(require('http’)); AWSXRay.capturePromise(); const axios = require('axios’); ... 送信リクエストをトレースする場合の例 ( 利⽤ライブラリ: axios ) 参考︓ • https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-instrumenting-your-app.html • https://d1.awsstatic.com/webinars/jp/pdf/services/20200526_BlackBelt_X-Ray.pdf
  24. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (2 / 4) 各種AWSサービスでトレースの 有効化設定を⾏う Ø サービスごとに設定⽅法が異なる STEP 2 <AWSサービスの構成例> AWSサービスに応じた有効化設定を⾏う フロントエンド(SPA) BFF バックエンド #1 AWS クライアント AWS Fargate Application Load Balancer Amazon DynamoDB AWS Fargate Amazon Aurora AWS Fargate バックエンド #2 Amazon Aurora AWS Fargate ... AWS Cloud Map お客様拠点
  25. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 設定例 (Amazon ECS の例) • AWS X-Ray デーモンの Docker コンテナをサイドカーとして設定 ... { "name": "xray-daemon", "image": "amazon/aws-xray-daemon", "cpu": 32, "memoryReservation": 256, "portMappings" : [ { "hostPort": 0, "containerPort": 2000, "protocol": "udp" } ], } ... AWS X-Ray API AWS X-Ray デーモンコンテナ アプリケーションコンテナ AWS X-Ray SDK Amazon ECS タスク アプリケーション タスク定義内の Container Definition の例
  26. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 設定例 (AWS Lambda の例) • AWS Lambda 関数の設定で “アクティブトレース” を有効化 • Amazon ECS とは異なりサイドカーコンテナの設定は不要
  27. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 設定例 (その他のAWSサービス) • その他のAWSサービスの有効化⽅法は AWS X-Ray のドキュメントに記載 https://docs.aws.amazon.com/ja_jp/xray/latest/devguide/xray-services.html
  28. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (3 / 4) AWS X-Ray の設定を変更する Ø サンプリングルール等の設定を変更 Ø サンプリングルールはX-Rayトレース データの記録頻度を制御する設定 → 利⽤料⾦やパフォーマンスに影響 STEP 3 デフォルトのサンプリングルールは以下︓ • 1秒ごとに初回のリクエストは必ずトレース • 初回以降のリクエストは全体の5%のみトレース サンプリングルール設定 デフォルトの サンプリングルール 例: ヘルスチェック⽤ リクエストのトレースを 抑制するルール AWS X-Ray の料⾦ https://aws.amazon.com/jp/xray/pricing/
  29. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. 利⽤⼿順の詳細 (4 / 4) リクエストを実⾏後、結果を確認する Ø エンドポイントに対してリクエストを 実⾏ Ø サービスマップやトレースリストで 想定通りの表⽰となることを確認 STEP 4 トレースリスト サービスマップ
  30. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. お客様事例での活⽤ ü AWS X-Ray を利⽤し、性能・負荷テスト実⾏時の応答時間やエラー発⽣有無を より細かい単位で確認し、テスト結果の妥当性を判断 ü サービスのボトルネックとなる箇所を特定しながら分析・デバッグを実施 トレースリスト サービスマップ AWS X-Ray
  31. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 4. まとめ
  32. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. まとめ ü Distributed Load Testing on AWS と AWS X-Ray の活⽤することで、 AWS上のマイクロサービスに対する効率的な性能・負荷テストの実⾏が可能 AWS Distributed Load Testing on AWS お客様拠点 AWS サービス1 クライアント サービス2 サービス3 サービス4 サービス5 ... AWS X-Ray
  33. © 2022, Amazon Web Services, Inc. or its affiliates. All

    rights reserved. Thank you! © 2022, Amazon Web Services, Inc. or its affiliates. All rights reserved. 平⾕ 皓倫 Akinori Hiratani ⼩深⽥ 翔⼀郎 Shoichiro Kobukata