mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-12-03 19:11:53 +07:00
[GH-ISSUE #6541] [Question]: How to reduce master-node sync bandwidth and CPU with ~100 nodes #4388
Labels
No labels
backlog
bug
clarification needed
documentation
duplicate
enhancement
github_actions
good first issue
invalid
javascript
New Feature
PR welcomed
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
MHSanaei/3x-ui#4388
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
@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):Per online node, that is:
GET panel/api/server/statusservice/node.go:1254(heartbeat probe)GET panel/api/server/descendantsruntime/remote.go:685GET panel/api/inbounds/listruntime/remote.go:754POST panel/api/clients/onlinesByGuidruntime/remote.go:764POST panel/api/clients/lastOnlineruntime/remote.go:777POST panel/api/clients/activeInboundsruntime/remote.go:784GET+POST panel/api/server/clientIpsruntime/remote.go:913,:927POST panel/api/clients/clientIpsByGuidruntime/remote.go:936POST panel/api/inbounds/pushClientTrafficsruntime/remote.go:804The 10s and 30s intervals are
nodeClientIpSyncIntervalandnodeGlobalPushIntervalininternal/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 arepanel/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
node_heartbeat_job.go:49(if !n.Enable { continue }) andnode_traffic_sync_job.go:116(if !n.Enable || n.Status != "online" { continue }). A disabled node costs exactly zero requests.websocket.HasClients()(node_heartbeat_job.go:63,node_traffic_sync_job.go:161). With no browser connected the master skipsGetNodeTreeView(),GetAllClientTraffics(),GetClientsLastOnline()andGetInboundsTrafficSummary()on every tick. This cuts master CPU and DB load; it does not cut node bandwidth.descendantscall (service/node_tree.go:69and 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.What will not help
Inbound sync = selected. The tag filter runs on the master after the full list has already been downloaded —FilterNodeSnapshotinservice/node.go:817-835trimssnap.Inboundsin memory. It saves no bandwidth.git show v3.6.0:internal/web/web.gohas the identicalcadenceNodeHeartbeat = "@every 5s"/cadenceNodeTraffic = "@every 5s"at lines 291-292; those constants were centralised ind14f341b, first released in v3.4.0. That is why 3.6.0 behaved the same.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:
service/node.go:1274—probe()callsruntime.HTTPClientForNode(n, proxyURL)directly rather than the cachedRemote.httpClient()(runtime/remote.go:143-152, guarded byclientOnce sync.Once). For an https node inskip/pin/mtlsmode,HTTPClientForNodebuilds a brand-newhttp.Client+http.Transporton 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 untilIdleConnTimeout: 60 * time.Second.verifymode and plainhttpare unaffected — they get the shareddefaultNodeHTTPClient(tls_client.go:194-196, pinned byTestHTTPClientForNodeVerifyShared). At 100skip/pinnodes this is ~20 fresh handshakes per second.job/node_traffic_sync_job.go:450—GetAllInboundClientIps()is an uncached full-tableFind(service/inbound_client_ips.go:15-20) run once per node insidesyncOne, 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.runtime/tls_client.go:137-144— the sharedverify-mode client is capped atMaxIdleConns: 64across 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 verifymode your nodes use, which decides whether point 1 applies to you. If you can say whether they areverify,skip,pinormtls— 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.
@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?
@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.
@BlindMaster24 commented on GitHub (Sep 15, 2026):
Don't worry, it'll be fixed. I'll let you know. Can you test it later on the dev version?
@BlindMaster24 commented on GitHub (Sep 15, 2026):
all 2 problems
@CD-D commented on GitHub (Sep 15, 2026):
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.
@BlindMaster24 commented on GitHub (Sep 15, 2026):
Ok
@BlindMaster24 commented on GitHub (Sep 15, 2026):
Try now
@zxcOvosh commented on GitHub (Sep 26, 2026):
Нашли решение?
@ssp-timapheev commented on GitHub (Sep 29, 2026):
Переключение на v26.6.27 больше ничто не помогло
@zxcOvosh commented on GitHub (Oct 11, 2026):
Устанавливали новые версии? Как они себя ведут?