# Performance Optimization

> **`Network Optimization`**

{% tabs %}
{% tab title="1. Configure Firewall" %}
Allow necessary ports:

```
sudo ufw allow 28967/tcp
sudo ufw allow 28967/udp
sudo ufw allow 9000/tcp
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Optimize TCP Settings" %}
Add to `/etc/sysctl.conf`:

```
net.core.rmem_max = 4194304
net.core.wmem_max = 4194304
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 65536 4194304
```

Apply changes:

```
sudo sysctl -p
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="3. Use a Content Delivery Network (CDN)" %}
Configure Cloudflare or similar CDN to proxy traffic to your node for improved performance and DDoS protection.
{% endtab %}
{% endtabs %}

> **`Storage Optimization`**

{% tabs %}
{% tab title="1. Use High-Performance SSDs" %}
NVMe SSDs are recommended for optimal I/O performance.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Implement RAID" %}
For improved reliability and performance, consider RAID 10 configuration:

{% code overflow="wrap" %}

```
sudo mdadm --create /dev/md0 --level=10 --raid-devices=4 /dev/sda /dev/sdb /dev/sdc /dev/sdd
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="3. File System Tuning" %}
For ext4 file system, adjust mount options in `/etc/fstab`:

```
UUID=your-uuid /mnt/data ext4 defaults,noatime,nodiratime,discard 0 0
```

{% endtab %}
{% endtabs %}

> **`Resource Management`**

{% tabs %}
{% tab title="1. Monitoring with Prometheus and Grafana" %}
Install Prometheus:

```
sudo apt install -y prometheus
```

{% code title="Configure Prometheus to scrape your node metrics by adding to /etc/prometheus/prometheus.yml:" %}

```yaml
scrape_configs:
  - job_name: 'daeta_node'
    static_configs:
      - targets: ['localhost:9000']
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Set Resource Limits" %}
Create a systemd override file:

```
sudo systemctl edit daeta-node
```

{% code title="Add the following:" %}

```
[Service]
CPUQuota=800%
MemoryMax=14G
```

{% endcode %}

This limits the node to 8 CPU cores and 14GB of RAM.
{% endtab %}
{% endtabs %}

> **`Troubleshooting`**
>
> `Common Issue and Solutions`

{% tabs %}
{% tab title="1. Node Not Syncing" %}
{% code title="Check network connectivity:" %}

```bash
daeta-node network test
```

{% endcode %}

{% code title="Ensure ports are open:" %}

```bash
nc -zv satellite.daeta.io 7777
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Low Earnings" %}
{% code title="Verify storage allocation:" %}

```bash
daeta-node storage info
```

{% endcode %}

{% code title="Check reputation score:" %}

```bash
daeta-node reputation
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="3. High Resource Usage" %}
{% code title="Monitor resource usage:" %}

```bash
top -c -p $(pgrep -d',' -f daeta-node)
```

{% endcode %}

Adjust resource limits as needed.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="4. Failed Audits" %}
{% code title="Check disk health:" %}

```bash
sudo smartctl -a /dev/sda
```

{% endcode %}

{% code title="Verify data integrity:" %}

```
daeta-node audit test
```

{% endcode %}
{% endtab %}
{% endtabs %}

> **`Loggind and Debugging`**

{% tabs %}
{% tab title="1. View Logs" %}

```bash
journalctl -u daeta-node -f
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Enable Debug Logging" %}
{% code title="Edit /etc/daeta/config.yaml:" %}

```yaml
debug:
  level: "debug"
  log_path: "/var/log/daeta-debug.log"
```

{% endcode %}
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="3. Analyze Logs" %}
{% code title="Use log analysis tools like lnav for better insights:" %}

```bash
sudo apt install lnav
lnav /var/log/daeta-debug.log
```

{% endcode %}
{% endtab %}
{% endtabs %}

> **`Best Practices`**

{% tabs %}
{% tab title="1. Regular Maintenance" %}
Schedule weekly system updates.

Perform monthly disk health checks.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="2. Security" %}
Use SSH key-based authentication.

Implement fail2ban for brute-force protection.

Keep the node software up-to-date.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="3. Redundancy" %}
Set up RAID for storage redundancy.

Consider running multiple nodes in different locations.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="4. Community Engagement" %}
Join the DÆTA Discord.

Participate in network stress tests and challenges.
{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="5. Performance Monitoring" %}
Set up alerts for disk space, CPU usage and bandwidth consumption.

Regularly review and optimize based on performance metrics.
{% endtab %}
{% endtabs %}

By following these guidelines and best practices, node operators can ensure optimal performance, maximize earnings and contribute to the overall health and reliability of the DÆTA network.
