Java instance pool optimization method and device and medium

By dividing the Java instance pool into blocks and managing instances according to the usage frequency and life cycle, the recycling time is dynamically adjusted, which solves the problem of large garbage collection burden under high concurrency, and improves system performance and resource utilization.

CN119149169APending Publication Date: 2024-12-17SHANDONG INSPUR AIGOU CLOUD CHAIN INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411168802.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2024-12-17

AI Technical Summary

Technical Problem

In a high concurrency environment, the rapid creation and destruction of Java instances exacerbates the burden of garbage collection, causing system pauses, affecting application performance with high real-time requirements.

Method used

By dividing the Java instance pool into multiple blocks, dividing it into long-term and short-term instance sets based on instance type, usage frequency, and life cycle, and dynamically adjusting the recycling time according to resource usage to reduce lock competition and garbage collection frequency .

Benefits of technology

It improves the efficiency of multi-threaded concurrent access, reduces the frequency and pause time of garbage collection, maximizes resource utilization, and ensures application performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119149169A_ABST
    Figure CN119149169A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a Java instance pool optimization method, Java instance pool optimization equipment and a medium, belongs to the technical field of Java, and solves the problem that under high concurrency, frequent GC of a Java instance pool easily causes system pause and causes serious influence on applications. Comprising the following steps: dividing a Java instance pool into a plurality of blocks according to a Java instance type; determining use frequencies and life cycles corresponding to the Java instances in the plurality of blocks, and dividing the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the use frequencies and the life cycles. And obtaining resource utilization rates corresponding to the plurality of blocks, and determining a recovery duration based on the resource utilization rates. And based on the recovery duration, recovering the Java instances to be recovered in the long-term Java instance set and the short-term Java instance set corresponding to the long-term Java instance set and the short-term Java instance set in the plurality of blocks so as to complete Java instance pool optimization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of Java technology, and in particular to a Java instance pool optimization method, device and medium. Background Art

[0002] In today's complex and ever-changing software development environment, high-concurrency systems have become an indispensable infrastructure to support core applications such as Internet services, big data processing, and cloud computing platforms. Such systems often need to handle millions or even higher levels of concurrent requests, which places extremely high demands on resource management and utilization efficiency. In Java, a widely used server-side programming language, instance pooling is a resource reuse technology that aims to reduce the overhead of object creation and destruction and improve system performance. However, with the expansion of system scale and the surge in concurrency, the operation mechanism of traditional Java instance pools has gradually exposed its limitations in high-concurrency environments, becoming one of the key factors affecting the overall performance of the system.

[0003] As instances are constantly created and destroyed, especially when small objects are frequently used, Java heap memory gradually becomes fragmented, which not only reduces memory utilization, but may also force the JVM (Java Virtual Machine) to trigger GC (Garbage Collection) earlier. Under high concurrency, the rapid creation and destruction of a large number of objects directly increases the burden of garbage collection. In extreme cases, frequent GC can easily cause system pauses, which has a serious impact on applications with high real-time requirements. Summary of the invention

[0004] The embodiments of the present application provide a Java instance pool optimization method, device and medium for solving the following technical problems: Under high concurrency, the rapid creation and destruction of a large number of objects directly increases the burden of garbage collection. In extreme cases, frequent GC can easily cause system pauses, causing serious impact on applications with high real-time requirements.

[0005] The present application embodiment adopts the following technical solutions:

[0006] The embodiment of the present application provides a Java instance pool optimization method, including: dividing the Java instance pool into multiple blocks according to the Java instance type; wherein each of the multiple blocks is provided with a unique identifier, and the unique identifier is used for multi-threaded access to the multiple blocks; determining the usage frequency and life cycle corresponding to the Java instances in the multiple blocks, and based on the usage frequency and life cycle, dividing the Java instances in each block into a long-term Java instance set and a short-term Java instance set. Obtaining the resource utilization rates corresponding to the multiple blocks, and determining the recycling time based on the resource utilization rates. Based on the recycling time, the Java instances to be recycled in the long-term Java instance set and the short-term Java instance set corresponding to the multiple blocks are recycled to complete the Java instance pool optimization.

