LoginSignup
14
16

More than 1 year has passed since last update.

LOCUSTをとりあえず動かすところまでの流れまとめ

Last updated at Posted at 2020-10-21

LOCUSTとは

負荷試験ツール
Pythonで簡単に定義できる

環境

Python3.7
locust 1.3.1

インストール

$ pip install locust

※locustioだとエラーで怒られるので注意

locustfile.pyを作成

from locust import HttpUser, TaskSet, task, between, constant

class UserBehavior(TaskSet):

    @task(1)
    def search(self):
        self.client.get("/hoge", verify=False)

class WebsiteUser(HttpUser):

    tasks = {UserBehavior:1}
    wait_time = constant(0)

コマンド実行

$ locust

Webコンソール(GUI)起動

ブラウザで http://localhost:8089/ にアクセス

設定は上から順に

Number of total users to simulate(最大同時接続ユーザ数)
Spawn rate(1秒ごとに増やすユーザ数)
Host(負荷試験する対象URL)

Start swarmingで実行

参考

https://locust.io/
https://qiita.com/naoki114/items/7ae5a045bb08c4950b04

14
16
1

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
14
16