# Understanding "overloaded" status and how to diagnose it

在中继搜索中，如果中继过载，中继昵称旁边将显示黄色小点。 这意味着以下负载指标中，至少有一个被触发了：

- 任何由于内存压力的 Tor OOM 调用
- 任何 ntor onionskins 被丢弃
- TCP 端口耗尽

注意：如果中继达到超载状态，在中继恢复后仍将显示 72 小时。

假若发生中继过载，请执行以下步骤：

1. 查看 https://status.torproject.org/ 的“Tor 网络”（Tor Network）部分，是否存在任何已知问题。
2. 调整系统`sysctl`优化网络、内存和 CPU 的负载。
3. 启用 `MetricsPort`了解实际情况。

## 调整 `sysctl` 优化网络、内存和 CPU 负载

### TCP 端口耗尽

如果遇到 TCP 端口耗尽的问题，可以考虑扩大本地端口的范围。 扩大范围可以用

`# sysctl -w net.ipv4.ip_local_port_range="15000 64000"`

或

`# echo 15000 64000 > /proc/sys/net/ipv4/ip_local_port_range`

请记住，如上所述，调整的 `sysctl`在重启时丢失，而不是永久的。 为了永久有效，需将其添加到 `/etc/sysctl.conf` 或 `/etc/sysctl.d/`中的文件。

## MetricsPort

想要了解 Tor 中继和 Tor 网络的运行情况，提供并可访问中继指标是至关重要的。 从 0.4.6+ 开始，中继超载信息被加入到中继描述符中，但直到 Tor 0.4.7.1-alpha 之后，才提供底层中继指标的接口：指标接口。

### 启用 MetricsPort

通过 torrc 配置选项`MetricsPort`，Tor 提供指标端口的访问。

重要的是要明白， 对 Tor 网络用户来说，公开暴露 Tor MetricsPort 是为危险的，因此该端口默认不启用，而且其访问必须受到访问政策的约束。 所以，在打开这个端口时，请务必小心谨慎，并在调试完毕后把它关闭。

假设你是运行了 Tor 中继的服务器上的唯一用户。 可以在 torrc 文件中添加以下内容来启用指标端口：

    MetricsPort 127.0.0.1:9035
    MetricsPortPolicy accept 127.0.0.1

然后使用以下命令可轻松获取指标：

`# curl http://127.0.0.1:9035/metrics`

默认为 Prometheus 格式。

注意： 该服务器上的每个用户都能够访问上述例子中的中继指标。 通常，可通过`MetricsPortPolicy` 设置严格的访问政策，并考虑使用操作系统防火墙功能进行深度防御。

关于 `MetricsPort` 和`MetricsPortPolicy`更详细的解释，请参阅 tor 的 man 页面。

### MetricsPort 输出