[0007] The embodiment of the present application limits the number of instances in each block through block division, reduces lock competition, improves the efficiency of multi-threaded concurrent access, and determines which instances are frequently created and destroyed and which instances can reside for a long time through usage frequency and life cycle, thereby optimizing the memory allocation strategy. Secondly, the embodiment of the present application reduces the scanning range of the garbage collector and reduces the frequency and pause time of garbage collection by managing long-term and short-term instances separately. The recycling time is dynamically adjusted according to the resource utilization rate to maximize resource utilization while ensuring application performance.

[0008] In one implementation of the present application, a Java instance pool is divided into multiple blocks according to the Java instance type, specifically including: building a partition queue based on multiple Java instances in the Java instance pool; obtaining metadata fields corresponding to the Java instances to be divided, and determining the types corresponding to the Java instances to be divided based on the metadata fields; based on the partition queue order, dividing the Java instances to be divided of the same type into the same block; obtaining the Java instance activity corresponding to multiple blocks, respectively, and dynamically adjusting the multiple blocks based on the Java instance activity; wherein the Java instance activity includes at least one of the memory occupancy rate, the Java instance creation rate, and the Java instance destruction rate.

[0009] In one implementation of the present application, the Java instance activity corresponding to multiple blocks is obtained, and the multiple blocks are dynamically adjusted based on the Java instance activity, specifically including: within a preset time period, obtaining the Java instance creation rate and the Java instance destruction rate corresponding to the multiple blocks; comparing the Java instance creation rate with the Java instance destruction rate to determine the Java instance activity rate corresponding to the multiple blocks; based on the Java instance activity rate corresponding to the multiple blocks and the memory occupancy rate corresponding to the multiple blocks, obtaining the block adjustment dynamic values ​​corresponding to the multiple blocks, so as to dynamically adjust the multiple blocks.

[0010] In one implementation of the present application, based on the usage frequency and the life cycle, the Java instances in each block are divided into a long-term Java instance set and a short-term Java instance set, specifically including: obtaining the usage frequency corresponding to the Java instances in each block, comparing the usage frequency with a preset frequency threshold, and dividing the Java instances in each block into a first instance set and a second instance set based on the comparison result; obtaining the life cycle corresponding to the Java instances in each block, comparing the life cycle with a preset period threshold, and dividing the Java instances in each block into a third instance set and a fourth instance set based on the comparison result; based on the intersection of the first instance set, the second instance set, the third instance set and the fourth instance set, dividing the Java instances in each block into a long-term Java instance set and a short-term Java instance set.

[0011] In one implementation of the present application, based on the intersection of the first instance set, the second instance set, the third instance set and the fourth instance set, the Java instances in each block are divided into a long-term Java instance set and a short-term Java instance set, specifically including: performing intersection processing on the first instance set and the third instance set, and using the intersection processing result as the long-term Java instance set; and performing intersection processing on the first instance set and the fourth instance set, and using the intersection processing result as the short-term Java instance set; and performing intersection processing on the second instance set and the third instance set, and using the intersection processing result as the long-term Java instance set; and performing intersection processing on the second instance set and the fourth instance set, and using the intersection processing result as the short-term Java instance set.

[0012] In one implementation of the present application, resource utilization rates corresponding to multiple blocks are obtained, and a recovery period is determined based on the resource utilization rates, specifically including: based on a preset interval time period, obtaining the total block memory corresponding to the multiple blocks and the occupied memory corresponding to each block; based on the ratio between the occupied memory corresponding to each block and the total block memory, obtaining the resource utilization rate corresponding to each block; comparing the resource utilization rate with a preset resource threshold to obtain a first difference; and calculating the difference between the resource utilization rates corresponding to two adjacent interval time periods to obtain a second difference; and determining the recovery period based on the first difference and the second difference.

