Method for managing multi-node garbage collection, computing device, and storage medium
By predicting and scheduling garbage collection event time windows of virtual machine nodes in the JVM cluster, the problem of load balancers being unable to perceive the GC status of nodes is solved, realizing real-time perception and reasonable scheduling of garbage collection events, and improving the stability and service performance of the virtual machine cluster.
Patent Information
- Application Number
- CN202511392779.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-26
- Publication Date
- 2026-08-25
- Estimated Expiration
- 2045-09-26
AI Technical Summary
In a microservice architecture, the load balancer of a JVM cluster cannot effectively detect the garbage collection status of nodes, causing traffic to be routed to nodes in the STW state, resulting in service latency fluctuations and wasted computing resources.
By acquiring the garbage collection event status information of virtual machine nodes, using a predictive model to predict the time window of future garbage collection events, and scheduling the request traffic of nodes through a distributed coordination service to avoid the overlap of garbage collection time windows of multiple nodes, combined with a traffic adjustment mechanism, real-time perception and reasonable scheduling of garbage collection events can be achieved.
It improves the stability of the virtual machine cluster, avoids the problem of sudden increase in global latency caused by global garbage collection on multiple nodes, and ensures high availability and resource utilization of services.
Smart Images

Figure CN121187969B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a management method, computing device, and storage medium for multi-node waste recycling. Background Technology
[0002] In a microservice architecture, JVM (Java Virtual Machine) clusters are typically horizontally scaled across multiple nodes to improve concurrent processing capabilities. The stability of a JVM cluster depends on the effectiveness of Garbage Collection (GC), a mechanism that automatically reclaims unused objects from the heap memory. When some nodes trigger a Full GC (global garbage collection event) due to heap memory pressure, all threads enter a Stop-The-World (STW) state, during which nodes cannot respond to external requests, causing fluctuations in service latency. At this time, the load balancer transfers new requests to other nodes, causing a surge in load and a rapid increase in memory usage on those nodes, significantly increasing the probability of other nodes triggering a Full GC.
[0003] In existing technologies, load balancers typically distribute traffic to nodes based on response time or round-robin algorithms, failing to detect the GC status of nodes. This can lead to traffic being routed to nodes in a Stop-The-World (STW) state, exacerbating latency jitter and wasting computing resources. Therefore, how to detect and coordinate the GC status of multiple nodes and rationally schedule the processing tasks of each node has become an urgent technical problem to be solved. Summary of the Invention
[0004] The purpose of this application is to provide a multi-node garbage collection management method, computing device and storage medium, which realizes real-time perception and reasonable scheduling of garbage collection events in virtual machine nodes, thereby improving the stability of virtual machine clusters.
[0005] To achieve the above objectives: In a first aspect, embodiments of this application provide a multi-node garbage collection management method, comprising: acquiring state information of garbage collection events executed in multiple virtual machine nodes, wherein the garbage collection events include at least global garbage collection events; inputting the state information into a prediction model, and outputting a prediction time window for the multiple virtual machine nodes to trigger global garbage collection events in the future, as the prediction result of the multiple virtual machine nodes; uniformly registering and scheduling the prediction results of each virtual machine node, so that the prediction time windows for each virtual machine node to trigger global garbage collection events do not overlap; and adjusting the request traffic of the virtual machine nodes according to the progress of the virtual machine nodes executing global garbage collection events.
[0006] In one embodiment, the state information includes at least one of the following: old generation utilization, global pause duration, object promotion rate, off-heap memory, number of threads, and CPU load.
[0007] In one embodiment, before inputting the state information into the prediction model, the method includes: constructing a prediction model based on a time feature embedding layer and a long short-term memory neural network; wherein the time feature embedding layer is used to determine the time-varying characteristics of the garbage collection event, and the long short-term memory neural network is used to predict the time window when the virtual machine node triggers a global garbage collection event in the future; acquiring historical state information of garbage collection events executed in multiple virtual machine nodes; generating training samples for the long short-term memory neural network based on the historical state information; and training the prediction model based on the training samples.
[0008] In one embodiment, the unified registration and scheduling of the prediction results for each virtual machine node includes: registering the prediction time windows for triggering global garbage collection events by the multiple virtual machine nodes respectively, thus obtaining multiple time window nodes; if the prediction time windows of the multiple time window nodes overlap, adjusting the prediction time windows corresponding to the time window nodes according to the priority and / or hash value of the time window nodes, so that the prediction time windows for triggering global garbage collection events by the virtual machine nodes do not overlap.
[0009] In one embodiment, the unified registration and scheduling of prediction results for each virtual machine node further includes: if no global garbage collection event is triggered within the prediction time window corresponding to the current time window node, then the prediction time window corresponding to the next time window node is moved forward.
[0010] In one embodiment, adjusting the request traffic of the virtual machine node based on the progress of the virtual machine node executing a global garbage collection event includes: obtaining the progress of the virtual machine node executing a global garbage collection event; if the virtual machine node starts executing a global garbage collection event, then reducing the request traffic weight of the virtual machine node; if the global garbage collection event of the virtual machine node ends, then increasing the request traffic weight of the virtual machine node.
[0011] In one embodiment, reducing the request traffic weight of the virtual machine node includes: adjusting the request traffic weight of the virtual machine node through a nonlinear decay model, such that the decay of the request traffic weight is exponentially related to the remaining time of the global garbage collection event.
[0012] In one embodiment, increasing the request traffic weight of the virtual machine node includes: adjusting the increase rate of the request traffic weight of the virtual machine node using a PID algorithm.
[0013] Secondly, embodiments of this application provide a computing device, including: a processor and a memory storing a computer program, wherein when the processor runs the computer program, the above-described multi-node garbage collection management method is implemented.
[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the aforementioned multi-node garbage collection management method.
[0015] The multi-node garbage collection management method, computing device, and storage medium provided in this application embodiment obtain state information of garbage collection events executed in multiple virtual machine nodes, including at least global garbage collection events; input the state information into a prediction model, and output the predicted time window for multiple virtual machine nodes to trigger global garbage collection events in the future, as the prediction result for multiple virtual machine nodes; uniformly register and schedule the prediction results of each virtual machine node, so that the predicted time windows for triggering global garbage collection events of each virtual machine node do not overlap; adjust the request traffic of virtual machine nodes according to the progress of global garbage collection events executed by virtual machine nodes. Thus, by predicting and coordinating the garbage collection time windows of multiple nodes and staggering their execution, combined with a traffic adjustment mechanism, real-time perception and reasonable scheduling of garbage collection events in virtual machine nodes are achieved, improving the stability of the virtual machine cluster. Therefore, this application embodiment, by predicting and coordinating the garbage collection time windows of multiple nodes and staggering their execution, combined with a traffic adjustment mechanism, achieves real-time perception and reasonable scheduling of garbage collection events in virtual machine nodes, thereby avoiding the problem of sudden increases in global latency caused by multi-node global garbage collection and improving the stability of the virtual machine cluster. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the heap memory structure in a virtual machine.
[0017] Figure 2 This is a flowchart illustrating the multi-node waste recycling management method provided in an embodiment of this application.
[0018] Figure 3 This is a schematic diagram illustrating the specific process of the multi-node waste recycling management method provided in this application embodiment.
[0019] Figure 4 This is a schematic diagram of the structure of a multi-node waste recycling management device provided in an embodiment of this application.
[0020] Figure 5 This is a schematic diagram of the structure of a computing device provided in an embodiment of the present invention. Detailed Implementation
[0021] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. In the following description, when referring to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the scope of the application.
[0022] The following is an explanation of the terms that may be involved in this embodiment: Node: An independent JVM instance running on a single physical / virtual server, with its own heap memory and GC thread.
[0023] Cluster: A logical collection of multiple JVM nodes that provides unified services to the outside world through load balancing.
[0024] GC (Garbage Collection): Releases memory by reclaiming objects that are no longer used in the heap. For example... Figure 1 As shown, the JVM heap memory consists of the young generation and the old generation. The young generation stores newly created objects and can be divided into the Eden space and the Survivor space. The Survivor space is further divided into the From space and the To space. The old generation stores long-lived objects. GC is divided into Minor GC for the young generation, Major GC for the old generation, and Full GC for the entire heap memory. Full GC pauses all application threads (STW).
[0025] STW (Stop-The-World) state: refers to the state in which all application threads are paused during garbage collection.
[0026] SLA (Service-Level Agreement): A performance metric agreed upon between a service provider and a user.
[0027] eBPF (Extended Berkeley Packet Filter) is a kernel-level programming technique that allows custom programs to be securely injected into the kernel or user-space processes without modifying the kernel source code or restarting the system, enabling real-time data processing and logic execution.
[0028] Time2Vec (Time Feature Embedding Technology): is a model that transforms time series data into learnable vectors to capture time periodicity and trends.
[0029] LSTM (Long Short-Term Memory) neural network: It is a recurrent neural network that uses forget gates, input gates and output gates to transmit and express information in long-term sequences, thus avoiding the forgetting of useful information.
[0030] Seq2Seq (Sequence-to-Sequence): is a deep learning architecture that uses an encoder-decoder structure to handle the mapping task from input sequence to output sequence.
[0031] The Adam (Adaptive Moment Estimation) optimizer is an adaptive learning rate optimization algorithm proposed by Diederik P. Kingma and Jimmy Ba in 2014. It combines the advantages of momentum gradient descent and RMSProp optimization methods, designing independent adaptive learning rates for different parameters by calculating the first and second moment estimates of the gradient.
[0032] See Figure 2 This application provides a multi-node garbage collection management method, which can be implemented using software and / or hardware, such as computers or servers. In this embodiment, the execution entity of the multi-node garbage collection management method is a server (such as a cloud server). The multi-node garbage collection management method provided in this embodiment includes: Step S1: Obtain the status information of garbage collection events executed in multiple virtual machine nodes. The garbage collection events include at least the global garbage collection event.
[0033] It should be noted that the state information of garbage collection events executed in virtual machine nodes (hereinafter referred to as GC state information) refers to the metrics and data related to the garbage collection process executed by each node in the JVM. GC state information in each JVM node of a distributed cluster can be collected non-intrusively using eBPF technology. Garbage collection events include at least global garbage collection events (hereinafter referred to as Full GC), and may also include Minor GC for the young generation and Major GC for the old generation. In other words, this application can obtain one or more types of GC state information. In a specific embodiment, GC state information may be GC log information, heap memory distribution during GC, GC thread activity, etc.
[0034] In one implementation, the state information includes at least one of the following: old generation utilization, global pause duration, object promotion rate, off-heap memory, number of threads, and CPU load.
[0035] Among these, Old Generation Utilization refers to the percentage of memory used in the Old Generation heap memory area of the Java Virtual Machine, reflecting the memory pressure of long-lived objects. Object Promotion Rate refers to the number of objects or the amount of memory promoted from the Young Generation to the Old Generation per unit time, reflecting the trend of Old Generation memory growth. STW Duration refers to the duration during which all application threads are paused during global garbage collection. External Memory refers to the physical memory area outside the Java heap. Thread Count refers to the number of currently active thread instances in the JVM process. CPU Load refers to the length of the CPU core processing task queue per unit time.
[0036] Step S2: Input the state information into the prediction model and output the prediction time window for multiple virtual machine nodes to trigger global garbage collection events in the future, as the prediction result for multiple virtual machine nodes.
[0037] Here, multi-dimensional GC state information is input into a time-series analysis-based prediction model constructed using Time2Vec and LSTM. After training, the model outputs the predicted time window for each virtual machine node to trigger a Full GC event in the future, i.e., the start and end time range within which each node may enter a Full GC. The prediction results are returned in a structured form for subsequent unified registration and scheduling strategies, avoiding multiple nodes triggering Full GC simultaneously at similar times, thereby reducing the impact of node pauses on the overall availability of JVM services.
[0038] In one embodiment, before inputting the state information into the prediction model, the method includes: constructing a prediction model based on a time feature embedding layer and a long short-term memory neural network; wherein the time feature embedding layer is used to determine the time-varying characteristics of garbage collection events, and the long short-term memory neural network is used to predict the time window when future virtual machine nodes trigger global garbage collection events; obtaining historical state information of garbage collection events executed in multiple virtual machine nodes; generating training samples for the long short-term memory neural network based on the historical state information; and training the prediction model based on the training samples.
[0039] Here, before inputting real-time GC state information into the prediction model for prediction, it is necessary to complete the construction and training of the prediction model. First, a hybrid model architecture is constructed that integrates a time feature embedding layer (hereinafter referred to as Time2Vec) and a long short-term memory neural network (hereinafter referred to as LSTM). The Time2Vec layer is responsible for transforming the raw timestamps into feature vectors with periodicity and trends to capture the time-varying patterns of garbage collection events; while LSTM utilizes its gating mechanism and state memory capability to specifically learn long-term dependencies in historical state sequences, thereby predicting the specific time window when future virtual machine nodes trigger Full GC events.
[0040] When building and training the prediction model based on the Time2Vec layer and LSTM, the time-varying features of GC state information are first extracted through the Time2Vec layer. The Time2Vec layer includes at least linear and sinusoidal terms. The linear term captures the long-term growth trend of GC events, such as the increased frequency of Full GC due to memory leaks; the sinusoidal term captures the periodic patterns of GC, such as the periodic pattern of GC triggering during peak business periods. For example, the timestamps in the GC logs are encoded into periodic functions through sine / cosine transforms to capture the temporal regularity of GC events. During the initial training phase of the Time2Vec layer, the Time2Vec parameters can be frozen; in the later stages of training, the Time2Vec parameters can be unfrozen and fine-tuned to prevent overfitting.
[0041] Next, the output of the Time2Vec layer is concatenated with the GC features through a fully connected layer to form an enhanced input vector. The GC features are a subset of the GC state information and can include some or all of the information. It should be noted that the fully connected layer is used to globally combine and transform the features of the input data. Each feature dimension in the GC state information is normally normalized independently to the [0,1] interval, and the timestamp of each feature is converted into a periodic feature code (such as hour, day of the week) to avoid numerical jumps.
[0042] Then, training samples are generated using a sliding window. A sliding window can segment continuous time series or one-dimensional data into subsequences, generating overlapping or non-overlapping subsamples by setting the window size and step size. Specifically, a fixed window length slides along the data sequence, and after each specified step, the data within the current window is extracted as the input sample. Adjusting the window size can capture short-term fluctuations or long-term trends, while the step size controls sample density and redundancy. The sliding window technique transforms continuous time-series GC state information into training samples for supervised learning. A fixed window length slides along the time axis, with each slide having a fixed step size. Multidimensional indicators (such as old generation utilization, global pause duration, object promotion rate, off-heap memory, thread count, CPU load, etc.) from multiple consecutive time steps within the window are used as input samples, and the actual Full GC trigger state or key indicator value of the next consecutive time step is used as the predicted label for that sample. This generates a large number of temporally correlated input-output samples to train the prediction model built on LSTM. For example, set the window size to 60 and the step size to 10, so that each sample contains 60 time steps of input features and 1 time step of output label.
[0043] Training sample example: First sample: [t1, t2, ..., t60] → label t61 The second sample: [t11, t12, ..., t70] → label t71 The third sample: [t21, t22, ..., t80] → label t81 ... Last sample: [t41, t42, ..., t100] → Label t101 (needs prediction) The mathematical expression is as follows: Given a sequence X = {x1, x2, ..., x} of length T t}, where xᵢ∈R 5 (5-dimensional GC index): Sample Si=[xi,xi+1,...,xi+59]∈R60×5; Label Li=xi+60∈R5; where i=1,11,21,...,T-60.
[0044] For example, detailed state information data of garbage collection events performed by multiple virtual machine nodes in the production environment within a historical period (typically no less than 7 days) is obtained. Then, based on this historical state information, a sliding window method (window length 60, step size 10) is used to construct supervised learning samples, each sample containing input features for 60 consecutive time steps and output label for the next time step.
[0045] Subsequently, an LSTM network is constructed, employing forget gates, input gates, and output gates to learn the nonlinear correlation between historical state information and future GC trigger time windows. Specifically, the forget gate in the LSTM structure uses the Sigmoid activation function to control the proportion of historical information retained; the input gate introduces a nonlinear Tanh (hyperbolic tangent) activation function to enhance nonlinear expressive power. A stacked two-layer LSTM structure is used, allowing for 60-100 time steps to address the gradient vanishing problem in long sequences. An attention mechanism is used for fusion, with an attention layer added after the LSTM output to weight key time steps (such as the memory surge stage before GC triggering). Multi-head attention fusion is performed on the Time2Vec layer and business features to improve cross-dimensional correlation capture capabilities. The output layer adopts a Seq2Seq (sequence-to-sequence) structure, with both the encoder and decoder using LSTM, supporting rolling prediction of GC in the next 3-5 steps. Quantile regression (0.1 / 0.5 / 0.9 quantiles) is added to the output layer to quantify the confidence interval of the prediction results. The Adam optimizer is used with mean squared error as the loss function to reduce prediction error. Training samples are input into the LSTM to train it, enabling the prediction model to output the predicted time window for future Full GC events on each JVM node. Optionally, the prediction model can be updated periodically with the latest GC status information; for example, the model can be automatically fine-tuned with the latest data every 24 hours to adapt the predicted wear to real-time changes in business load.
[0046] Step S3: Register and schedule the prediction results of each virtual machine node in a unified manner so that the prediction time windows of each virtual machine node triggering global garbage collection events do not overlap.
[0047] Here, the predicted Full GC time windows of each virtual machine node are submitted to a distributed coordination service, such as ZooKeeper, for unified registration and centralized management. ZooKeeper constructs a set of time window nodes by maintaining a time window registry, detects time overlap conflicts between the predicted windows of different nodes in real time, and adjusts and redistributes conflict windows according to a predefined arbitration strategy. This ensures that the actual or planned time windows for triggering Full GC on all nodes are completely staggered in time sequence, avoiding cluster-level service delays or avalanche effects caused by multiple nodes simultaneously experiencing global stop-the-world (STW).
[0048] In one embodiment, the prediction results of each virtual machine node are uniformly registered and scheduled, including: registering prediction time windows for triggering global garbage collection events by multiple virtual machine nodes respectively, resulting in multiple time window nodes; if the prediction time windows of multiple time window nodes overlap, the prediction time windows corresponding to the time window nodes are adjusted according to the priority and / or hash value of the time window nodes, so that the prediction time windows for triggering global garbage collection events by each virtual machine node do not overlap.
[0049] Here, the prediction time window for each JVM node is first registered as an independent time window node. The purpose of the distributed GC coordination service is to coordinate the GC triggering time windows of each node to avoid overlapping Stop-The-World (STW) windows across multiple nodes. This includes time window registration and conflict detection and arbitration.
[0050] Each node registers its predicted GC time window (format: {start_time, duration, priority}) by reporting it through a ZooKeeper ephemeral node ( / gc_windows / nodes / {node_id}), and maintains this registration through a heartbeat mechanism (updating node status every 10 seconds). The ZooKeeper persistent node structure is as follows: / gc_windows / ├── nodes / # Predicted GC time for each node's registration └── windows / # Assigned time window (start time, duration, node) The design incorporates a conflict detection and arbitration algorithm. When a new node registers a time window or an existing node updates its time window, all persistent nodes under / gc_windows / windows are traversed to check if their time windows overlap, i.e., if the time interval of [start, start+duration] intersects with that of an existing window.
[0051] If there is overlap between time window nodes, adjustments can be made by prioritizing them: based on preset priority rules such as node load and business importance, the windows of high-priority nodes are retained, and the start and end times of the windows of low-priority nodes are adjusted. Alternatively, adjustments can be made by dynamically offsetting hash values: a hash value is generated based on the node ID or timestamp, the time offset is calculated, and the window is moved forward or backward to ensure that the time windows are mutually exclusive.
[0052] Optionally, fault tolerance mechanisms can be used to ensure the stability of GC operations in a distributed environment. Specifically, during the GC window, Cgroups are used to dynamically allocate dedicated CPU cores to JVM processes (e.g., reserving two exclusive cores per node). By limiting CPU scheduling for non-GC processes, STW (Stop-The-World) time caused by resource contention is avoided. Furthermore, the `mlock` system call can be used to forcibly lock the JVM heap memory, preventing latency jitter caused by memory pages being swapped to disk. Simultaneously, the `-XX:PretenureSizeThreshold` parameter can be used to directly allocate large objects to the old generation, reducing memory fragmentation during the young generation promotion process and lowering the frequency and duration of Full GC. Thus, through the synergy of hardware resource isolation and memory management strategies, GC events are ensured to execute efficiently within the preset window, thereby improving system throughput and guaranteeing low-latency response in critical business scenarios.
[0053] In one embodiment, the unified registration and scheduling of prediction results for each virtual machine node further includes: if no global garbage collection event is triggered within the prediction time window corresponding to the current time window node, then the prediction time window corresponding to the next time window node is moved forward.
[0054] Optionally, GC event logs can be monitored in real time to verify the actual execution status of nodes within the predicted GC time window. If a prediction deviation occurs, i.e., a node fails to trigger a Full GC within the preset time window, the coordination service will activate a backup scheduling mechanism to postpone the node's next GC time window to the nearest available conflict-free interval. This can be adjusted based on the current load and resource usage, and the scheduling failure count will be recorded.
[0055] Optionally, when the same node fails to schedule three times consecutively, the system determines that its GC behavior has an unstable risk, automatically marks the node as "GC unstable," reduces its weight in load balancing, and guides traffic to migrate to stable nodes. Furthermore, CPU / memory isolation can be implemented for the JVM process of this node to avoid secondary interference with GC performance due to resource contention.
[0056] Step S4: Adjust the request traffic of the virtual machine node according to the process of the virtual machine node executing the global garbage collection event.
[0057] Here, when a JVM node is detected to have started a Full GC event and entered the STW state, the intelligent load balancer, based on the GC time window output by the predictive model, gradually reduces the request traffic to that JVM node according to the remaining time of the Full GC event, in order to avoid the impact of the JVM node being in Full GC on the performance of the JVM cluster. Once the JVM node has completed the Full GC event, the intelligent load balancer gradually restores the request traffic to that JVM node, restoring its normal function.
[0058] In one embodiment, adjusting the request traffic of a virtual machine node based on the progress of the virtual machine node executing a global garbage collection event includes: obtaining the progress of the virtual machine node executing a global garbage collection event; if the virtual machine node starts executing a global garbage collection event, then reducing the request traffic weight of the virtual machine node; if the execution of the global garbage collection event of the virtual machine node ends, then increasing the request traffic weight of the virtual machine node.
[0059] Here, request traffic scheduling is achieved by monitoring the Full GC process status of virtual machine nodes in real time. When a node is detected to be starting a Full GC event, its request traffic weight is immediately reduced through a load balancing mechanism, such as prioritizing the allocation of new requests to other nodes to avoid delays caused by the node processing requests during a Stop-The-World (STW) period. After the node's GC event ends, its request traffic weight is gradually restored to normal levels. Specifically, the remaining STW time is obtained in real time, and the request traffic weight flowing to that node is reduced through a non-linear decay model, making its load negatively correlated with the GC execution progress. After the node completes GC and resumes service, the traffic weight is gradually increased to normal levels through a PID control algorithm. In this way, by linking GC status and traffic allocation in real time, the impact of high-overhead GC periods on service response is effectively avoided, while ensuring a balance in resource utilization, thereby improving the overall performance and stability of the distributed system.
[0060] In one embodiment, reducing the request traffic weight of a virtual machine node includes: adjusting the request traffic weight of the virtual machine node through a nonlinear decay model, such that the decay of the request traffic weight is exponentially related to the remaining time of the global garbage collection event.
[0061] Here, if it is predicted that a node is about to enter the Full GC time window, such as 30 seconds in advance, the load balancer can dynamically reduce the weight of the node and gradually guide new request traffic to other nodes with stable GC status, thus avoiding processing requests during the STW phase.
[0062] Specifically, the intelligent load balancer reads the node GC status (is_stw, remaining_time) through shared memory or local Unix domain sockets to avoid network call latency.
[0063] Sub-millisecond broadcasting of GC status is implemented via Redis Pub / Sub or Kafka. Each load balancer node subscribes to the topic `gc_status_channel` to obtain node status change events in real time. A custom HTTP header `X-GC-State: {"status":"stw", "remaining":500}` is injected into the node response for use by the client-side load balancer (such as Ribbon) in decision-making.
[0064] The dynamic calculation of weights uses a nonlinear decay model, employing the following formula:
[0065] In the formula, t is the remaining STW time, k is the decay coefficient, W0 is the initial weight, and W t To adjust the weights, the attenuation coefficient k is dynamically adjusted via SLA, with an initial value of 0.5. When the actual P99 delay exceeds the target value, the value of k is automatically increased.
[0066] The attenuation coefficient k is dynamically adjusted using an adaptive adjustment algorithm based on real-time monitoring of request latency and error rate feedback. The adjustment formula is as follows:
[0067] In the formula, k old k is the attenuation coefficient before adjustment. new is the adjusted attenuation coefficient, 'a' is the adjustment factor (0.1-0.3, configured according to business sensitivity), and 'D' is the value of D. actual For the actual P99 delay, D target Set the SLA target delay (e.g., 200ms).
[0068] In one embodiment, increasing the request traffic weight of a virtual machine node includes adjusting the rate at which the request traffic weight of the virtual machine node is increased using a PID algorithm.
[0069] The traffic scheduling strategy incorporates a PID algorithm to control the rate of weight change, thus preventing drastic traffic fluctuations. The PID control formula is as follows:
[0070] In the formula, To control the response strength of the current error, For target weight With actual weight The difference; This is the proportionality coefficient; The integral coefficient is used to eliminate historical accumulated errors; These are the differential coefficients used to predict future error trends. A minimum weight threshold (e.g., 10%) is set to prevent nodes from being completely removed. After GC, the weights are gradually restored to the baseline value at a rate of 20% per second. If a node fails to complete GC on time for three consecutive times, it is marked as a faulty node, and a service circuit breaker is triggered.
[0071] In summary, the multi-node garbage collection management method provided in the above embodiments obtains the status information of garbage collection events executed in multiple virtual machine nodes, including at least global garbage collection events; inputs the status information into a prediction model, outputs the predicted time windows for multiple virtual machine nodes to trigger global garbage collection events in the future, and uses these as the prediction results for multiple virtual machine nodes; uniformly registers and schedules the prediction results for each virtual machine node, ensuring that the predicted time windows for each virtual machine node to trigger global garbage collection events do not overlap; and adjusts the request traffic of virtual machine nodes according to the progress of global garbage collection events executed by the virtual machine nodes. Thus, by predicting and coordinating the garbage collection time windows of multiple nodes and staggering their execution, combined with a traffic adjustment mechanism, real-time perception and reasonable scheduling of garbage collection events in virtual machine nodes are achieved, improving the stability of the virtual machine cluster. Therefore, this embodiment of the application, by predicting and coordinating the garbage collection time windows of multiple nodes and staggering their execution, combined with a traffic adjustment mechanism, achieves real-time perception and reasonable scheduling of garbage collection events in virtual machine nodes, thereby avoiding the problem of sudden increases in global latency caused by multi-node global garbage collection and improving the stability of the virtual machine cluster.
[0072] Based on the same inventive concept as the foregoing embodiments, the method provided by the foregoing embodiments will be illustrated below by a specific example.
[0073] In a microservice architecture, Java Virtual Machine (JVM) clusters achieve horizontal scaling by processing requests in parallel across multiple nodes. Their operational status is heavily influenced by the garbage collection mechanism. When some nodes trigger GC due to memory pressure, the load balancer will transfer requests to other nodes, causing a surge in load and a rapid increase in memory usage on the remaining nodes. This snowball effect significantly increases the probability of multiple nodes simultaneously reaching the Full GC threshold. Full GC triggers all threads into a global pause (STW, Stop-The-World) state, during which nodes cannot respond to external requests, leading to fluctuating service latency. Because the timing of GC triggering on each node is independently determined by its local heap memory usage, and there is a lack of cross-node coordination mechanisms, overlapping Full GC time windows across multiple nodes are prone to occur, triggering cascading service degradation.
[0074] Traditional load balancing strategies allocate traffic based on response time or round-robin algorithms, failing to detect node GC status. This leads to traffic still being routed to nodes performing GC during Stop-The-World (STW) periods, exacerbating latency; it also causes sudden increases in global request latency, violating SLAs (e.g., P99 latency exceeding 200ms). Existing solutions include global clock-synchronized GC, triggering GC within a fixed time window after synchronizing all node clocks via NTP. However, each node independently monitors its heap memory for GC, failing to perceive the overall cluster load status, resulting in localized optimization leading to global degradation.
[0075] Existing solutions rely on single-node GC optimization (such as low-latency garbage collection algorithms), but fail to address the issue of GC cycle synchronization across multiple nodes in a distributed environment. When node load balancing or memory allocation rates converge, multi-node Stop-The-World (STW) events can resonate, leading to a sharp drop in cluster-level processing capacity. Furthermore, the disconnect between load balancing and GC status is significant. Traditional load balancers employ stateless strategies such as round-robin and hashing. In microservice architectures, request backlogs on STW nodes can trigger downstream dependency timeouts, creating cascading failures and posing a cluster-level avalanche risk.
[0076] This solution provides a GC intelligent scheduling method for distributed JVM clusters. Through a three-level linkage technical architecture of prediction, coordination, and control, it solves the problem of sudden increase in global latency caused by multi-node Full GC (STW) in microservice clusters.
[0077] This solution uses GC status (such as STW prediction and memory level) as the core factor for load balancing decisions, replacing the traditional stateless strategy; it uses distributed locks or time wheel algorithms to stagger the GC triggering timing of each node, eliminating the resonance effect; and it builds a low-latency GC status collection and distribution link based on shared memory proxy, enabling the load balancer to perceive STW events in real time and achieve global orderly management of GC events.
[0078] Specifically, please refer to Figure 3 ,like Figure 3 As shown, firstly, multi-dimensional metrics of microservice nodes are input into a prediction model built based on the Time2Vec layer and LSTM to predict the time window for triggering Full GC on microservice nodes. Next, the predicted GC time window is reported to the GC coordinator. The GC coordinator, through interaction with ZooKeeper, completes the registration and non-overlapping allocation of global GC time windows, avoiding system performance fluctuations caused by multiple nodes triggering GC simultaneously. Simultaneously, the GC coordinator issues dynamic weight adjustment commands through the Envoy load balancer to optimize traffic distribution between services. Furthermore, microservice nodes pass GC status through shared memory, achieving more granular GC management, ultimately reducing system jitter and improving stability.
[0079] For example, when the time windows of each node do not overlap, the coordination service marks the time window as allocated, and the node does not need to adjust the window and can directly perform GC as originally planned. When overlapping time windows are detected, priority is assigned according to the SLA level of the microservice, which can be set from 1 to 5, with level 1 being the highest priority. If the priorities of each node are different, the higher priority node retains its time window, while the lower priority node is forced to reallocate its time window, with a minimum interval of ≥300 seconds between the new window and the existing window; if all nodes have the same priority, they are sorted according to the node ID hash value, and the node with the smaller hash value is given priority in retaining its time window. The node with the larger hash value is reallocated its time window. The GC coordination controller issues instructions according to the above scenario, allowing conflicting nodes to reallocate their time windows in the most recent available time period. If multiple conflicts cause a node to be unable to obtain a window for a long time, the coordination service dynamically increases the interval threshold.
[0080] Optionally, by monitoring GC event logs, it can be determined whether a node has not triggered a Full GC within the predicted GC time window. If it has not triggered the coordination service to start backup scheduling, the next GC time window for that node is moved to the nearest available interval, and the number of scheduling failures is recorded. When scheduling fails three times consecutively, the node is marked as "GC unstable" and intelligent load balancing weight calculation is triggered to implement a node degradation strategy.
[0081] Optionally, the distributed GC coordination service has a fault-tolerance mechanism. During the GC window, it reserves exclusive CPU cores for JVM processes through Cgroups (e.g., allocating 2 dedicated CPU cores to each node) to avoid prolonged STW time due to CPU resource contention during GC. It uses the mlock system call to lock the JVM heap memory (configured via -XX:PretenureSizeThreshold to allow large objects to directly enter the old generation, reducing memory fragmentation) to prevent latency jitter caused by page swapping.
[0082] Thus, this application's embodiments introduce a deep learning model (LSTM) into the prediction of global garbage collection (GC) trigger time in a distributed JVM cluster. High-precision prediction is achieved through multi-dimensional feature input, providing a data foundation for cluster-level GC coordination. Based on this, a distributed time window conflict arbitration mechanism is constructed using ZooKeeper, dynamically registering GC time windows and prioritizing arbitration to avoid STW resonance across multiple nodes and minimize cluster latency aggregation. Furthermore, this application's embodiments innovatively propose a dynamic load balancing algorithm based on a nonlinear decay model and PID control. This algorithm uses GC status (such as remaining STW time) as a core decision factor to achieve coordination between traffic distribution and GC cycles, improving SLA assurance capabilities. It is applicable to latency-sensitive scenarios such as financial transactions (e.g., payment systems), e-commerce flash sales, and real-time communication, reducing the risk of order loss and user experience degradation due to GC latency. Simultaneously, precise GC coordinated scheduling reduces excessive expansion demands caused by GC avalanches, lowering infrastructure costs. By eliminating system impacts triggered by concentrated GC, troubleshooting time is shortened, operational efficiency is improved, and the stringent high availability requirements of cloud computing platforms and large-scale microservice architectures are met.
[0083] Please see Figure 4 To achieve the above objectives, embodiments of the present invention also provide a multi-node waste recycling management device 40, which is applied to a computing device and includes: Module 41 is used to obtain the status information of garbage collection events executed in multiple virtual machine nodes, including at least the global garbage collection event; The prediction module 42 is used to input state information into the prediction model and output the prediction time window for multiple virtual machine nodes to trigger global garbage collection events in the future, as the prediction result for multiple virtual machine nodes. The scheduling module 43 is used to determine the final prediction result of the second purchase order data for a future preset period based on the current purchase order data and the preliminary prediction results. Adjustment module 44 is used to adjust the request traffic of virtual machine nodes based on the process of executing global garbage collection events on virtual machine nodes.
[0084] In one implementation, the state information includes at least one of the following: old generation utilization, global pause duration, object promotion rate, off-heap memory, number of threads, and CPU load.
[0085] In one embodiment, before inputting the state information into the prediction model, the method includes: constructing a prediction model based on a time feature embedding layer and a long short-term memory neural network; wherein the time feature embedding layer is used to determine the time-varying characteristics of garbage collection events, and the long short-term memory neural network is used to predict the time window when future virtual machine nodes trigger global garbage collection events; obtaining historical state information of garbage collection events executed in multiple virtual machine nodes; generating training samples for the long short-term memory neural network based on the historical state information; and training the prediction model based on the training samples.
[0086] In one embodiment, the prediction results of each virtual machine node are uniformly registered and scheduled, including: registering prediction time windows for triggering global garbage collection events by multiple virtual machine nodes respectively, resulting in multiple time window nodes; if the prediction time windows of multiple time window nodes overlap, the prediction time windows corresponding to the time window nodes are adjusted according to the priority and / or hash value of the time window nodes, so that the prediction time windows for triggering global garbage collection events by each virtual machine node do not overlap.
[0087] In one embodiment, the unified registration and scheduling of prediction results for each virtual machine node further includes: if no global garbage collection event is triggered within the prediction time window corresponding to the current time window node, then the prediction time window corresponding to the next time window node is moved forward.
[0088] In one embodiment, adjusting the request traffic of a virtual machine node based on the progress of the virtual machine node executing a global garbage collection event includes: obtaining the progress of the virtual machine node executing a global garbage collection event; if the virtual machine node starts executing a global garbage collection event, then reducing the request traffic weight of the virtual machine node; if the execution of the global garbage collection event of the virtual machine node ends, then increasing the request traffic weight of the virtual machine node.
[0089] In one embodiment, reducing the request traffic weight of a virtual machine node includes: adjusting the request traffic weight of the virtual machine node through a nonlinear decay model, such that the decay of the request traffic weight is exponentially related to the remaining time of the global garbage collection event.
[0090] In one implementation, increasing the request traffic weight of a virtual machine node includes adjusting the rate of increase of the request traffic weight of the virtual machine node using a PID algorithm.
[0091] For the specific implementation of the multi-node waste recycling management device in this application embodiment, please refer to the relevant description of the multi-node waste recycling management method, which will not be repeated here.
[0092] Based on the same inventive concept as the foregoing embodiments, this embodiment of the invention provides a computing device, such as... Figure 5As shown, the computing device includes: a processor 610 and a memory 611 storing computer programs; wherein, Figure 5 The processor 610 shown in the diagram does not indicate that there is only one processor 610, but only indicates the positional relationship of the processor 610 relative to other devices. In practical applications, there can be one or more processors 610; similarly, Figure 5 The memory 611 shown in the diagram has the same meaning, that is, it is only used to indicate the positional relationship of memory 611 relative to other devices. In practical applications, there can be one or more memories 611. When the processor 610 runs the computer program, the multi-node garbage collection management method described above is implemented.
[0093] The computing device may also include at least one network interface 612. The various components of the computing device are coupled together via a bus system 613. It is understood that the bus system 613 is used to implement communication between these components. In addition to a data bus, the bus system 613 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 5 The general designated all buses as Bus System 613.
[0094] Based on the same inventive concept as the foregoing embodiments, this embodiment also provides a computer-readable storage medium storing a computer program. The computer-readable storage medium can be a magnetic random access memory (FRAM), a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), a flash memory, a magnetic surface memory, an optical disc, or a compact disc read-only memory (CD-ROM), etc.; it can also be various devices including one or any combination of the above-mentioned memories, such as mobile phones, computers, tablet devices, personal digital assistants, etc. When the computer program stored in the computer-readable storage medium is executed by a processor, it implements the multi-node garbage collection management method described above. For the specific steps implemented when the computer program is executed by the processor, please refer to [link to relevant documentation]. Figures 1-5The description of the illustrated embodiments will not be repeated here.
[0095] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A management method for multi-node waste recycling, characterized in that, include: Obtain status information of garbage collection events executed in multiple virtual machine nodes, wherein the garbage collection events include at least global garbage collection events; The state information is input into the prediction model, and the predicted time window for the multiple virtual machine nodes to trigger global garbage collection events in the future is output as the prediction result for the multiple virtual machine nodes. The prediction results of each virtual machine node are uniformly registered and scheduled so that the prediction time windows of the global garbage collection events triggered by each virtual machine node do not overlap. Adjust the request traffic of the virtual machine node according to the progress of the global garbage collection event executed by the virtual machine node; The state information includes at least one of the following: old generation utilization, global pause duration, object promotion rate, off-heap memory, number of threads, and CPU load. Before inputting the state information into the prediction model, the following steps are included: A prediction model is constructed based on a time feature embedding layer and a long short-term memory neural network; wherein, the time feature embedding layer is used to determine the time-varying characteristics of the garbage collection event, and the long short-term memory neural network is used to predict the time window when the virtual machine node will trigger a global garbage collection event in the future; Obtain historical status information of garbage collection events executed in multiple virtual machine nodes; Training samples for the long short-term memory neural network are generated based on the historical state information; The prediction model is trained based on the training samples; The unified registration and scheduling of prediction results for each virtual machine node includes: Register the predicted time windows for triggering global garbage collection events on the multiple virtual machine nodes respectively to obtain multiple time window nodes; If the predicted time windows of the multiple time window nodes overlap, the predicted time window corresponding to the time window node is adjusted according to the priority and / or hash value of the time window node, so that the predicted time windows of the virtual machine nodes triggering global garbage collection events do not overlap.
2. The method according to claim 1, characterized in that, The unified registration and scheduling of prediction results for each virtual machine node also includes: If no global garbage collection event is triggered within the prediction time window corresponding to the current time window node, the prediction time window corresponding to the next time window node will be moved forward.
3. The method according to claim 1, characterized in that, The step of adjusting the request traffic of the virtual machine node based on the process of executing global garbage collection events on the virtual machine node includes: Obtain the process of the virtual machine node executing the global garbage collection event; If the virtual machine node starts executing a global garbage collection event, then the request traffic weight of the virtual machine node is reduced; If the global garbage collection event of the virtual machine node is completed, the request traffic weight of the virtual machine node is increased.
4. The method according to claim 3, characterized in that, The reduction of the request traffic weight of the virtual machine node includes: The request traffic weight of the virtual machine node is adjusted by a nonlinear decay model, so that the decay of the request traffic weight is exponentially related to the remaining time of the global garbage collection event.
5. The method according to claim 3, characterized in that, The method of increasing the request traffic weight of the virtual machine node includes: The PID algorithm is used to adjust the rate at which the request traffic weight of the virtual machine node increases.
6. A computing device, characterized in that, include: The processor and the memory storing a computer program implement the multi-node garbage collection management method according to any one of claims 1 to 5 when the processor runs the computer program.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the multi-node garbage collection management method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Resource garbage recycling method and device
CN115617704A
Trigger information generation method and device, time sequence model generation method and device and electronic equipment
CN116991752A