A10 Thunder(vThunder、ACOS 5.2.0)の負荷分散では、クライアントからの初回のリクエストをどのサーバに転送するかを決める方式(ロードバランシング方式)を、ラウンドロビンや最小コネクションなどから選べます。この記事では、実務でよく使う4つの方式を設定し、振り分けの結果を確認します。
- ロードバランシング方式を設定する場所(サービスグループの Algorithm)
- ラウンドロビンと最小コネクションの動きと確認方法
- サーバ単位の重み付けラウンドロビンの設定
- サービスポート単位の重み付けラウンドロビンの設定
構成は 【A10 Thunder】サーバ負荷分散(L4)の基本設定と動作確認 5.2.0 のものを使います。サービスグループ sg-web に、Web-01(10.0.200.100)と Web-02(10.0.200.173)の TCP 80 がメンバーとして入っています。
ロードバランシング方式の設定場所
ロードバランシング方式は、サービスグループで設定します。GUI では ADC ›› SLB ›› Service Groups の一覧の Algorithm 列に、いまの方式が表示されます。何も変えなければ、ラウンドロビン(Round Robin)です。
この記事の画面は、実際の画面ではなく、検証時の画面から設定する項目(見るポイント)を抜き出して描いたイメージです。バージョンによって、項目の並びや表記は変わります。
| Status | Name | Type | Algorithm | Current | Total |
|---|---|---|---|---|---|
| sg-web | tcp | 1Round Robin | 0 | 0 | |
| Web-01 | 80 | 0 | 0 | ||
| Web-02 | 80 | 0 | 0 |
| No. | 表示 | 意味 |
|---|---|---|
| 1 | Algorithm | サービスグループのロードバランシング方式。既定のラウンドロビンになっています。 |
方式を変えるときは、一覧から sg-web を開き、Algorithm のプルダウンから選んで更新します。プルダウンには次の方式が並びます。この記事で使うのは、印を付けた4つです。
| Name | sg-web |
| Protocol | tcp |
| 1Algorithm |
選べる方式
Destination IP Hash Destination IP Only Hash Fastest Responses Least Request Source IP Hash Source IP Only Hash Weighted Round Robin Weighted round robin on service port level Round Robin Round Robin Strict Least Connection Service Least Connection Weighted Least Connection Service Weighted Least Connection Stateless DST IP Hash Stateless Per PKT Round Robin Stateless SRC DST IP Hash Stateless SRC DST IP Only Hash Stateless SRC IP Hash Stateless SRC IP Only hash |
| No. | 項目 | 設定内容 |
|---|---|---|
| 1 | Algorithm | ロードバランシング方式を選びます。この記事では Round Robin、Least Connection、Weighted Round Robin、Weighted round robin on service port level を順に試します。 |
| 2 | Update | サービスグループの設定を更新します。 |
ラウンドロビン(Round Robin)
既定の方式です。振り分け先のサーバに、順番に、均等に接続を振り分けます。Web-01 と Web-02 の2台にラウンドロビンを使うと、クライアントからのリクエストは2台に交互に振り分けられます。
何回かアクセスしたあとにサービスグループの一覧を見ると、接続の累計(Total)が Web-01 は 15、Web-02 は 14 で、ほぼ同じ数に振り分けられています。
| Status | Name | Algorithm | Current | Total |
|---|---|---|---|---|
| sg-web | Round Robin | 2 | 29 | |
| Web-01 | 1 | 115 | ||
| Web-02 | 1 | 14 |
| No. | 表示 | 意味 |
|---|---|---|
| 1 | Total(15/14) | メンバーごとの接続数の累計。Web-01 と Web-02 にほぼ均等に振り分けられています。Current はいま張られている接続の数です。 |
show slb service-group:振り分けの状況
CLI では show slb service-group で同じ情報を確認できます。
vThunder
vThunder# show slb service-group Total Number of Service Groups configured: 1 Current = Current Connections, Total = Total Connections Fwd-p = Forward packets, Rev-p = Reverse packets Peak-c = Peak connections Service Group Name Service Current Total Fwd-p Rev-p Peak-c ----------------------------------------------------------------------------------- *sg-web State: All Up Web-01:80 1 15 94 49 0 Web-02:80 1 14 84 44 0
最小コネクション(Least Connection)
いまの接続数(コネクション数)がいちばん少ないサーバに、次の接続を振り分けます。接続を長く保つ通信が混ざっていて、サーバごとに接続数の偏りが出やすい場合に向いた方式です。
Algorithm を Least Connection にする
ADC ›› SLB ›› Service Groups で sg-web を開き、Algorithm で Least Connection を選んで更新します。CLI では、サービスグループのモードで method least-connection を設定します。
vThunder
vThunder(config)# slb service-group sg-web tcp
vThunder(config-slb svc group)# method least-connection
vThunder(config-slb svc group)# exit
vThunder(config)#
結果を確認する
1台目のクライアントから接続して複数のコネクションを張らせ(Web-01 に振り分けられました)、続けて2台目、3台目のクライアントから接続すると、コネクションの少ない Web-02 に振り分けられました。サービスグループの一覧では、Algorithm が least-connection になっています。
| Status | Name | Algorithm | Current | Total |
|---|---|---|---|---|
| sg-web | 1least-connection | 4 | 31 | |
| Web-01 | 1 | 23 | ||
| Web-02 | 3 | 8 |
| No. | 表示 | 意味 |
|---|---|---|
| 1 | Algorithm least-connection | 方式が最小コネクションに変わっています。Total は Web-01 が 23、Web-02 が 8 で、接続数の少なかった Web-02 に新しい接続が振り分けられたあと、Current は Web-01 が 1、Web-02 が 3 になっています。 |
vThunder
vThunder# show slb service-group Total Number of Service Groups configured: 1 Current = Current Connections, Total = Total Connections Fwd-p = Forward packets, Rev-p = Reverse packets Peak-c = Peak connections Service Group Name Service Current Total Fwd-p Rev-p Peak-c ----------------------------------------------------------------------------------- *sg-web State: All Up Web-01:80 1 23 145 82 0 Web-02:80 3 8 71 51 0
最小コネクションが見ているのは、累計の Total ではなく、いま張られている接続の数(Current)です。Total に差があっても、Current が少ないサーバに振り分けられます。
重み付けラウンドロビン(Weighted Round Robin)
サーバごとに重み(Weight)を付けて、その比率でラウンドロビンします。性能の違うサーバを混ぜて使うときなどに、性能の高いサーバへ多く振り分けられます。今回は Web-01 と Web-02 を 10:1 にします。
Algorithm を Weighted Round Robin にする
sg-web の Algorithm で Weighted Round Robin を選んで更新します。CLI では method weighted-rr です。
vThunder
vThunder(config)# slb service-group sg-web tcp
vThunder(config-slb svc group)# method weighted-rr
vThunder(config-slb svc group)# exit
vThunder(config)#
サーバの重みを設定する
重み(Weight)はサーバ単位で設定します。ADC ›› SLB ›› Servers で Web-01 を Edit し、Advanced Fields の Weight を 10 に変えます。Web-02 は既定の 1 のままです。
| Name | Web-01 |
| Host | 10.0.200.100 |
| ⋮ (中略) | |
| Template Server | |
| Connection Resume | |
| 1Weight | 10 |
| Slow Start | ☐ |
| No. | 項目 | 設定内容 |
|---|---|---|
| 1 | Weight | サーバの重み。既定は 1 で、1〜1000 の範囲で指定できます。Web-01 を 10 にします。 |
CLI では、サーバのモードで weight を設定します。
vThunder
vThunder(config)# slb server Web-01 10.0.200.100
vThunder(config-real server)# weight 10
結果を確認する
接続の累計は Web-01 が 24、Web-02 が 2 で、おおよそ 10:1 の比率で振り分けられています。
| Status | Name | Algorithm | Total |
|---|---|---|---|
| sg-web | Weighted Round Robin | ||
| Web-01 | 124 | ||
| Web-02 | 2 |
| No. | 表示 | 意味 |
|---|---|---|
| 1 | Total(24/2) | 重み 10:1 に近い比率で、Web-01 に多く振り分けられています。 |
vThunder
vThunder#show slb service-group Total Number of Service Groups configured: 1 Current = Current Connections, Total = Total Connections Fwd-p = Forward packets, Rev-p = Reverse packets Peak-c = Peak connections Service Group Name Service Current Total Fwd-p Rev-p Peak-c ----------------------------------------------------------------------------------- *sg-web State: All Up Web-01:80 2 24 148 80 0 Web-02:80 0 2 13 7 0
サービスポートレベルの重み付けラウンドロビン
重み付けラウンドロビン(Weighted Round Robin)はサーバ単位の重みを使いました。サーバではなくサービスポート単位で重みを付けたい場合は、Weighted round robin on service port level を使います。今回は、Web-02 の TCP 80 の重みを 20 にします。
Algorithm を Weighted round robin on service port level にする
sg-web の Algorithm で Weighted round robin on service port level を選んで更新します。CLI では method service-weighted-rr です。
vThunder
vThunder(config)# slb service-group sg-web tcp
vThunder(config-slb svc group)# method service-weighted-rr
サービスポートの重みを設定する
重みは、サーバのサービスポートで設定します。ADC ›› SLB ›› Servers で Web-02 を開き、Port 80 を Edit して、Advanced Fields の Weight を 20 に変えて更新します。
| Name | Web-02 |
| Host | 10.0.200.173 |
| Port / Port Range | Protocol | Weight | Conn Limit | Health Check | Actions |
|---|---|---|---|---|---|
| 80 | tcp | 220 | 64000000 | Default | 1Edit |
| Weight | 20 |
| No. | 項目 | 設定内容 |
|---|---|---|
| 1 | Edit/Weight | Port 80 の編集を開き、Advanced Fields の Weight を 20 にします。ポートの重みも、既定は 1 で、1〜1000 の範囲で指定できます。 |
| 2 | Weight 20 | 更新すると、Port の一覧の Weight が 20 になります。 |
CLI では、サーバのポートのモードで weight を設定します。
vThunder
vThunder(config)# slb server Web-02 10.0.200.173 vThunder(config-real server)# port 80 tcp vThunder(config-real server-node port)# weight 20
結果を確認する
接続の累計は Web-01 が 4、Web-02 が 76 で、おおよそ 1:20 の比率で振り分けられています。
| Status | Name | Algorithm | Current | Total |
|---|---|---|---|---|
| sg-web | Weighted round robin on service port level | 2 | 80 | |
| Web-01 | 0 | 14 | ||
| Web-02 | 2 | 76 |
| No. | 表示 | 意味 |
|---|---|---|
| 1 | Total(4/76) | ポートの重み 1:20 に近い比率で、Web-02 に多く振り分けられています。 |
vThunder
vThunder# show slb service-group Total Number of Service Groups configured: 1 Current = Current Connections, Total = Total Connections Fwd-p = Forward packets, Rev-p = Reverse packets Peak-c = Peak connections Service Group Name Service Current Total Fwd-p Rev-p Peak-c ----------------------------------------------------------------------------------- *sg-web State: All Up Web-01:80 0 4 24 12 0 Web-02:80 2 76 477 259 0
この検証では、前の手順で設定した Web-01 のサーバ単位の重み 10 を残したままです。それでも結果は 1:20 に近い比率になっており、この方式ではサーバ単位の重みではなく、ポートの重みで振り分けられていることがわかります。方式を切り替えるときは、どちらの単位の重みが使われるかに注意してください。
まとめ
| 方式(GUI) | CLI(method) | 振り分け方 | 重みの設定場所 |
|---|---|---|---|
| Round Robin(既定) | round-robin | 順番に均等 | ― |
| Least Connection | least-connection | いまの接続数が最も少ないサーバ | ― |
| Weighted Round Robin | weighted-rr | 重みの比率で順番に | サーバ(slb server の weight) |
| Weighted round robin on service port level | service-weighted-rr | 重みの比率で順番に | サーバのポート(port の weight) |
振り分けの結果は、GUI のサービスグループの一覧か、CLI の show slb service-group の Total と Current で確かめられます。方式はサービスグループごとに選び、重みを使う方式では、サーバ単位かポート単位かで設定する場所が変わります。
コメント