以下示例为`MetricsPort` 启用后生成的输出（删去了所有与拥塞控制有关的指标，因为我们仍然需要稳定该接口）：

    # HELP tor_relay_connections Total number of opened connections
    # TYPE tor_relay_connections gauge
    tor_relay_connections{type="OR listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="OR listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="OR listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="OR listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="OR",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="OR",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="OR",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="OR",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Exit",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Exit",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Exit",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Exit",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Socks listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Socks listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Socks listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Socks listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Socks",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Socks",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Socks",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Socks",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Directory listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Directory listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Directory listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Directory listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Directory",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Directory",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Directory",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Directory",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Control listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Control listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Control listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Control listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Control",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Control",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Control",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Control",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Transparent pf/netfilter listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Transparent pf/netfilter listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Transparent pf/netfilter listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Transparent pf/netfilter listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Transparent natd listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Transparent natd listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Transparent natd listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Transparent natd listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="DNS listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="DNS listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="DNS listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="DNS listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Extended OR",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Extended OR",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Extended OR",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Extended OR",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Extended OR listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Extended OR listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Extended OR listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Extended OR listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="HTTP tunnel listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="HTTP tunnel listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="HTTP tunnel listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="HTTP tunnel listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Metrics listener",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Metrics listener",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Metrics listener",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Metrics listener",direction="received",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Metrics",direction="initiated",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Metrics",direction="initiated",state="opened",family="ipv6"} 0
    tor_relay_connections{type="Metrics",direction="received",state="opened",family="ipv4"} 0
    tor_relay_connections{type="Metrics",direction="received",state="opened",family="ipv6"} 0
    # HELP tor_relay_connections_total Total number of created/rejected connections
    # TYPE tor_relay_connections_total counter
    tor_relay_connections_total{type="OR listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="OR listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="OR listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="OR listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="OR listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="OR listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="OR",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="OR",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="OR",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="OR",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="OR",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="OR",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Exit",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Exit",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Exit",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Exit",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Exit",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Exit",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Socks listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Socks listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Socks listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Socks listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Socks listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Socks listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Socks",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Socks",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Socks",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Socks",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Socks",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Socks",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Directory listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Directory listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Directory listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Directory listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Directory listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Directory listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Directory",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Directory",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Directory",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Directory",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Directory",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Directory",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Control listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Control listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Control listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Control listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Control listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Control listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Control",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Control",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Control",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Control",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Control",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Control",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent pf/netfilter listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Transparent natd listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="DNS listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="DNS listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="DNS listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="DNS listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="DNS listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="DNS listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Extended OR listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="HTTP tunnel listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics listener",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics listener",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics listener",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics listener",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics listener",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics listener",direction="received",state="rejected",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics",direction="initiated",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics",direction="initiated",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics",direction="received",state="created",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics",direction="received",state="created",family="ipv6"} 0
    tor_relay_connections_total{type="Metrics",direction="received",state="rejected",family="ipv4"} 0
    tor_relay_connections_total{type="Metrics",direction="received",state="rejected",family="ipv6"} 0
    # HELP tor_relay_flag Relay flags from consensus
    # TYPE tor_relay_flag gauge
    tor_relay_flag{type="Fast"} 0
    tor_relay_flag{type="Exit"} 0
    tor_relay_flag{type="Authority"} 0
    tor_relay_flag{type="Stable"} 0
    tor_relay_flag{type="HSDir"} 0
    tor_relay_flag{type="Running"} 0
    tor_relay_flag{type="V2Dir"} 0
    tor_relay_flag{type="Sybil"} 0
    tor_relay_flag{type="Guard"} 0
    # HELP tor_relay_circuits_total Total number of circuits
    # TYPE tor_relay_circuits_total gauge
    tor_relay_circuits_total{state="opened"} 0
    # HELP tor_relay_streams_total Total number of streams
    # TYPE tor_relay_streams_total counter
    tor_relay_streams_total{type="BEGIN"} 0
    tor_relay_streams_total{type="BEGIN_DIR"} 0
    tor_relay_streams_total{type="RESOLVE"} 0
    # HELP tor_relay_traffic_bytes Traffic related counters
    # TYPE tor_relay_traffic_bytes counter
    tor_relay_traffic_bytes{direction="read"} 0
    tor_relay_traffic_bytes{direction="written"} 0
    # HELP tor_relay_dos_total Denial of Service defenses related counters
    # TYPE tor_relay_dos_total counter
    tor_relay_dos_total{type="circuit_rejected"} 0
    tor_relay_dos_total{type="circuit_killed_max_cell"} 0
    tor_relay_dos_total{type="circuit_killed_max_cell_outq"} 0
    tor_relay_dos_total{type="marked_address"} 0
    tor_relay_dos_total{type="marked_address_maxq"} 0
    tor_relay_dos_total{type="conn_rejected"} 0
    tor_relay_dos_total{type="concurrent_conn_rejected"} 0
    tor_relay_dos_total{type="single_hop_refused"} 0
    tor_relay_dos_total{type="introduce2_rejected"} 0
    # HELP tor_relay_load_onionskins_total Total number of onionskins handled
    # TYPE tor_relay_load_onionskins_total counter
    tor_relay_load_onionskins_total{type="tap",action="processed"} 0
    tor_relay_load_onionskins_total{type="tap",action="dropped"} 0
    tor_relay_load_onionskins_total{type="fast",action="processed"} 0
    tor_relay_load_onionskins_total{type="fast",action="dropped"} 0
    tor_relay_load_onionskins_total{type="ntor",action="processed"} 0
    tor_relay_load_onionskins_total{type="ntor",action="dropped"} 0
    tor_relay_load_onionskins_total{type="ntor_v3",action="processed"} 0
    tor_relay_load_onionskins_total{type="ntor_v3",action="dropped"} 0
    # HELP tor_relay_exit_dns_query_total Total number of DNS queries done by this relay
    # TYPE tor_relay_exit_dns_query_total counter
    tor_relay_exit_dns_query_total 0
    # HELP tor_relay_exit_dns_error_total Total number of DNS errors encountered by this relay
    # TYPE tor_relay_exit_dns_error_total counter
    tor_relay_exit_dns_error_total{reason="success"} 0
    tor_relay_exit_dns_error_total{reason="format"} 0
    tor_relay_exit_dns_error_total{reason="serverfailed"} 0
    tor_relay_exit_dns_error_total{reason="notexist"} 0
    tor_relay_exit_dns_error_total{reason="notimpl"} 0
    tor_relay_exit_dns_error_total{reason="refused"} 0
    tor_relay_exit_dns_error_total{reason="truncated"} 0
    tor_relay_exit_dns_error_total{reason="unknown"} 0
    tor_relay_exit_dns_error_total{reason="tor_timeout"} 0
    tor_relay_exit_dns_error_total{reason="shutdown"} 0
    tor_relay_exit_dns_error_total{reason="cancel"} 0
    tor_relay_exit_dns_error_total{reason="nodata"} 0
    # HELP tor_relay_load_oom_bytes_total Total number of bytes the OOM has freed by subsystem
    # TYPE tor_relay_load_oom_bytes_total counter
    tor_relay_load_oom_bytes_total{subsys="cell"} 0
    tor_relay_load_oom_bytes_total{subsys="dns"} 0
    tor_relay_load_oom_bytes_total{subsys="geoip"} 0
    tor_relay_load_oom_bytes_total{subsys="hsdir"} 0
    # HELP tor_relay_load_socket_total Total number of sockets
    # TYPE tor_relay_load_socket_total gauge
    tor_relay_load_socket_total{state="opened"} 0
    tor_relay_load_socket_total 0
    # HELP tor_relay_load_tcp_exhaustion_total Total number of times we ran out of TCP ports
    # TYPE tor_relay_load_tcp_exhaustion_total counter
    tor_relay_load_tcp_exhaustion_total 0
    # HELP tor_relay_load_global_rate_limit_reached_total Total number of global connection bucket limit reached
    # TYPE tor_relay_load_global_rate_limit_reached_total counter
    tor_relay_load_global_rate_limit_reached_total{side="read"} 0
    tor_relay_load_global_rate_limit_reached_total{side="write"} 0

下面解释其中一些行代表的意思：

### tor_relay_load_onionskins_total{type="ntor",action="dropped"} 0

当中继开始出现“dropped”时，通常是 CPU 或内存出现问题。

除了 在处理 “洋葱皮” 进程时，Tor 是单线程的。 在每个线路著名的“洋葱层”上，需要进行的加密工作就是“洋葱皮”。

当 Tor 处理这些层时，我们使用线程池，并将所有工作外包到该线程池。 可能出现，由于内存或 CPU 的压力，该线程池开始丢弃工作，进而触发一个超载状态。

如果服务器满负载运行，很可能触发它。

### tor_relay_exit_dns_error_total{...}

“*_dns_error_total” 领域的任何计数器（成功查询的除外）都表明可能存在 DNS 相关的问题。 然而，我们在 0.4.7 的发布周期中意识到，DNS 错误的噪音太大，且包含太多的假阳性，不可用于超载报告。 因此，从 0.4.6.9 和 0.4.7.4-alpha 开始，我们不再将其用于此目的。然而，为了便于中继操作员了解中继发生了什么，仍然保留了 DNS 指标。

DNS 超时问题和错误只适用于出口节点。

### tor_relay_load_oom_bytes_total{...}

内存不足调用表示这是内存的问题。 该中继需要更多的 RAM 或者它正在泄露内存。 如果 tor 出现内存泄露，请通过 Tor gitLab 或发送邮件至tor-relays 邮件列表报告这个问题。

Tor 自带 OOM 处理程序。当达到 tor 认为的可使用内存的 75% 时，将调用该处理程序。 因此，假设 Tor 认为它总共可以使用 2GB 内存，那么当内存使用量达到 1.5GB 时，它就会开始释放内存。 这视为超载状态。

为了估计可用的内存量，当 Tor 启动时，它将使用 `MaxMemInQueues`；如果未设置，将查看系统可用的内存总量并应用此算法：

    if RAM >= 8GB {
    memory = RAM * 40%
    } else {
    memory = RAM * 75%
    }
    /* Capped. */
    memory = min(memory, 8GB) -> [8GB on 64bit and 2GB on 32bit)
    /* Minimum value. */
    memory = max(250MB, memory)

为了避免过载状态，我们建议在 64 位上运行内存 2GB 以上的中继。 建议 4GB，当然，也可以增加更多的内存。 注意：如果您运行的是具有大量内存的强大服务器，那么即使您仍有大量内存未使用，由于默认的 8GB 队列大小限制，您也可能最终处于过载状态。在这种情况下，将适当的 `MaxMemInQueues` 条目添加到您的 `torrc` 配置中。

可能有人会注意到， Tor 可能被操作系统的 OOM 处理程序自身调用。 因为 tor 在启动时占用了系统的总内存，如果整个系统还有许多其他应用程序也在使用内存运行，那么最终占用太多内存。 在这种情况下，操作系统可能会使 Tor 的内存不足，而 Tor 甚至都没有注意到内存压力。

### tor_relay_load_socket_total

如果打开的 socket 端口数量接近或等于可用的总数，那么这就表明，中继 socket 端口快要用尽了。 解决方法是增加 Tor 进程的`ulimit -n` 。

### tor_relay_load_tcp_exhaustion_total

这几行表示中继的 TCP 端口快要用尽了。

尝试按照上述方法调整`sysctl`。

### tor_relay_load_global_rate_limit_reached_total

如果在短期内，这个计数器数值出现明显递增，那么这个中继发生了拥塞。 它很可能用作大型洋葱服务的守卫节点，或者用于在网络上进行 DDoS。

如果中继仍超载，而且不知道为什么，请联系 network-report@torproject.org。 可以使用 network-report OpenPGP 密钥来加密邮件。