Wallarm NGINXノードのリソース割り当て¶
Wallarm NGINXノードに割り当てるメモリおよびCPUリソースの量は、リクエスト処理の品質と速度を左右します。本ドキュメントでは、セルフホスト型NGINXノードのメモリ割り当てに関する推奨事項を説明します。
NGINXフィルタリングノードの主なメモリおよびCPUの消費源は次の2つです。
-
wstore、別名postanalyticsモジュールです。これはローカルのデータ分析バックエンドであり、フィルタリングノードにおける主なメモリ消費源です。
-
NGINXは、フィルタリングノードおよびリバースプロキシの主要コンポーネントです。
NGINXのCPU使用率は、RPSの水準、リクエストおよびレスポンスの平均サイズ、ノードが処理するカスタムルールセットのルール数、Base64やデータ圧縮などのデータエンコーディングの種類やレイヤーなど、多くの要因に依存します。
平均すると、CPUコア1つで約500 RPSを処理できます。本番モードでの運用時は、NGINXプロセスに少なくともCPUコア1つ、wstoreプロセスにコア1つを割り当てることを推奨します。多くの場合、最初はフィルタリングノードを過剰にプロビジョニングし、実際の本番トラフィックレベルにおけるCPUとメモリの使用状況を確認したうえで、割り当てリソースを徐々に適正水準まで減らすことを推奨します(トラフィックのスパイクやノード冗長性に備えて、最低でも2倍の余裕を確保します)。
wstore¶
Postanalytics uses the in-memory storage wstore. The wstore database is used to keep in a circular buffer a local copy of the data stream processed by a filtering node, including request/response headers and request bodies (but not response bodies).
To make a filtering node efficient, the database should keep at least 15 minutes of transmitted data with about 2x overhead for data serialization. Following these points, the amount of memory can be estimated by the formula:
For example, if a filtering node is handling at peak 50 Mbps of end user requests, the required wstore database memory consumption can be estimated as the following:
Kubernetes Ingress Controllerでのリソース割り当て¶
wstore memory is configured using the following sections in the values.yaml
file:
-
To set up memory in GB:
-
To set up memory in CPU:
Listed parameters are set by using the --set
option of the commands helm install
and helm upgrade
, for example:
helm install --set controller.wallarm.postanalytics.arena='1.0' <INGRESS_CONTROLLER_RELEASE_NAME> wallarm/wallarm-ingress -n <KUBERNETES_NAMESPACE>
There are also other parameters required for correct Ingress controller installation. Please pass them in the --set
option too.
All-in-One Installerを使用する場合のリソース割り当て¶
wstoreのメモリサイズは、/opt/wallarm/env.list
構成ファイル内のSLAB_ALLOC_ARENA
属性で制御します。以下の手順でメモリを割り当てます。
-
編集のために
/opt/wallarm/env.list
ファイルを開きます: -
メモリサイズを指定するように
SLAB_ALLOC_ARENA
属性を設定します。値には整数または浮動小数点数を使用できます(小数点はドット.
です)。例:
-
Wallarmサービスを再起動します:
Amazon Machine Imageを使用する場合のリソース割り当て¶
-
Wallarmノードは、割り当てられたリソースをwstoreとNGINXの間で自動的に分配します。
-
Wallarm NGINX Node AMIからWallarmノードインスタンスを起動する場合、テスト用途には
t3.medium
インスタンスタイプ、本番にはm4.xlarge
の使用を推奨します。
NGINX¶
NGINXのメモリ消費は多くの要因に左右されます。平均的には次の式で見積もれます。
例:
-
フィルタリングノードはピーク時に10000件の同時リクエストを処理し、
-
リクエストの平均サイズは5 kBです。
NGINXのメモリ消費は次のように見積もれます。
メモリ量を割り当てるには:
-
NGINX Ingress controllerのPod(
ingress-controller
)の場合、helm install
またはhelm upgrade
の--set
オプションを使用して、values.yaml
ファイル内で次のセクションを設定します。
パラメータを変更するコマンドの例:
helm install --set controller.resources.limits.cpu='2000m',controller.resources.limits.memory='3280Mi' <INGRESS_CONTROLLER_RELEASE_NAME> wallarm/wallarm-ingress -n <KUBERNETES_NAMESPACE>
正しくIngress controllerをインストールするには、その他のパラメータも必要です。これらも
--set
オプションで指定してください。 -
その他のデプロイ方法では、NGINXの構成ファイルを使用します。
トラブルシューティング¶
Wallarmノードが想定以上のメモリやCPUを消費する場合は、リソース使用量を削減するために、CPU高負荷のトラブルシューティングに記載された推奨事項を確認し、適用してください。