[0013] In one implementation of the present application, the recovery duration is determined based on the first difference and the second difference, specifically including: comparing the first difference with the first preset weight allocation table to determine the first weight value corresponding to the first difference; constructing a difference table based on the second differences corresponding to the consecutive interval time periods, so as to determine the usage change through the difference table; comparing the usage change with the second preset weight allocation table to determine the second weight corresponding to each interval time period; and determining the recovery duration corresponding to each interval time period based on the first weight and the second weight.

[0014] In one implementation of the present application, based on the recycling duration, the Java instances to be recycled in the long-term Java instance sets and the short-term Java instance sets corresponding to multiple blocks are recycled, specifically including: determining the long-term instances to be recycled in the long-term Java instance sets of multiple blocks, and determining the short-term instances to be recycled in the short-term Java instance sets of multiple blocks; after the recycling duration is reached, the long-term instances to be recycled in each block are recycled in turn; and the short-term instances to be recycled in each block are recycled in real time.

[0015] The embodiment of the present application provides a Java instance pool optimization device, comprising: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can: divide the Java instance pool into multiple blocks according to the Java instance type; wherein the multiple blocks are respectively provided with unique identifiers, and the unique identifiers are used for multi-threaded access to the multiple blocks. Determine the usage frequency and life cycle corresponding to the Java instances in the multiple blocks, and divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the usage frequency and life cycle. Obtain the resource utilization rates corresponding to the multiple blocks, and determine the recycling time based on the resource utilization rates. Based on the recycling time, the Java instances to be recycled in the long-term Java instance set and the short-term Java instance set corresponding to the multiple blocks are recycled to complete the Java instance pool optimization.

[0016] A non-volatile computer storage medium provided in an embodiment of the present application stores computer executable instructions, and the computer executable instructions are configured to: divide a Java instance pool into multiple blocks according to the Java instance type; wherein a unique identifier is set for each of the multiple blocks, and the unique identifier is used for multi-threaded access to the multiple blocks. Determine the usage frequency and life cycle corresponding to the Java instances in the multiple blocks, and based on the usage frequency and life cycle, divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set. Obtain the resource utilization rates corresponding to the multiple blocks, and determine the recycling time based on the resource utilization rates. Based on the recycling time, recycle the Java instances to be recycled in the long-term Java instance set and the short-term Java instance set corresponding to the multiple blocks, so as to complete the optimization of the Java instance pool.

[0017] At least one of the above technical solutions adopted in the embodiments of the present application can achieve the following beneficial effects: the embodiments of the present application limit the number of instances in each block through block division, reduce lock contention, improve the efficiency of multi-threaded concurrent access, and determine which instances are frequently created and destroyed and which instances can reside for a long time by using frequency and life cycle, thereby optimizing the memory allocation strategy. Secondly, the embodiments of the present application reduce the scanning range of the garbage collector and reduce the frequency and pause time of garbage collection by managing long-term and short-term instances separately. Dynamically adjust the recycling time according to resource utilization to maximize resource utilization while ensuring application performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative labor. In the drawings:

[0019] Figure 1 A flow chart of a Java instance pool optimization method provided in an embodiment of the present application;

[0020] Figure 2 A schematic diagram of the structure of a Java instance pool optimization device provided in an embodiment of the present application.

[0021] Reference numerals:

[0022] 200: Java instance pool optimization device, 201: processor, 202: memory. DETAILED DESCRIPTION

[0023] Embodiments of the present application provide a Java instance pool optimization method, device, and medium.

[0024] In order to enable those skilled in the art to better understand the technical solutions in this application, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0025] The technical solution proposed in the embodiment of the present invention is described in detail below with reference to the accompanying drawings.

