LoginSignup
0
2

More than 3 years have passed since last update.

serverless artilleryでサーバレスに負荷テスト

Posted at

Links

環境

serverless artillery 0.5.2
Serverless Framework 1.82.0
npm 6.13.4

※注意:2020/12/19現在Serverless Frameworkが最新だとserverless artillery動作せず

実行手順

インストール

$ npm install -g serverless-artillery

ディレクトリと設定ファイルの作成

$ mkdir my-test && cd $_

# 設定用ファイルの作成
$ slsart configure
$ touch script.yml

ファイルの編集

serverless.yml

  • regionsの設定を追記(デフォルトだとus-east-1
  • LambdaにVPCを紐付ける場合はvpc設定も追記
provider:
  name: aws
  region: ap-northeast-1
  vpc:
    securityGroupIDs:
      - xxxxx
    subnetIDs:
      - xxxxx

script.yml

config:
  target: "http://api-host"
  phases:
    - 
      duration: 30
      arrivalRate: 3
scenarios:
  -
    flow:
      -
        post:
          url: "/sample"
          headers:
            Content-Type: "application/json"
          json:
            Name: "User Taro"
            Age: 20
            ...

※注意:Content-Typeヘッダを設定しているが、実際に実行するとヘッダ名がcontent-typeと小文字になるので、処理に影響する場合は対策が必要

デプロイとテストの実行

  • ~/.aws/credentialsの設定は事前にしておく
$ AWS_PROFILE=your-profile slsart deploy --stage test
$ AWS_PROFILE=your-profile slsart invoke --stage test

※注意:VPC Endpoint経由でAPIを叩く場合、Lambdaからローカルに結果が返ってこないので、CloudWatch Logsを確認する必要がある(回避方法あるかも?)

リソースの削除

$ AWS_PROFILE=your-profile slsart remove --stage test1
0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2