[GH-ISSUE #6541] [Question]: How to reduce master-node sync bandwidth and CPU with ~100 nodes #4388

Open
opened 2026-10-31 20:39:19 +07:00 by bsakaguchi · 11 comments
Owner

Originally created by @CD-D on GitHub (Sep 15, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6541

What are you trying to do?

I have a VPS connected to 100 nodes, with 100 inbound connections configured for 5 users. Currently, I'm experiencing abnormal bandwidth consumption: upload is steadily at 126.96 KB/s and download at 271.79 KB/s, resulting in excessive traffic usage and high CPU load. How can I reduce the communication frequency between nodes to save bandwidth or lower the system load?

What have you already tried?

Downgrade to version 3.6.0 and disable Xray.

3x-ui version

3.8.0

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 24.04

Screenshots or config snippets

No response

Before submitting

  • I read the Wiki and searched existing issues.
  • This is a usage question, not a bug report.
  • This question is written in English.
Originally created by @CD-D on GitHub (Sep 15, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6541 ### What are you trying to do? I have a VPS connected to 100 nodes, with 100 inbound connections configured for 5 users. Currently, I'm experiencing abnormal bandwidth consumption: upload is steadily at 126.96 KB/s and download at 271.79 KB/s, resulting in excessive traffic usage and high CPU load. How can I reduce the communication frequency between nodes to save bandwidth or lower the system load? ### What have you already tried? Downgrade to version 3.6.0 and disable Xray. ### 3x-ui version 3.8.0 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 24.04 ### Screenshots or config snippets _No response_ ### Before submitting - [x] I read the [Wiki](https://github.com/MHSanaei/3x-ui/wiki) and searched [existing issues](../issues?q=is%3Aissue). - [x] This is a usage question, not a bug report. - [x] This question is written in English.
Author
Owner

@github-actions[bot] commented on GitHub (Sep 15, 2026):

What you are seeing is the master↔node sync protocol, not Xray — and there is currently no setting or environment variable to slow it down. The cadence is a compile-time constant, so the only lever you have today is how many nodes each panel polls directly.

I retitled the issue from the empty [Question]: to something searchable; your text is untouched.

Why the traffic is constant

Two cron jobs poll every enabled node every 5 seconds (internal/web/web.go:303-304):

cadenceNodeHeartbeat = "@every 5s"
cadenceNodeTraffic   = "@every 5s"

Per online node, that is:

every requests where
5s GET panel/api/server/status service/node.go:1254 (heartbeat probe)
5s GET panel/api/server/descendants runtime/remote.go:685
5s GET panel/api/inbounds/list runtime/remote.go:754
5s POST panel/api/clients/onlinesByGuid runtime/remote.go:764
5s POST panel/api/clients/lastOnline runtime/remote.go:777
5s POST panel/api/clients/activeInbounds runtime/remote.go:784
10s GET + POST panel/api/server/clientIps runtime/remote.go:913, :927
10s POST panel/api/clients/clientIpsByGuid runtime/remote.go:936
30s POST panel/api/inbounds/pushClientTraffics runtime/remote.go:804

The 10s and 30s intervals are nodeClientIpSyncInterval and nodeGlobalPushInterval in internal/web/job/node_traffic_sync_job.go:22,24.

Counting one 30-second window per node: 6 requests × 6 ticks + 3 requests × 3 ticks + 1 = 46. With 100 online nodes that is 4600 requests per 30s ≈ 153 HTTPS requests per second, continuously, whether or not anyone is using the panel.

Against your own figures that works out to ≈1.8 KB per response (271.79 KB/s ÷ 153) and ≈0.83 KB per request (126.96 KB/s ÷ 153) — and responses are already gzipped (internal/web/web.go:201). So the volume you measured is consistent with the protocol running normally at 100 nodes; it is not a leak or a runaway loop. The two biggest payloads are panel/api/inbounds/list, which returns each node's full inbound list (settings, streamSettings, sniffing, per-client stats — not just counters), and the client-IP table the master pushes back to every node every 10s.

What actually reduces it today

  1. Disable nodes you are not using. Both jobs skip a disabled node entirely before any network call — node_heartbeat_job.go:49 (if !n.Enable { continue }) and node_traffic_sync_job.go:116 (if !n.Enable || n.Status != "online" { continue }). A disabled node costs exactly zero requests.
  2. Close the panel tab on the master when you are not watching it. Both jobs gate their websocket fan-out on websocket.HasClients() (node_heartbeat_job.go:63, node_traffic_sync_job.go:161). With no browser connected the master skips GetNodeTreeView(), GetAllClientTraffics(), GetClientsLastOnline() and GetInboundsTrafficSummary() on every tick. This cuts master CPU and DB load; it does not cut node bandwidth.
  3. Cut the number of direct nodes per panel. A panel only polls its own node rows; a node's own sub-nodes are learned read-only through the single descendants call (service/node_tree.go:69 and the comment at :99-104). Splitting 100 nodes into, say, 10 sub-masters of 10 nodes each means the top panel polls 10, not 100. I cannot quantify the net saving for you — the aggregate data still has to travel — but the request rate on the top panel drops by the same factor.
  4. Operational, not a code fact: if master and nodes share a private network, pointing each node's Address at its private IP keeps this traffic off billed public egress.

What will not help

  • Inbound sync = selected. The tag filter runs on the master after the full list has already been downloaded — FilterNodeSnapshot in service/node.go:817-835 trims snap.Inbounds in memory. It saves no bandwidth.
  • Downgrading. git show v3.6.0:internal/web/web.go has the identical cadenceNodeHeartbeat = "@every 5s" / cadenceNodeTraffic = "@every 5s" at lines 291-292; those constants were centralised in d14f341b, first released in v3.4.0. That is why 3.6.0 behaved the same.
  • Stopping Xray. These two jobs are panel-side and run regardless of Xray's state.

One thing that is working in your favour: a tick that cannot finish in 5s is dropped rather than queued (running.TryLock(), node_traffic_sync_job.go:82), and the traffic sync only runs 8 nodes concurrently (nodeTrafficSyncConcurrency = 8, line 19). So the panel self-throttles instead of piling up — at the cost of node status lagging behind.

Notes for the maintainer

Three things I found while tracing this that amplify the cost specifically at high node counts:

  1. service/node.go:1274 — probe() calls runtime.HTTPClientForNode(n, proxyURL) directly rather than the cached Remote.httpClient() (runtime/remote.go:143-152, guarded by clientOnce sync.Once). For an https node in skip/pin/mtls mode, HTTPClientForNode builds a brand-new http.Client + http.Transport on every call (runtime/tls_client.go:197-229), so each heartbeat starts with an empty pool: a full TCP+TLS handshake every 5s per node, with the discarded transport holding an idle connection until IdleConnTimeout: 60 * time.Second. verify mode and plain http are unaffected — they get the shared defaultNodeHTTPClient (tls_client.go:194-196, pinned by TestHTTPClientForNodeVerifyShared). At 100 skip/pin nodes this is ~20 fresh handshakes per second.
  2. job/node_traffic_sync_job.go:450 — GetAllInboundClientIps() is an uncached full-table Find (service/inbound_client_ips.go:15-20) run once per node inside syncOne, and the whole cluster-wide IP table is then POSTed to each node (line 456). That is O(nodes × table) in both DB reads and upload bytes, every 10s.
  3. runtime/tls_client.go:137-144 — the shared verify-mode client is capped at MaxIdleConns: 64 across all hosts, so with 100 nodes the pool cannot hold one connection per node and a share of them re-handshake each tick.

The multi-node doc only says the master "sends a heartbeat every few seconds" (docs/content/docs/en/operations/multi-node.mdx:32); it documents neither the poll set nor any scaling guidance, which is why this cost is invisible until you are at 100 nodes.

I could not determine which TLS verify mode your nodes use, which decides whether point 1 applies to you. If you can say whether they are verify, skip, pin or mtls — and whether the panel is SQLite or PostgreSQL — that would pin down how much of your CPU load is TLS handshakes versus DB work.

Verdict: Feature request — a configurable node-poll cadence (and a leaner per-tick request set) does not exist today; the bandwidth itself is the designed protocol, not a defect.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:5676714554 --> @github-actions[bot] commented on GitHub (Sep 15, 2026): What you are seeing is the master↔node sync protocol, not Xray — and there is currently **no setting or environment variable to slow it down**. The cadence is a compile-time constant, so the only lever you have today is *how many nodes each panel polls directly*. I retitled the issue from the empty `[Question]:` to something searchable; your text is untouched. ## Why the traffic is constant Two cron jobs poll every enabled node every 5 seconds (`internal/web/web.go:303-304`): ```go cadenceNodeHeartbeat = "@every 5s" cadenceNodeTraffic = "@every 5s" ``` Per online node, that is: | every | requests | where | | --- | --- | --- | | 5s | `GET panel/api/server/status` | `service/node.go:1254` (heartbeat probe) | | 5s | `GET panel/api/server/descendants` | `runtime/remote.go:685` | | 5s | `GET panel/api/inbounds/list` | `runtime/remote.go:754` | | 5s | `POST panel/api/clients/onlinesByGuid` | `runtime/remote.go:764` | | 5s | `POST panel/api/clients/lastOnline` | `runtime/remote.go:777` | | 5s | `POST panel/api/clients/activeInbounds` | `runtime/remote.go:784` | | 10s | `GET` + `POST panel/api/server/clientIps` | `runtime/remote.go:913`, `:927` | | 10s | `POST panel/api/clients/clientIpsByGuid` | `runtime/remote.go:936` | | 30s | `POST panel/api/inbounds/pushClientTraffics` | `runtime/remote.go:804` | The 10s and 30s intervals are `nodeClientIpSyncInterval` and `nodeGlobalPushInterval` in `internal/web/job/node_traffic_sync_job.go:22,24`. Counting one 30-second window per node: `6 requests × 6 ticks + 3 requests × 3 ticks + 1 = 46`. With **100 online nodes that is 4600 requests per 30s ≈ 153 HTTPS requests per second, continuously**, whether or not anyone is using the panel. Against your own figures that works out to ≈1.8 KB per response (271.79 KB/s ÷ 153) and ≈0.83 KB per request (126.96 KB/s ÷ 153) — and responses are already gzipped (`internal/web/web.go:201`). So the volume you measured is consistent with the protocol running normally at 100 nodes; it is not a leak or a runaway loop. The two biggest payloads are `panel/api/inbounds/list`, which returns each node's **full** inbound list (`settings`, `streamSettings`, `sniffing`, per-client stats — not just counters), and the client-IP table the master pushes back to every node every 10s. ## What actually reduces it today 1. **Disable nodes you are not using.** Both jobs skip a disabled node entirely before any network call — `node_heartbeat_job.go:49` (`if !n.Enable { continue }`) and `node_traffic_sync_job.go:116` (`if !n.Enable || n.Status != "online" { continue }`). A disabled node costs exactly zero requests. 2. **Close the panel tab on the master when you are not watching it.** Both jobs gate their websocket fan-out on `websocket.HasClients()` (`node_heartbeat_job.go:63`, `node_traffic_sync_job.go:161`). With no browser connected the master skips `GetNodeTreeView()`, `GetAllClientTraffics()`, `GetClientsLastOnline()` and `GetInboundsTrafficSummary()` on every tick. This cuts master CPU and DB load; it does not cut node bandwidth. 3. **Cut the number of *direct* nodes per panel.** A panel only polls its own node rows; a node's own sub-nodes are learned read-only through the single `descendants` call (`service/node_tree.go:69` and the comment at `:99-104`). Splitting 100 nodes into, say, 10 sub-masters of 10 nodes each means the top panel polls 10, not 100. I cannot quantify the net saving for you — the aggregate data still has to travel — but the request rate on the top panel drops by the same factor. 4. Operational, not a code fact: if master and nodes share a private network, pointing each node's **Address** at its private IP keeps this traffic off billed public egress. ## What will not help - **`Inbound sync = selected`.** The tag filter runs on the master *after* the full list has already been downloaded — `FilterNodeSnapshot` in `service/node.go:817-835` trims `snap.Inbounds` in memory. It saves no bandwidth. - **Downgrading.** `git show v3.6.0:internal/web/web.go` has the identical `cadenceNodeHeartbeat = "@every 5s"` / `cadenceNodeTraffic = "@every 5s"` at lines 291-292; those constants were centralised in d14f341b, first released in v3.4.0. That is why 3.6.0 behaved the same. - **Stopping Xray.** These two jobs are panel-side and run regardless of Xray's state. One thing that is working in your favour: a tick that cannot finish in 5s is dropped rather than queued (`running.TryLock()`, `node_traffic_sync_job.go:82`), and the traffic sync only runs 8 nodes concurrently (`nodeTrafficSyncConcurrency = 8`, line 19). So the panel self-throttles instead of piling up — at the cost of node status lagging behind. ## Notes for the maintainer Three things I found while tracing this that amplify the cost specifically at high node counts: 1. `service/node.go:1274` — `probe()` calls `runtime.HTTPClientForNode(n, proxyURL)` directly rather than the cached `Remote.httpClient()` (`runtime/remote.go:143-152`, guarded by `clientOnce sync.Once`). For an https node in `skip`/`pin`/`mtls` mode, `HTTPClientForNode` builds a brand-new `http.Client` + `http.Transport` on every call (`runtime/tls_client.go:197-229`), so each heartbeat starts with an empty pool: a full TCP+TLS handshake every 5s per node, with the discarded transport holding an idle connection until `IdleConnTimeout: 60 * time.Second`. `verify` mode and plain `http` are unaffected — they get the shared `defaultNodeHTTPClient` (`tls_client.go:194-196`, pinned by `TestHTTPClientForNodeVerifyShared`). At 100 `skip`/`pin` nodes this is ~20 fresh handshakes per second. 2. `job/node_traffic_sync_job.go:450` — `GetAllInboundClientIps()` is an uncached full-table `Find` (`service/inbound_client_ips.go:15-20`) run **once per node** inside `syncOne`, and the whole cluster-wide IP table is then POSTed to each node (line 456). That is O(nodes × table) in both DB reads and upload bytes, every 10s. 3. `runtime/tls_client.go:137-144` — the shared `verify`-mode client is capped at `MaxIdleConns: 64` across *all* hosts, so with 100 nodes the pool cannot hold one connection per node and a share of them re-handshake each tick. The multi-node doc only says the master "sends a heartbeat every few seconds" (`docs/content/docs/en/operations/multi-node.mdx:32`); it documents neither the poll set nor any scaling guidance, which is why this cost is invisible until you are at 100 nodes. **I could not determine** which `TLS verify` mode your nodes use, which decides whether point 1 applies to you. If you can say whether they are `verify`, `skip`, `pin` or `mtls` — and whether the panel is SQLite or PostgreSQL — that would pin down how much of your CPU load is TLS handshakes versus DB work. Verdict: Feature request — a configurable node-poll cadence (and a leaner per-tick request set) does not exist today; the bandwidth itself is the designed protocol, not a defect. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@ssp-timapheev commented on GitHub (Sep 15, 2026):

Все клиенты опять слетели reality verification failed...
Как вылечить?
Минимальную версию клиента поставил (с прошлого обновления все слетело и снова установил), что ещё может быть?

All clients have crashed again: reality verification failed...
How to fix it?
I installed the minimum client version (everything crashed after the previous update, and I installed it again), what else could be the issue?

<!-- gh-comment-id:5677591136 --> @ssp-timapheev commented on GitHub (Sep 15, 2026): Все клиенты опять слетели reality verification failed... Как вылечить? Минимальную версию клиента поставил (с прошлого обновления все слетело и снова установил), что ещё может быть? All clients have crashed again: reality verification failed... How to fix it? I installed the minimum client version (everything crashed after the previous update, and I installed it again), what else could be the issue?
Author
Owner

@CD-D commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

<!-- gh-comment-id:5678764302 --> @CD-D commented on GitHub (Sep 15, 2026): My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.
Author
Owner

@BlindMaster24 commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

Don't worry, it'll be fixed. I'll let you know. Can you test it later on the dev version?

<!-- gh-comment-id:5679099106 --> @BlindMaster24 commented on GitHub (Sep 15, 2026): > My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle. Don't worry, it'll be fixed. I'll let you know. Can you test it later on the dev version?
Author
Owner

@BlindMaster24 commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

all 2 problems

<!-- gh-comment-id:5679105943 --> @BlindMaster24 commented on GitHub (Sep 15, 2026): > My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle. all 2 problems
Author
Owner

@CD-D commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

all 2 problems

No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore.

<!-- gh-comment-id:5679149085 --> @CD-D commented on GitHub (Sep 15, 2026): > > My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle. > > all 2 problems No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore.
Author
Owner

@BlindMaster24 commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

all 2 problems

No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore.

Ok

<!-- gh-comment-id:5679169024 --> @BlindMaster24 commented on GitHub (Sep 15, 2026): > > > My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle. > > > > > > all 2 problems > > No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore. Ok
Author
Owner

@BlindMaster24 commented on GitHub (Sep 15, 2026):

My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle.

all 2 problems

No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore.

Try now

<!-- gh-comment-id:5680444767 --> @BlindMaster24 commented on GitHub (Sep 15, 2026): > > > My current solution is to disable all the nodes, but manually turning off 100 of them is quite a hassle. > > > > > > all 2 problems > > No problem, I'll do my best to cooperate with you. I really hope a bulk enable/disable option for nodes can be added. I don't want to click through them one by one anymore. Try now
Author
Owner

@zxcOvosh commented on GitHub (Sep 26, 2026):

Все клиенты опять слетели reality verification failed...
Как вылечить?
Минимальную версию клиента поставил (с прошлого обновления все слетело и снова установил), что ещё может быть?

All clients have crashed again: reality verification failed...
How to fix it?
I installed the minimum client version (everything crashed after the previous update, and I installed it again), what else could be the issue?

Нашли решение?

<!-- gh-comment-id:5846485939 --> @zxcOvosh commented on GitHub (Sep 26, 2026): > Все клиенты опять слетели reality verification failed... > Как вылечить? > Минимальную версию клиента поставил (с прошлого обновления все слетело и снова установил), что ещё может быть? > > All clients have crashed again: reality verification failed... > How to fix it? > I installed the minimum client version (everything crashed after the previous update, and I installed it again), what else could be the issue? Нашли решение?
Author
Owner

@ssp-timapheev commented on GitHub (Sep 29, 2026):

Переключение на v26.6.27 больше ничто не помогло

<!-- gh-comment-id:5891929102 --> @ssp-timapheev commented on GitHub (Sep 29, 2026): Переключение на v26.6.27 больше ничто не помогло
Author
Owner

@zxcOvosh commented on GitHub (Oct 11, 2026):

Переключение на v26.6.27 больше ничто не помогло

Устанавливали новые версии? Как они себя ведут?

<!-- gh-comment-id:6114185264 --> @zxcOvosh commented on GitHub (Oct 11, 2026): > Переключение на v26.6.27 больше ничто не помогло Устанавливали новые версии? Как они себя ведут?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#4388
No description provided.