[0026] Figure 1 A flow chart of a Java instance pool optimization method provided in an embodiment of the present application is as follows: Figure 1 As shown, the Java instance pool optimization method includes the following steps:

[0027] Step 101: Divide the Java instance pool into multiple blocks according to the Java instance type.

[0028] In one embodiment of the present application, a partitioning queue is constructed based on multiple Java instances in a Java instance pool. The metadata field corresponding to the Java instance to be partitioned is obtained, and the type corresponding to the Java instance to be partitioned is determined based on the metadata field. Based on the partitioning queue order, the Java instances to be partitioned of the same type are partitioned into the same block. The Java instance activity corresponding to the multiple blocks is obtained, and the multiple blocks are dynamically adjusted based on the Java instance activity; wherein the Java instance activity includes at least one of the memory occupancy rate, the Java instance creation rate, and the Java instance destruction rate.

[0029] Specifically, first, multiple Java instances in the Java instance pool are organized into one or more partition queues according to the creation time. This queue is used to determine the order in which the Java instances are processed. For example, a queue can be constructed according to the first-in-first-out principle to ensure that the earliest created instance is processed first. Secondly, each Java instance is assigned a metadata field when it is created or run, and the metadata field describes the attributes or characteristics of the instance. The type of each Java instance to be partitioned is determined by reading the metadata field. The type can be defined based on business logic, such as processing orders, user authentication, etc., or based on a technology stack or performance characteristics, such as memory usage patterns, processing speed, etc. Among them, multiple blocks are respectively set with unique identifiers, and the unique identifiers are used for multi-threaded access to multiple blocks. Through block partitioning, the number of instances in each block can be limited, lock competition can be reduced, and the efficiency of multi-threaded concurrent access can be improved. Each block has a unique identifier, which is convenient for quickly locating problems during management and monitoring, and improves the convenience of maintenance.

[0030] Furthermore, Java instances of the same type to be divided are divided into the same block in the order of the division queue. The activity of Java instances in each block is continuously monitored, which usually includes key indicators such as memory usage, Java instance creation rate, and destruction rate. Based on these activity data, the resource configuration or scheduling strategy of the block is dynamically adjusted. For example, if the memory usage of Java instances in a block is continuously high, the memory quota of the block can be increased or some instances can be migrated to blocks with more sufficient resources.

[0031] In one embodiment of the present application, within a preset time period, Java instance creation rates and Java instance destruction rates corresponding to multiple blocks are obtained. The Java instance creation rate and the Java instance destruction rate are compared to determine the Java instance activity rates corresponding to the multiple blocks. Based on the Java instance activity rates corresponding to the multiple blocks and the memory occupancy rates corresponding to the multiple blocks, the block adjustment dynamic values ​​corresponding to the multiple blocks are obtained to dynamically adjust the multiple blocks.

[0032] Specifically, within a preset time period, such as every minute, every hour, etc., the number of newly created Java instances and the number of destroyed Java instances in each block are recorded. Then, the ratio of these two numbers to the length of the time period is calculated, that is, the creation rate and destruction rate of the Java instance are obtained. By comparing the ratio between the creation rate and the destruction rate, the activity rate of the Java instance is obtained. The activity rate index in the embodiment of the present application reflects the net growth or decrease rate of the Java instance in the block, thereby indirectly reflecting the activity level of the block. After obtaining the Java instance activity rate and memory occupancy rate of each block, the adjusted dynamic value of the block can be calculated based on these two indicators.

[0033] Furthermore, the calculation of the adjustment dynamic value involves the weighted sum of multiple factors:

[0034] Block adjustment dynamic value = α*(memory occupancy rate) + β*(activity rate);

[0035] Among them, α and β are weight coefficients used to adjust the relative importance of memory occupancy and activity rate in dynamic value calculation. Based on the calculated block adjustment dynamic value, a series of measures are taken to dynamically adjust the resource allocation of the block. For blocks with high memory occupancy and high activity rate, the memory quota needs to be increased to support more instances; conversely, for blocks with low memory occupancy and low activity rate, the memory quota is reduced to release resources.

