To get Best Performance for Nginx with AWS Load Balancer

0

How to get Best Performance for Nginx with AWS Load Balancer? I get error in worker connections and php fpm max children.

1回答
2
承認された回答

Hello.

I also answered the following URL.
https://repost.aws/ja/questions/QUkFxoqAy4QSCYTO-Vn2MH5A/nginx-php-error-in-ec2-with-lb

I often calculate numbers using the following calculations.

pm.max_children = available memory of instance / average memory usage of php-fpm process

If you are using Linux, you can get the average memory used by the php-fpm process using the following command.

ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'

I often set "worker_connections" to about twice the number shown in the error.
In your case, I think it would be a good idea to set it to around "1,536".
Be careful not to set the number larger than "worker_rlimit_nofile".
https://nginx.org/en/docs/ngx_core_module.html#worker_connections

It should be kept in mind that this number includes all connections (e.g. connections with proxied servers, among others), not only connections with clients. Another consideration is that the actual number of simultaneous connections cannot exceed the current limit on the maximum number of open files, which can be changed by worker_rlimit_nofile.

You can check the number of files that can be handled by the OS using the following command.

cat /proc/sys/fs/file-max

Therefore, I think it is best to calculate "worker_rlimit_nofile" as follows.

worker_rlimit_nofile = Number of files that can be handled by the OS / Number of Nginx processes
profile picture
エキスパート
回答済み 1ヶ月前
profile picture
エキスパート
レビュー済み 1ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