A method for load balancing of transit nodes in a server in a P2P system
By employing multi-dimensional load monitoring and dynamic weight calculation methods, the problem of efficient scheduling and load balancing of relay servers in P2P networks was solved, enabling on-demand allocation of nodes and efficient utilization of resources, thereby improving system stability and response efficiency.
Patent Information
- Application Number
- CN202610379495.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-26
- Publication Date
- 2026-05-29
AI Technical Summary
In existing P2P network communication, relay servers struggle to achieve efficient scheduling in scenarios with a massive number of devices, resulting in uneven load distribution, resource waste, and high response latency.
By employing multi-dimensional load monitoring and dynamic weight calculation methods, the network bandwidth, CPU, memory, and concurrent connection load of the relay server are monitored in real time, and the node weights are dynamically adjusted to achieve weighted probability scheduling and full lifecycle management, thereby ensuring load balancing.
It improves the accuracy of load distribution and the system's adaptability, avoids node overload or resource idleness, enhances the stability and operational efficiency of the relay server cluster, and ensures the service quality of P2P communication.
Smart Images

Figure CN122120270A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, specifically to a load balancing method for server relay nodes in a P2P system. Background Technology
[0002] P2P systems are decentralized distributed network architectures. Their core lies in the equal status of each node, which functions as both a client and a server. It can actively request resources and directly provide services to other nodes, thus eliminating dependence on a single central server. In the P2P context, "server" does not refer to a traditional central control host, but rather to a node or mechanism within the network that performs specific collaborative functions. In a pure P2P network, all nodes share the server role, achieving distributed storage and sharing of resources. In a hybrid P2P network, there may be bootstrapping servers assisting new nodes in joining, index servers maintaining resource indexes, or relay servers responsible for data transfer when network address translation (NAT) fails. These components aim to assist node discovery and connection establishment, rather than monopolizing data exchange, thereby improving network efficiency while maintaining the advantages of decentralization. In P2P network communication, relay servers serve as crucial relay guarantees when network address translation (NAT) penetration fails, and their load balancing capabilities directly determine the system's quality of service. However, existing technologies struggle to meet the efficient scheduling needs of massive device scenarios, primarily due to five bottlenecks. First, the strategies are simplistic; traditional round-robin, random, or least-connection algorithms focus on only a single dimension and fail to perceive the true real-time load of nodes. Second, the evaluation is one-sided, neglecting the combined impact of critical resources such as bandwidth, CPU, and memory, resulting in an inaccurate measurement of a node's actual processing capacity. Third, the configuration is rigid; static weights cannot adapt to dynamically changing business loads, leading to delayed operational adjustments. Furthermore, facing the exponential growth of IoT devices and real-time communication requests, traditional scheduling algorithms are inefficient and have high response latency, ultimately resulting in severely uneven load distribution within the cluster and wasted resources. Therefore, there is an urgent need to construct an intelligent load balancing mechanism that integrates multi-dimensional indicators and supports real-time dynamic adjustments to address these pain points and improve the overall system stability. Summary of the Invention
[0003] The purpose of this invention is to provide a load balancing method for server relay nodes in a P2P system, which has the advantage of high efficiency and solves the problem that in existing P2P network communication, relay servers are unable to meet the high-efficiency scheduling requirements of massive device scenarios, and are prone to low scheduling efficiency and uneven load distribution. To achieve the above objectives, the present invention provides the following technical solution: a load balancing method for server relay nodes in a P2P system, comprising the following steps: S1. Real-time multi-dimensional load monitoring: Through the load monitoring module, the operation data of the relay node of each relay server is continuously collected. S2. Dynamic weight calculation: The data collected by the load monitoring module is substituted into the algorithm to calculate the load of each node, and the scheduling weight of each node is calculated based on the load. S3, weighted probability scheduling, arranges the scheduling weights of each node from smallest to largest and calculates the sum, generates a random number R within the sum interval, constructs different ranges of cumulative weight intervals based on the size of the scheduling weights, determines which cumulative weight interval the random number R falls into, and then assigns the node to the requester. S4 provides full lifecycle management of relay server nodes, manages and handles anomalies, and dynamically adjusts the weight of each node in real time based on updated load data, so that subsequent requests are distributed according to the latest weight, achieving dynamic load balancing. As a preferred embodiment of the server relay node load balancing method in a P2P system according to the present invention, the relay node operation data in S1 includes network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data. As a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, the network bandwidth load data is the real-time utilization rate of the node's uplink and downlink bandwidth, the CPU load data is the percentage of CPU usage, the memory usage load data is the proportion of used memory to total memory, and the concurrent connection load data is the number of currently active node connections. In a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, in step S2, when performing load calculation, the network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data are first uniformly converted to the same dimension range before performing comprehensive load calculation. As a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, the load calculation formula is as follows: Where L is the overall load value; ; ; . As a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, when calculating the scheduling weight based on the load, the comprehensive load value is converted into a scheduling weight, and the formula for calculating the scheduling weight is as follows: in For scheduling weights; The normalization coefficient; This is the overall load value. In a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, the random number R in S3 adopts a uniformly distributed random number generator, and the random number generator uses a random algorithm to ensure sampling uniformity. In a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, when constructing cumulative weight intervals of different ranges based on the size of the scheduling weight in step S3, a continuous numerical interval from 0 to the sum of the scheduling weights is first determined. Then, according to the arrangement order of the node scheduling weights, this total interval is sequentially divided among the nodes. The first node occupies an interval starting from 0 with a length equal to its weight value. The second node immediately follows the first node and occupies an interval with the same length equal to its weight. This process continues until all nodes are allocated, thus forming a sequence of cumulative weight intervals that are connected end to end. As a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, when managing and handling anomalies of relay server nodes in step S4, the node registration and discovery unit first realizes the dynamic access and exit of nodes, maintains a list of available nodes in real time, and performs periodic health checks to confirm online status. Once a node response timeout or service anomaly is detected, the anomaly handling unit intervenes, removes the faulty node from the scheduling list or reduces its weight, records detailed anomaly information, and triggers an alarm. At the same time, the capacity management unit continuously monitors the load of each node. When the number of concurrent connections of a node reaches a preset threshold, its weight is automatically downgraded to prevent overload. The statistical analysis unit aggregates and analyzes the number of request allocations, success rate, and average load indicators of each node to generate a load balancing effect report, thereby providing data support for the continuous optimization of the weighting algorithm and ensuring the high availability and stability of the entire relay service cluster. In a preferred embodiment of the load balancing method for server relay nodes in a P2P system according to the present invention, when dynamically adjusting the weights of each node in step S4, the monitoring module continuously collects network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data of each node and reports them in real time. Then, the weight calculation module dynamically calculates the comprehensive load value of each node based on these real-time data and a preset weight coefficient, and maps it to a scheduling weight. The scheduling decision module constructs a cumulative weight range based on the updated weight list, and uses a weighted probability sampling algorithm to automatically allocate requests by generating random numbers and matching nodes that fall into the range when subsequent requests arrive. Finally, the statistical analysis unit summarizes the number of request allocations, success rate, and average load of each node, and generates an effect report to assist in optimizing the weight parameters, thereby forming dynamic load balancing. Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention significantly improves the accuracy of load allocation and the system's adaptability by introducing a multi-dimensional load monitoring and dynamic weight calculation mechanism. Unlike traditional single strategies such as polling or least connections, this solution comprehensively considers four key indicators: network bandwidth, CPU, memory, and concurrent connections. It also sets differentiated weight coefficients to reflect the impact of different resources on the business, thereby accurately depicting the true load status of nodes. 2. This invention dynamically maps the comprehensive load value to the scheduling weight through a formula, so that nodes with lower loads have a higher probability of being scheduled, realizing automated scheduling on demand, effectively avoiding node overload or resource idleness caused by a single strategy, and solving the problem of resource waste. 3. This invention significantly enhances the stability and operational efficiency of relay server clusters by constructing a closed-loop management system encompassing monitoring, calculation, scheduling, and feedback. It not only supports dynamic node registration, health checks, and anomaly removal, ensuring the real-time validity of the service list, but also provides data support for algorithm optimization through statistical analysis units, forming a positive cycle of continuous improvement. This dynamic, full lifecycle management mechanism can automatically adapt to real-time fluctuations in business load without frequent manual intervention in static configuration. Even in scenarios with massive concurrent device access, it maintains high scheduling efficiency and low response latency, ensuring the service quality of P2P communication and providing a solid foundation for the stable operation of large-scale IoT devices and real-time audio / video systems. Attached Figure Description
[0004] Figure 1 This is a flowchart of the method of the present invention. Detailed Implementation
[0005] Example 1 Please see Figure 1 A load balancing method for server relay nodes in a P2P system includes the following steps: S1. Real-time multi-dimensional load monitoring: Through the load monitoring module, the operation data of the relay node of each relay server is continuously collected. S2. Dynamic weight calculation: The data collected by the load monitoring module is substituted into the algorithm to calculate the load of each node, and the scheduling weight of each node is calculated based on the load. S3, weighted probability scheduling, arranges the scheduling weights of each node from smallest to largest and calculates the sum, generates a random number R within the sum interval, constructs different ranges of cumulative weight intervals based on the size of the scheduling weights, determines which cumulative weight interval the random number R falls into, and then assigns the node to the requester. S4 provides full lifecycle management of relay server nodes, manages and handles anomalies, and dynamically adjusts the weight of each node in real time based on updated load data, so that subsequent requests are distributed according to the latest weight, achieving dynamic load balancing. Furthermore, the relay node operation data in S1 includes network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data. Furthermore, network bandwidth load data represents the real-time utilization rate of node uplink and downlink bandwidth, CPU load data represents the percentage of CPU usage, memory usage load data represents the percentage of memory used relative to total memory, and concurrent connection load data represents the number of currently active node connections. Furthermore, when performing load calculations in S2, the network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data are first converted to the same unit of measurement before a comprehensive load calculation is performed. Furthermore, the load calculation formula is as follows: Where L is the overall load value; ; ; . Furthermore, when calculating the scheduling weight based on the load, the comprehensive load value is converted into a scheduling weight. The formula for calculating the scheduling weight is as follows: in For scheduling weights; The normalization coefficient; This is the overall load value. Furthermore, the random number R in S3 uses a uniformly distributed random number generator, which employs a random algorithm to ensure sampling uniformity. Furthermore, in S3, when constructing cumulative weight intervals of different ranges based on the size of the scheduling weights, a continuous numerical interval from 0 to the sum of the scheduling weights is first determined. Then, according to the order of the node scheduling weights, this total interval is sequentially divided among the nodes. The first node occupies the interval starting from 0 with a length equal to its weight value. The second node follows the first node and occupies the interval with the same length equal to its weight. This process continues until all nodes are assigned, thus forming a sequence of cumulative weight intervals that are connected end to end. Furthermore, in S4, when managing and handling anomalies of relay server nodes, the node registration and discovery unit first enables dynamic access and exit of nodes, maintains a real-time list of available nodes, and performs periodic health checks to confirm online status. Once a node response timeout or service anomaly is detected, the anomaly handling unit intervenes, removing the faulty node from the scheduling list or reducing its weight, while recording detailed anomaly information and triggering alarms. At the same time, the capacity management unit continuously monitors the load of each node. When the number of concurrent connections of a node reaches a preset threshold, its weight is automatically downgraded to prevent overload. The statistical analysis unit aggregates and analyzes the request allocation frequency, success rate, and average load indicators of each node, generating a load balancing effect report, thereby providing data support for the continuous optimization of the weighting algorithm and ensuring the high availability and stability of the entire relay service cluster. Furthermore, when dynamically adjusting the weights of each node in S4, the monitoring module continuously collects and reports the network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data of each node in real time. Then, the weight calculation module dynamically calculates the comprehensive load value of each node based on these real-time data and the preset weight coefficients, and maps it to the scheduling weight. The scheduling decision module constructs a cumulative weight range based on the updated weight list. Using a weighted probability sampling algorithm, when subsequent requests arrive, it automatically allocates requests by generating random numbers and matching nodes that fall into the range. Finally, the statistical analysis unit summarizes the number of request allocations, success rate, and average load of each node, and generates an effect report to assist in optimizing the weight parameters, thereby forming dynamic load balancing. This embodiment significantly improves the accuracy of load allocation and the system's adaptability by introducing a multi-dimensional load monitoring and dynamic weight calculation mechanism. Unlike traditional single strategies such as polling or least connections, this solution comprehensively considers four key indicators: network bandwidth, CPU, memory, and concurrent connections. It also sets differentiated weight coefficients to reflect the impact of different resources on services, thereby accurately depicting the true load status of nodes. By dynamically mapping the overall load value to the scheduling weight using a formula, nodes with lower loads have a higher probability of being scheduled, thus achieving automated scheduling with on-demand allocation. This effectively avoids node overload or resource idleness caused by a single strategy and solves the problem of resource waste. Furthermore, this solution significantly enhances the stability and operational efficiency of the relay server cluster by constructing a closed-loop management system encompassing monitoring, computation, scheduling, and feedback. It not only supports dynamic node registration, health checks, and anomaly removal, ensuring the real-time validity of the service list, but also provides data support for algorithm optimization through statistical analysis units, forming a positive cycle of continuous improvement. This dynamic, full lifecycle management mechanism can automatically adapt to real-time fluctuations in business load without frequent manual intervention in static configuration. Even in scenarios with massive concurrent device access, it maintains high scheduling efficiency and low response latency, ensuring not only the quality of service for P2P communication but also providing a solid foundation for the stable operation of large-scale IoT devices and real-time audio / video systems. The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A load balancing method for server relay nodes in a P2P system, characterized in that, Includes the following steps: S1. Real-time multi-dimensional load monitoring: Through the load monitoring module, the operation data of the relay node of each relay server is continuously collected. S2. Dynamic weight calculation: The data collected by the load monitoring module is substituted into the algorithm to calculate the load of each node, and the scheduling weight of each node is calculated based on the load. S3, weighted probability scheduling, arranges the scheduling weights of each node from smallest to largest and calculates the sum, generates a random number R within the sum interval, constructs different ranges of cumulative weight intervals based on the size of the scheduling weights, determines which cumulative weight interval the random number R falls into, and then assigns the node to the requester. S4 provides full lifecycle management of relay server nodes, manages and handles anomalies, and dynamically adjusts the weight of each node in real time based on updated load data, so that subsequent requests are distributed according to the latest weight, achieving dynamic load balancing.
2. The load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: The relay node operation data in S1 includes network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data.
3. The load balancing method for server relay nodes in a P2P system according to claim 2, characterized in that: Network bandwidth load data represents the real-time utilization rate of node uplink and downlink bandwidth; CPU load data represents the percentage of CPU usage; memory usage load data represents the percentage of memory used relative to total memory; and concurrent connection load data represents the number of currently active node connections.
4. The load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: In S2, when performing load calculation, the network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data are first converted to the same unit of measurement before a comprehensive load calculation is performed.
5. A load balancing method for server relay nodes in a P2P system according to claim 4, characterized in that: The load calculation formula is as follows: Where L is the overall load value; ; ; .
6. A load balancing method for server relay nodes in a P2P system according to claim 5, characterized in that: When calculating scheduling weights based on load, the overall load value is converted into a scheduling weight. The formula for calculating scheduling weights is as follows: in For scheduling weights; The normalization coefficient; This is the overall load value.
7. A load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: The random number R in S3 is generated using a uniformly distributed random number generator, which employs a random algorithm to ensure sampling uniformity.
8. A load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: In step S3, when constructing cumulative weight intervals of different ranges based on the size of the scheduling weights, a continuous numerical interval from 0 to the sum of the scheduling weights is first determined. Then, according to the order of the node scheduling weights, this total interval is sequentially divided among the nodes. The first node occupies an interval starting from 0 with a length equal to its weight value. The second node follows the first node and occupies an interval with the same length equal to its weight. This process continues until all nodes are allocated, thus forming a sequence of cumulative weight intervals that are connected end to end.
9. A load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: In S4, when managing and handling anomalies of relay server nodes, the node registration and discovery unit first enables dynamic access and exit of nodes, maintains a real-time available node list, and performs periodic health checks to confirm online status. Once a node response timeout or service anomaly is detected, the anomaly handling unit intervenes, removes the faulty node from the scheduling list or reduces its weight, records detailed anomaly information, and triggers alarms. Meanwhile, the capacity management unit continuously monitors the load of each node. When the number of concurrent connections of a node reaches a preset threshold, its weight is automatically downgraded to prevent overload. The statistical analysis unit aggregates and analyzes the request allocation frequency, success rate, and average load indicators of each node to generate a load balancing effect report, thereby providing data support for the continuous optimization of the weighting algorithm and ensuring the high availability and stability of the entire relay service cluster.
10. A load balancing method for server relay nodes in a P2P system according to claim 1, characterized in that: In step S4, when dynamically adjusting the weights of each node, the monitoring module continuously collects and reports the network bandwidth load data, CPU load data, memory usage load data, and concurrent connection load data of each node in real time. Then, the weight calculation module dynamically calculates the comprehensive load value of each node based on these real-time data and the preset weight coefficients, and maps it to the scheduling weight. The scheduling decision module constructs a cumulative weight range based on the updated weight list. Using a weighted probability sampling algorithm, when subsequent requests arrive, it automatically allocates requests by generating random numbers and matching nodes that fall into the range. Finally, the statistical analysis unit summarizes the number of request allocations, success rate, and average load of each node, and generates an effect report to assist in optimizing the weight parameters, thereby forming dynamic load balancing.