[0036] Step 102: Determine the usage frequencies and life cycles of the Java instances in the multiple blocks, and divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the usage frequencies and life cycles.

[0037] In one embodiment of the present application, the usage frequency corresponding to the Java instances in each block is obtained, the usage frequency is compared with the preset frequency threshold, and based on the comparison result, the Java instances in each block are divided into a first instance set and a second instance set. The life cycle corresponding to the Java instances in each block is obtained, the life cycle is compared with the preset period threshold, and based on the comparison result, the Java instances in each block are divided into a third instance set and a fourth instance set. Based on the intersection of the first instance set, the second instance set, the third instance set, and the fourth instance set, the Java instances in each block are divided into a long-term Java instance set and a short-term Java instance set.

[0038] Specifically, first, the usage frequency data of Java instances in each block is collected, and the usage frequency of each Java instance is compared with the preset threshold. If the usage frequency of the instance is higher than the threshold, it is divided into a first instance set, that is, high-frequency instances; otherwise, it is divided into a second instance set, that is, low-frequency instances. Secondly, the life cycle data of each Java instance is collected, that is, the length of time from their creation to their destruction, and the life cycle of each Java instance is compared with the preset threshold. If the life cycle of the instance is longer than the threshold, it is divided into a third instance set, that is, a long-term instance; otherwise, it is divided into a fourth instance set, that is, a short-term instance. Further, based on the classification results, the final classification of each Java instance is determined by intersection analysis.

[0039] In one embodiment of the present application, the first instance set and the third instance set are subjected to intersection processing, and the intersection processing result is used as a long-term Java instance set. The first instance set and the fourth instance set are subjected to intersection processing, and the intersection processing result is used as a short-term Java instance set. The second instance set and the third instance set are subjected to intersection processing, and the intersection processing result is used as a long-term Java instance set. The second instance set and the fourth instance set are subjected to intersection processing, and the intersection processing result is used as a short-term Java instance set.

[0040] Specifically, the first instance set (high-frequency instances) and the third instance set (long-term survival instances) are intersected, and the resulting intersection includes all Java instances that are both high-frequency and long-lived, which can be used as a long-term Java instance set. The first instance set (high-frequency instances) and the fourth instance set (short-term survival instances) are intersected, and the resulting intersection includes all Java instances that are both high-frequency and short-lived, which can be used as a short-term Java instance set. The second instance set (low-frequency instances) and the third instance set (long-term survival instances) are intersected, and the resulting intersection includes all Java instances that are both low-frequency and long-lived, which can be used as a long-term Java instance set. The second instance set (low-frequency instances) and the fourth instance set (short-term survival instances) are intersected, and the resulting intersection includes all Java instances that are both low-frequency and short-lived, which can be used as a short-term Java instance set.

[0041] Step 103: Obtain resource utilization rates corresponding to the multiple blocks respectively, and determine the recycling duration based on the resource utilization rates.

[0042] In one embodiment of the present application, based on a preset interval time period, the total block memory corresponding to each of the multiple blocks and the occupied memory corresponding to each block are obtained. Based on the ratio between the occupied memory corresponding to each block and the total block memory, the resource utilization rate corresponding to each block is obtained. The resource utilization rate is compared with the preset resource threshold to obtain a first difference; and the resource utilization rates corresponding to two adjacent interval time periods are calculated to obtain a second difference. The recycling time is determined based on the first difference and the second difference.

[0043] Specifically, according to the preset interval time period, such as every 5 minutes, the memory usage of each block is collected, including the total memory of each block, that is, the maximum amount of memory that can be allocated to the block, and the occupied memory, that is, the amount of memory currently in use. Based on the occupied memory and total memory of each block, the resource utilization rate of each block is calculated. Among them:

