はじめに
st2のworkerを増やすための手順を記載。
st2でジョブ制御するとst2actionrunnerにそれなりの負荷がかかる。
標準は10プロセスしか起動しないため、スケールアップを行う場合はプロセスを増加する必要がある。
調査した範囲では動的にプロセス数を上げ下げすることはできなかったので手動による変更手順をまとめた。
前提
環境
項目 | 説明 |
---|---|
OS | Ubuntu 16.04 |
StackStorm | 2.8.1 |
Python | 2.7.12 (st2が使ってるpython) |
quick installで入れただけ。
手順
st2をまず停止する
$ sudo st2ctl stop
workerのプロセス数を変更
/etc/default/st2actionrunner
WORKERS=12
- defaultは10
- stopする前にこの値を変更すると、WORKERSの数までしかstopしてくれないので注意
st2を起動
$ sudo st2ctl start
process確認
$ ps -ef | grep st2actionrunne[r] | cat -n
1 root 26938 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
2 root 26942 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
3 root 26946 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
4 root 26949 1 0 07:21 ? 00:00:05 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
5 root 26953 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
6 root 26956 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
7 root 26959 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
8 root 26962 1 0 07:21 ? 00:00:07 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
9 root 26965 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
10 root 26968 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
11 root 26973 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
12 root 26976 1 0 07:21 ? 00:00:06 /opt/stackstorm/st2/bin/python /opt/stackstorm/st2/bin/st2actionrunner --config-file /etc/st2/st2.conf
調査した時のメモ
ドキュメントを見つけられなかったのでスクリプトを見た。
どうやらsystemctlで動いている
$ systemctl status st2actionrunner.service
● st2actionrunner.service - StackStorm service st2actionrunner
Loaded: loaded (/lib/systemd/system/st2actionrunner.service; enabled; vendor preset: enabled)
Active: active (exited) since Thu 2018-11-15 06:45:08 UTC; 1h 26min ago
Process: 26750 ExecStop=/bin/bash /opt/stackstorm/st2/bin/runners.sh stop (code=exited, status=0/SUCCESS)
Process: 26930 ExecStart=/bin/bash /opt/stackstorm/st2/bin/runners.sh start (code=exited, status=0/SUCCESS)
Main PID: 26930 (code=exited, status=0/SUCCESS)
Tasks: 0
Memory: 0B
CPU: 0
CGroup: /system.slice/st2actionrunner.service
以下の記述がある
/lib/systemd/system/st2actionrunner.service
[Service]
EnvironmentFile=-/etc/default/st2actionrunner
ExecStart=/bin/bash /opt/stackstorm/st2/bin/runners.sh start
ExecStop=/bin/bash /opt/stackstorm/st2/bin/runners.sh stop
書いてあった
/opt/stackstorm/st2/bin/runners.sh
# Default number of workers
WORKERS="${WORKERS:-10}"
ここまで調査して思ったけどst2のgitにst2docがあることを思い出したので、そっちにちゃんとした情報があったかも…まだ見てないです