

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# EC2 インスタンスのパフォーマンスを調整する


**注記**  
CloudFormation テンプレートを使用して AWS リソースをプロビジョニングした場合、これらのチューニングは自動的に適用されます。AMI を使用した場合、または EC2 インスタンスを手動で作成した場合、最も信頼性の高いパフォーマンスを実現するには、これらのパフォーマンスチューニングを適用する必要があります。

チューニングを適用した後は、必ずインスタンスを再起動してください。

**トピック**
+ [ハードウェア割り込みの調整とキューの受信 - CPU とネットワークに影響](#tune-hardware-interrupts)
+ [Rx 割り込みの結合を調整する - ネットワークに影響します](#tune-rx-interrupts)
+ [Rx リングバッファを調整する - ネットワークに影響します](#tune-rx-ring-buffer)
+ [CPU C 状態を調整する - CPU に影響します](#tune-cpu-c-state)
+ [進入ポートを予約する - ネットワークに影響します](#reserve-ingress-ports)
+ [リブート](#reboot)

## ハードウェア割り込みの調整とキューの受信 - CPU とネットワークに影響


このセクションでは、systemd、SMP IRQ、受信パケットステアリング (RPS)、受信フローステアリング (RFS) の CPU コア使用率を設定します。使用しているインスタンスタイプに基づく一連の推奨設定については、「[付録: 割り込み/RPS チューニングの推奨パラメータ](#recommended-parameters)」を参照してください。

1. systemd プロセスをエージェント CPU コアから切り離します。

1. ハードウェア割り込みリクエストをエージェント CPU コアから離してルーティングします。

1. 1 つのネットワークインターフェイスカードのハードウェアキューがネットワークトラフィックのボトルネックにならないように RPS を設定します。

1. CPU キャッシュヒットレートを高め、ネットワーク遅延を低減するように RFS を設定します。

RPM が提供する `set_irq_affinity.sh` スクリプトは、上記のすべてを自動的に構成します。を crontab に追加すると、起動ごとに適用されます。

```
echo "@reboot sudo /opt/aws/groundstation/bin/set_irq_affinity.sh '${interrupt_core_list}' '${rps_core_mask}' >> /var/log/user-data.log 2>&1" >>/var/spool/cron/root
```
+ をカーネルと OS 用に予約されたコア`interrupt_core_list`に置き換えます。通常は 1 番目と 2 番目のコアペアとハイパースレッドコアペアです。これと、上記で選択したコアとが重複しないようにしてください。(例: ハイパースレッドの 96-CPU インスタンスの場合は「0,1,48,49」）。
+ `rps_core_mask` は、受信パケットを処理する CPU を指定する 16 進数のビットマスクで、各桁は 4 個の CPU を表します。また、右から 8 文字ごとにカンマで区切る必要があります。すべての CPU を許可し、キャッシュにバランシングを任せることをお勧めします。
  + 各インスタンスタイプに推奨されるパラメータのリストについては、「[付録: 割り込み/RPS チューニングの推奨パラメータ](#recommended-parameters)」を参照してください。
+  96-CPU インスタンスの例: 

  ```
  echo "@reboot sudo /opt/aws/groundstation/bin/set_irq_affinity.sh '0,1,48,49' 'ffffffff,ffffffff,ffffffff' >> /var/log/user-data.log 2>&1" >>/var/spool/cron/root
  ```

## Rx 割り込みの結合を調整する - ネットワークに影響します


 割り込み合体により、ホストシステムに大量の割り込みが発生するのを防ぎ、ネットワークのスループットを向上させることができます。この構成では、パケットが収集され、128 マイクロ秒ごとに 1 つの割り込みが発生します。を crontab に追加すると、起動ごとに適用されます。

```
echo "@reboot sudo ethtool -C ${interface} rx-usecs 128 tx-usecs 128 >>/var/log/user-data.log 2>&1" >>/var/spool/cron/root
```
+ `interface` を、データを受信するように設定されたネットワークインターフェイス (イーサネットアダプタ) に置き換えます。通常、これは EC2 インスタンスに割り当てられたデフォルトのネットワークインターフェイス`eth0`です。

## Rx リングバッファを調整する - ネットワークに影響します


 Rx リングバッファのリングエントリ数を増やして、バースト接続中のパケットドロップやオーバーランを防止します。を crontab に追加すると、起動するたびに正しく設定されます。

```
echo "@reboot sudo ethtool -G ${interface} rx 16384 >>/var/log/user-data.log 2>&1" >>/var/spool/cron/root
```
+ `interface` を、データを受信するように設定されたネットワークインターフェイス (イーサネットアダプタ) に置き換えます。通常、これは EC2 インスタンスに割り当てられたデフォルトのネットワークインターフェイス`eth0`です。
+ `c6i` ファミリーインスタンスを設定する場合、リングバッファを ではなく `8192`に設定するためにコマンドを変更する必要があります`16384`。

## CPU C 状態を調整する - CPU に影響します


 CPU C ステートを設定して、コンタクトの開始時にパケットが失われる原因となるアイドリングを防止します。インスタンスの再起動が必要です。

```
echo "GRUB_CMDLINE_LINUX_DEFAULT=\"console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 nvme_core.io_timeout=4294967295 intel_idle.max_cstate=1 processor.max_cstate=1 max_cstate=1\"" >/etc/default/grub
echo "GRUB_TIMEOUT=0" >>/etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
```

## 進入ポートを予約する - ネットワークに影響します


 カーネルの使用状況と競合しないように、`AwsGroundStationAgentEndpoint` の入力アドレスのポート範囲内のすべてのポートを予約します。ポートの使用が競合すると、コンタクトやデータ配信の失敗につながります。

```
echo "net.ipv4.ip_local_reserved_ports=${port_range_min}-${port_range_max}" >> /etc/sysctl.conf
```
+ 例えば、`echo "net.ipv4.ip_local_reserved_ports=42000-43500" >> /etc/sysctl.conf` などです。

## リブート


すべてのチューニングが正常に適用されたら、インスタンスを再起動してチューニングを有効にします。

```
sudo reboot
```

## 付録: 割り込み/RPS チューニングの推奨パラメータ


 このセクションでは、チューニングセクション「ハードウェア割り込みと受信キューのチューニング - CPU とネットワークに影響あり」セクションで使用するための推奨パラメータ値を決定します。


| ファミリー | インスタンスタイプ | \$1\$1interrupt\$1core\$1list\$1 | \$1\$1rps\$1core\$1mask\$1 | 
| --- | --- | --- | --- | 
|  c7i  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  C6i  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  c5  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  c5n  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  m5  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  r5  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  r5n  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  g4dn  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  p4d  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 
|  p3dn  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/ja_jp/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 