[0044] Resource usage = occupied memory / total memory.

[0045] Further, the resource utilization rate of each block is compared with a preset resource threshold to obtain a first difference. For each block, the difference in resource utilization rates in two adjacent interval time periods is calculated to obtain a second difference. The recycling time is determined based on the first difference and the second difference.

[0046] In one embodiment of the present application, the first difference is compared with the first preset weight allocation table to determine the first weight value corresponding to the first difference. Based on the second difference values ​​corresponding to the consecutive interval time periods, a difference table is constructed to determine the usage change through the difference table. The usage change is compared with the second preset weight allocation table to determine the second weight corresponding to each interval time period. Based on the first weight and the second weight, the recycling time corresponding to each interval time period is determined.

[0047] Specifically, the calculated first difference is compared with the first preset weight allocation table to determine the first weight value corresponding to each block. The first weight value reflects the degree to which the current resource usage rate of the block exceeds the threshold, and the importance of this degree to the recycling time decision.

[0048] Furthermore, based on the second difference of each block in the continuous interval time period, that is, the difference in resource utilization between two adjacent time points, a difference table is constructed. The second difference table reflects the changing trend of resource utilization, whether it is increasing, decreasing or remaining stable. The usage change (that is, the value in the difference table) is compared with the second preset weight allocation table to determine the second weight corresponding to each interval time period. This weight value reflects the importance of the changing trend of resource utilization for the recycling time decision.

[0049] Furthermore, the first weight and the second weight of each block in each interval time period are combined to determine the recycling time in the time period. Assume that the calculation rule of the recycling time is:

[0050] Recovery time = basic time * (first weight + second weight);

[0051] For block A in the first interval time period, the recovery time = 10 minutes * (1 + 2) = 30 minutes. It should be noted that the "basic time" in the embodiment of the present application is a preset value, which is used to adjust the basic unit of the recovery time.

[0052] Step 104: Based on the recycling duration, the Java instances to be recycled in the long-term Java instance sets and the short-term Java instance sets corresponding to the multiple blocks are recycled to complete the Java instance pool optimization.

[0053] In one embodiment of the present application, a long-term instance that needs to be recycled is determined from a long-term Java instance set of multiple blocks, and a short-term instance that needs to be recycled is determined from each short-term Java instance set of multiple blocks. After the recycling time is reached, the long-term instances that need to be recycled in each block are recycled in turn. The short-term instances that need to be recycled in each block are recycled in real time.

[0054] Specifically, in the long-term Java instance set of each block, based on a series of criteria such as instance activity, last use time, and memory size, we evaluate which instances are no longer needed or have relatively low retention value. After evaluation, we determine a group of instances that need to be recycled from the long-term Java instance set of each block. Similarly, we determine a group of instances that need to be recycled from the short-term Java instance set of each block.

[0055] Furthermore, the long-term instance recycling is started based on the calculated recycling time. When the recycling time is reached, the system will sequentially traverse the long-term Java instance set of each block and recycle the instances marked as needing recycling. This process can be performed in batches to avoid excessive impact on system performance.

[0056] Furthermore, due to the short life cycle of short-term instances and the fact that they may occupy fewer resources, the system will usually choose to recycle them in real time. That is, after an instance is determined to need to be recycled, the recycling operation will be performed immediately without waiting for a specific recycling duration. The embodiment of the present application will check the short-term Java instance set regularly or in a triggered manner, and recycle the instances marked as needing to be recycled in real time. This recycling method helps to maintain the resource utilization and performance of the system.

[0057] For example, the system contains three blocks A, B, and C. Each block has its own long-term and short-term Java instance sets. Block A: In the long-term Java instance set, after evaluation, it was found that instances X and Y are no longer active and occupy a large amount of memory, so they are marked as needing to be recycled. In the short-term Java instance set, instance Z has completed its task and is marked as needing to be recycled. When the recycling time is reached, the system first recycles instances X and Y in block A. At the same time, the system recycles the short-term instance Z in block A in real time.

