

Le traduzioni sono generate tramite traduzione automatica. In caso di conflitto tra il contenuto di una traduzione e la versione originale in Inglese, quest'ultima prevarrà.

# Ottimizza la tua istanza EC2 per ottimizzarne le prestazioni


**Nota**  
Se hai effettuato il provisioning delle risorse AWS utilizzando CloudFormation modelli, queste ottimizzazioni vengono applicate automaticamente. Se hai utilizzato un'AMI o hai creato manualmente l'istanza EC2, questi aggiustamenti delle prestazioni devono essere applicati per ottenere le prestazioni più affidabili.

Ricordati di riavviare l'istanza dopo aver applicato qualsiasi ottimizzazione.

**Argomenti**
+ [Ottimizza le interruzioni hardware e le code di ricezione: influisce sulla CPU e sulla rete](#tune-hardware-interrupts)
+ [Tune Rx interrupt coalescenza: influisce sulla rete](#tune-rx-interrupts)
+ [Tune Rx ring buffer: influisce sulla rete](#tune-rx-ring-buffer)
+ [Tune CPU C-State: influisce sulla CPU](#tune-cpu-c-state)
+ [Riserva le porte di ingresso: influisce sulla rete](#reserve-ingress-ports)
+ [Riavviare](#reboot)

## Ottimizza le interruzioni hardware e le code di ricezione: influisce sulla CPU e sulla rete


Questa sezione configura l'utilizzo del core della CPU di systemd, SMP IRQs, Receive Packet Steering (RPS) e Receive Flow Steering (RFS). Vedi [Appendice: Parametri consigliati per l'accordatura interrupt/RPS](#recommended-parameters) una serie di impostazioni consigliate in base al tipo di istanza che stai utilizzando.

1. Allontana i processi systemd dai core della CPU dell'agente.

1. Indirizza le richieste di interruzione hardware lontano dai core della CPU dell'agente.

1. Configura RPS per evitare che la coda hardware di una singola scheda di interfaccia di rete diventi un collo di bottiglia nel traffico di rete.

1. Configura RFS per aumentare la frequenza di accesso alla cache della CPU e quindi ridurre la latenza di rete.

Lo `set_irq_affinity.sh` script fornito dall'RPM configura tutto quanto sopra per te. Aggiungi a crontab, in modo che venga applicato ad ogni avvio:

```
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
```
+ Sostituiscilo `interrupt_core_list` con core riservati al kernel e al sistema operativo, in genere il primo e il secondo insieme a coppie di core hyperthreaded. Questo non dovrebbe sovrapporsi ai core selezionati sopra. (Es: '0,1,48,49' per un'istanza Hyper-Thread da 96 CPU).
+ `rps_core_mask`è una maschera di bit esadecimale che specifica quali devono elaborare i pacchetti in entrata, con ogni cifra che CPUs rappresenta 4. CPUs Deve inoltre essere separato da virgole ogni 8 caratteri a partire da destra. Si consiglia di consentire tutto CPUs e lasciare che la cache gestisca il bilanciamento.
  + Per visualizzare l'elenco dei parametri consigliati per ogni tipo di istanza, fare riferimento a. [Appendice: Parametri consigliati per l'accordatura interrupt/RPS](#recommended-parameters)
+  Esempio di istanza da 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
  ```

## Tune Rx interrupt coalescenza: influisce sulla rete


 La coalescenza delle interruzioni aiuta a prevenire l'inondazione del sistema host con troppe interruzioni e aiuta ad aumentare la velocità di trasmissione della rete. Con questa configurazione, i pacchetti vengono raccolti e viene generata una singola interruzione ogni 128 microsecondi. Aggiungi a crontab, in modo che venga applicato ad ogni avvio: 

```
echo "@reboot sudo ethtool -C ${interface} rx-usecs 128 tx-usecs 128 >>/var/log/user-data.log 2>&1" >>/var/spool/cron/root
```
+ Sostituisci `interface` con l'interfaccia di rete (adattatore ethernet) configurata per ricevere dati. In genere, si `eth0` tratta dell'interfaccia di rete predefinita assegnata a un'istanza EC2.

## Tune Rx ring buffer: influisce sulla rete


 Aumenta il numero di ingressi ad anello per il ring buffer Rx per evitare cadute o sovraccarichi di pacchetti durante le connessioni interrotte. Aggiungi al crontab, in modo che sia impostato correttamente su ogni avvio: 

```
echo "@reboot sudo ethtool -G ${interface} rx 16384 >>/var/log/user-data.log 2>&1" >>/var/spool/cron/root
```
+ Sostituisci `interface` con l'interfaccia di rete (adattatore ethernet) configurata per ricevere dati. In genere, si `eth0` tratta dell'interfaccia di rete predefinita assegnata a un'istanza EC2.
+ Se si configura un'istanza `c6i` familiare, è necessario modificare il comando per impostare il ring buffer su`8192`, anziché. `16384`

## Tune CPU C-State: influisce sulla CPU


 Imposta lo stato C della CPU per evitare l'inattività, che può causare la perdita di pacchetti durante l'avvio di un contatto. Richiede il riavvio dell'istanza. 

```
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
```

## Riserva le porte di ingresso: influisce sulla rete


 Riservate tutte le porte nell'intervallo `AwsGroundStationAgentEndpoint` di porte degli indirizzi di ingresso per evitare conflitti con l'utilizzo del kernel. Il conflitto di utilizzo delle porte porterà a problemi di contatto e di consegna dei dati. 

```
echo "net.ipv4.ip_local_reserved_ports=${port_range_min}-${port_range_max}" >> /etc/sysctl.conf
```
+ Esempio: `echo "net.ipv4.ip_local_reserved_ports=42000-43500" >> /etc/sysctl.conf`.

## Riavviare


Dopo che tutte le regolazioni sono state applicate correttamente, riavviate l'istanza per rendere effettive le regolazioni.

```
sudo reboot
```

## Appendice: Parametri consigliati per l'accordatura interrupt/RPS


 Questa sezione determina i valori dei parametri consigliati da utilizzare nella sezione di ottimizzazione Tune Hardware Interrupts and Receive Queues - Impact CPU and Network. 


| Family | Tipo di istanza | \$1 \$1interrupt\$1core\$1list\$1 | \$1 \$1rps\$1core\$1mask\$1 | 
| --- | --- | --- | --- | 
|  c7i  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/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/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  |  [\[See the AWS documentation website for more details\]](http://docs.aws.amazon.com/it_it/ground-station/latest/gs-agent-ug/ec2-instance-performance-tuning.html)  | 