LoginSignup
3

More than 5 years have passed since last update.

pm2でプロセスを多重化しロードバランシングを行う

Posted at

pm2でプロセスを多重化しロードバランシングを行う

pm2のインストール

npm install pm2 -g

pm2経由でアプリの起動

pm2 start pm2-bootstrap.json
pm2-bootstrap.json
{
    "apps" : [
        {
            "name"        : "public-tutorial",
            "script"      : "./app.js",
            "instances"   : 2,
            "exec_mode"   : "fork_mode",
            "node_args"   : "--stack-size=10240000",
            "env"         : {
                "NODE_ENV": "localhost"
            }
        }
    ]
}

instance
: 起動するプロセス数を指定する

exec_mode
: fork_mode / cluster_mode
クラスターモードはベータ版なので商用環境で使うなという警告文がでる

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
3