[0058] Figure 2 A schematic diagram of the structure of a Java instance pool optimization device provided in an embodiment of the present application. Figure 2As shown, the Java instance pool optimization device 200 includes: at least one processor 201; and a memory 202 that is communicatively connected to the at least one processor 201; wherein the memory 202 stores instructions that can be executed by the at least one processor 201, and the instructions are executed by the at least one processor 201, so that the at least one processor 201 can: divide the Java instance pool into multiple blocks according to the Java instance type; wherein the multiple blocks are respectively provided with unique identifiers, and the unique identifiers are used for multi-threaded access to the multiple blocks. Determine the usage frequency and life cycle corresponding to the Java instances in the multiple blocks, and divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the usage frequency and life cycle. Obtain the resource utilization rates corresponding to the multiple blocks, and determine the recycling duration based on the resource utilization rates. Based on the recycling duration, recycle the Java instances to be recycled in the long-term Java instance set and the short-term Java instance set corresponding to the multiple blocks.

[0059] A non-volatile computer storage medium provided in an embodiment of the present application stores computer executable instructions, and the computer executable instructions are configured to: divide a Java instance pool into multiple blocks according to the Java instance type; wherein a unique identifier is set for each of the multiple blocks, and the unique identifier is used for multi-threaded access to the multiple blocks. Determine the usage frequency and life cycle corresponding to the Java instances in the multiple blocks, and based on the usage frequency and life cycle, divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set. Obtain the resource utilization rates corresponding to the multiple blocks, and determine the recycling time based on the resource utilization rates. Based on the recycling time, recycle the Java instances to be recycled in the long-term Java instance set and the short-term Java instance set corresponding to the multiple blocks.

[0060] Each embodiment in this application is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and non-volatile computer storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0061] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the embodiments of the present application may have various changes and variations. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present application.

Claims

1. A Java instance pool optimization method, characterized in that: The method comprises: According to the Java instance type, the Java instance pool is divided into a plurality of blocks; wherein the plurality of blocks are respectively provided with a unique identifier, and the unique identifier is used for multi-threaded access to the plurality of blocks; Determine usage frequencies and life cycles corresponding to the Java instances in the plurality of blocks, and divide the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the usage frequencies and the life cycles; Obtain resource usage rates corresponding to the plurality of blocks respectively, and determine a recycling duration based on the resource usage rates; Based on the recycling duration, the long-term Java instance sets and the to-be-reclaimed Java instances in the short-term Java instance sets respectively corresponding to the plurality of blocks are recycled to complete the Java instance pool optimization.

2. A Java instance pool optimization method according to claim 1, characterized in that: The Java instance pool is divided into multiple blocks according to the Java instance type, specifically including: Building a partition queue based on multiple Java instances in the Java instance pool; Obtaining a metadata field corresponding to the Java instance to be divided, and determining a type corresponding to the Java instance to be divided based on the metadata field; Based on the partition queue order, the Java instances to be partitioned of the same type are partitioned into the same block; The Java instance activities corresponding to the plurality of blocks are obtained, and the plurality of blocks are dynamically adjusted based on the Java instance activities; wherein the Java instance activity includes at least one of the memory occupancy rate, the Java instance creation rate, and the Java instance destruction rate.

3. A Java instance pool optimization method according to claim 2, characterized in that: The obtaining of Java instance activities corresponding to the plurality of blocks respectively, and dynamically adjusting the plurality of blocks based on the Java instance activities specifically includes: Within a preset time period, obtaining Java instance creation rates and Java instance destruction rates corresponding to the plurality of blocks respectively; Comparing the Java instance creation rate with the Java instance destruction rate to determine the Java instance activity rates corresponding to the plurality of blocks respectively; Based on the Java instance activity rates respectively corresponding to the multiple blocks and the memory occupancy rates respectively corresponding to the multiple blocks, the block adjustment dynamic values ​​respectively corresponding to the multiple blocks are obtained to dynamically adjust the multiple blocks.

4. A Java instance pool optimization method according to claim 1, characterized in that: The Java instances in each of the blocks are divided into a long-term Java instance set and a short-term Java instance set based on the usage frequency and the life cycle, specifically including: Obtaining usage frequencies respectively corresponding to the Java instances in each of the blocks, comparing the usage frequencies with a preset frequency threshold, and dividing the Java instances in each of the blocks into a first instance set and a second instance set based on the comparison result; Obtaining life cycles corresponding to the Java instances in each of the blocks, respectively, comparing the life cycles with a preset period threshold, and dividing the Java instances in each of the blocks into a third instance set and a fourth instance set based on the comparison result; Based on the intersection of the first instance set, the second instance set, the third instance set and the fourth instance set, the Java instances in each block are divided into a long-term Java instance set and a short-term Java instance set.

5. A Java instance pool optimization method according to claim 4, characterized in that: The dividing the Java instances in each block into a long-term Java instance set and a short-term Java instance set based on the intersection of the first instance set, the second instance set, the third instance set, and the fourth instance set specifically includes: Performing intersection processing on the first instance set and the third instance set, and using the intersection processing result as the long-term Java instance set; and Performing intersection processing on the first instance set and the fourth instance set, and using the intersection processing result as the short-term Java instance set; and Performing intersection processing on the second instance set and the third instance set, and using the intersection processing result as the long-term Java instance set; and An intersection process is performed on the second instance set and the fourth instance set, and the intersection process result is used as the short-term Java instance set.

6. A Java instance pool optimization method according to claim 1, characterized in that: The obtaining resource usage rates respectively corresponding to the plurality of blocks and determining the recycling duration based on the resource usage rates specifically includes: Based on a preset interval time period, obtaining a total block memory corresponding to each of the plurality of blocks and an occupied memory corresponding to each of the blocks; Based on the ratio between the occupied memory corresponding to each of the blocks and the total memory of the blocks, obtaining the resource usage rate corresponding to each of the blocks; Comparing the resource usage rate with a preset resource threshold to obtain a first difference; and Calculate the difference between the resource usage rates corresponding to two adjacent interval time periods to obtain a second difference; The recycling time is determined based on the first difference and the second difference.

7. A Java instance pool optimization method according to claim 6, characterized in that: The determining the recycling time based on the first difference and the second difference specifically includes: Comparing the first difference with a first preset weight allocation table to determine a first weight value corresponding to the first difference; Based on the second differences respectively corresponding to the consecutive interval time periods, a difference table is constructed to determine the usage rate change through the difference table; Comparing the usage rate change with the second preset weight allocation table to determine the second weights corresponding to each interval time period; Based on the first weight and the second weight, the recycling durations corresponding to the respective interval time periods are determined.

8. A Java instance pool optimization method according to claim 1, characterized in that: The step of reclaiming the long-term Java instance sets and the to-be-reclaimed Java instances in the short-term Java instance sets respectively corresponding to the plurality of blocks based on the reclaim duration specifically includes: Determining a long-term instance that needs to be recycled from a set of long-term Java instances of the plurality of blocks, and determining a short-term instance that needs to be recycled from a set of short-term Java instances of the plurality of blocks; After the recycling time is reached, the long-term instances that need to be recycled in each of the blocks are recycled in turn; The short-term instances that need to be recycled in each of the blocks are recycled in real time.

9. A Java instance pool optimization device, characterized in that: The device comprises a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the device is triggered to execute the method according to any one of claims 1 to 8.

10. A non-volatile computer storage medium storing computer executable instructions, characterized in that: The computer executable instructions can execute the method according to any one of claims 1 to 8.