Instance management method and device based on JVM process

By detecting application interface requests and judging the JVM process mode, deciding whether to start a new JVM process, solving the problem of JVM process heap memory overflow, ensuring the normal operation and service stability of the JVM process.

CN120276807APending Publication Date: 2025-07-08BEIJING VENUS INFORMATION SECURITY TECH +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510475819.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-16
Publication Date
2025-07-08

AI Technical Summary

Technical Problem

When running multiple Web services in a cloud host or virtualized environment, the heap memory of the JVM process may exceed the preset threshold, causing an abnormal stop, affecting service availability.

Method used

By detecting application interface requests, judging the JVM process mode, deciding whether to start a new JVM process, ensuring that the new instance runs in the appropriate process, and avoiding heap memory overflow.

Benefits of technology

Effectively manage JVM processes, prevent heap memory overflow, and ensure the normal operation of JVM processes and service stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120276807A_ABST
    Figure CN120276807A_ABST
Patent Text Reader

Abstract

The invention discloses an instance management method and device based on a JVM process. The method comprises the steps that a calling request of an application interface is received; detecting whether an instance corresponding to the application interface exists or not; if the instance corresponding to the application interface does not exist, creating a new instance corresponding to the application interface; obtaining a JVM process mode corresponding to the application interface, and judging whether the new instance needs to start a new JVM process or not according to the JVM process mode; if the newly added instance needs to start the new JVM process, starting the new JVM process; the new JVM process is used for running the newly-added instance, the newly-added instance is registered, and the application interface is called through the newly-added instance. According to different JVM process modes, whether a new JVM process needs to be started for the newly added instance or not is judged, and whether the new JVM process needs to be started to operate the newly added instance or not is determined according to the judgment result, so that all instances are prevented from operating in the same JVM process, and normal operation of the JVM process is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular, to a method and device for instance management based on a JVM process. Background Art

[0002] When running multiple Web services in a cloud host or virtualized environment, some challenges are usually encountered, such as the need to repeatedly execute the same operations. Each Web container usually requires an independent configuration and startup process, and each container consumes a certain amount of resources, which makes management more complex.

[0003] To solve these problems, multiple Spring Boot projects can be merged into a single Spring container and run in the same Java Virtual Machine (JVM) process. By isolating the project prefixes and configuration items, multiple Spring Boot projects can run in the same JVM without interfering with each other. However, this approach is limited to Spring Boot projects running in the same JVM process and does not consider that the heap memory required by the JVM process may exceed the preset heap memory threshold. When the heap memory overflows, the JVM process may stop abnormally, resulting in service unavailability.

[0004] Therefore, how to ensure the normal operation of the JVM process has become an urgent problem to be solved in this field. Summary of the Invention

[0005] This application provides a method and device for instance management based on a JVM process, aiming to ensure the normal operation of the JVM process.

[0006] To achieve the above object, this application provides the following technical solutions:

[0007] A method for instance management based on a JVM process includes:

[0008] When a call request for an application interface is received, detect whether there is an instance corresponding to the application interface;

[0009] If there is no instance corresponding to the application interface, create a new instance corresponding to the application interface;

[0010] Obtain the Java virtual machine JVM process mode corresponding to the application interface;

[0011] Determine whether the new instance needs to start a new JVM process according to the JVM process mode;

[0012] If the new instance needs to start the new JVM process, start the new JVM process;

[0013] After the new JVM process starts successfully, run the newly added instance using the new JVM process and register the newly added instance.

[0014] After the newly added instance is registered, call the application interface using the newly added instance.

[0015] Optionally, determining whether the newly added instance needs to start a new JVM process according to the JVM process mode includes:

[0016] When the JVM process mode is the single-instance process mode, determine that the newly added instance needs to start the new JVM process.

[0017] Optionally, determining whether the newly added instance needs to start a new JVM process according to the JVM process mode includes:

[0018] When the JVM process mode is the single-application-instance shared process mode, detect whether there is an instance in the application that is the same as the newly added instance;

[0019] If there is an instance that is the same as the newly added instance, determine that the newly added instance needs to start the new JVM process;

[0020] If there is no instance that is the same as the newly added instance, determine whether the status of the shared process in the application is the normal status;

[0021] If the status of the shared process in the application is the normal status, determine that the newly added instance does not need to start the new JVM process;

[0022] If the status of the shared process in the application is not the normal status, determine that the newly added instance needs to start the new JVM process.

[0023] Optionally, determining whether the newly added instance needs to start a new JVM process according to the JVM process mode includes:

[0024] When the JVM process mode is the multi-application-instance shared process mode, obtain the number of applications registered in each shared process;

[0025] Determine the shared process with the smallest number of applications as the current process;

[0026] Determine whether the number of applications in the current process is greater than the preset registration number;

[0027] If the number of applications in the current process is greater than the preset registration number, determine that the newly added instance needs to start the new JVM process;

[0028] If the number of applications in the current process is not greater than the preset registration number, obtain and calculate the sum value of the preset application setting heap and the cumulative heap of the registered applications in the current process;

[0029] Determine whether the sum value is greater than the preset process threshold;

[0030] If the sum value is greater than the preset process threshold, filter out the shared processes from all the application numbers that are greater than the number of applications in the current process and less than the number of applications in other processes, and after determining them as the current process, return to execute the step of determining whether the number of applications in the current process is greater than the preset registration number; the number of applications in other processes indicates the shared processes other than the current process;

[0031] If the sum value is not greater than the preset process threshold, determine whether the status of the current process is the normal status;

[0032] If the status of the current process is not the normal status, filter out the shared processes from all the application numbers that are greater than the number of applications in the current process and less than the number of applications in other processes, and after determining them as the current process, return to execute the step of determining whether the number of applications in the current process is greater than the preset registration number;

[0033] If the status of the current process is the normal status, determine that the new instance does not need to start the new JVM process.

[0034] Optionally, it further includes:

[0035] When there is no shared process in all the application numbers that is greater than the number of applications in the current process, determine that the new instance needs to start the new JVM process.

[0036] Optionally, it further includes:

[0037] When receiving an instance update request, determine whether the status of the JVM process corresponding to the instance is the normal status;

[0038] If the status of the JVM process corresponding to the instance is the normal status, update the instance information of the instance in the JVM process;

[0039] If the status of the JVM process corresponding to the instance is not the normal status, start the new JVM process.

[0040] Optionally, it further includes:

[0041] When receiving an instance deletion request, obtain the process mode corresponding to the instance;

[0042] Judge whether it is necessary to close the JVM process corresponding to the instance according to the process mode;

[0043] If it is necessary to close the JVM process corresponding to the instance, delete the instance information of the instance and close the JVM process corresponding to the instance;

[0044] If it is not necessary to close the JVM process corresponding to the instance, send the instance deletion request to the JVM process so that the JVM process deletes the instance.

[0045] Optionally, the judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes:

[0046] When the process mode is a single-instance process mode, it is determined that it is necessary to close the JVM process corresponding to the instance.

[0047] Optionally, the judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes:

[0048] When the process mode is a single-application instance sharing process mode, delete the instance information of the instance;

[0049] After the instance information of the instance is deleted, detect whether the instance is a preset instance;

[0050] If the instance is the preset instance, it is determined that it is necessary to close the JVM process corresponding to the instance;

[0051] If the instance is not the preset instance, it is determined that it is not necessary to close the JVM process corresponding to the instance.

[0052] Optionally, the judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes:

[0053] When the process mode is a multi-application instance sharing process mode, delete the instance information of the instance;

[0054] After the instance information of the instance is deleted, detect whether there are other application instances in the shared process where the instance is located;

[0055] If there are no other application instances in the shared process where the instance is located, it is determined that it is necessary to close the JVM process corresponding to the instance;

[0056] If there are other application instances in the shared process where the instance is located, it is determined that it is not necessary to close the JVM process corresponding to the instance.

[0057] An instance management device based on a JVM process, comprising:

[0058] A detection unit, configured to detect whether there is an instance corresponding to the application interface when receiving a call request for the application interface;

[0059] A creation unit, configured to create a new instance corresponding to the application interface if there is no instance corresponding to the application interface;

[0060] An acquisition unit, configured to acquire the Java Virtual Machine (JVM) process mode corresponding to the application interface;

[0061] A judgment unit, configured to judge whether the new instance needs to start a new JVM process according to the JVM process mode;

[0062] A start unit, configured to start the new JVM process if the new instance needs to start the new JVM process;

[0063] An operation unit, configured to, after the new JVM process is started, run the new instance by using the new JVM process and register the new instance;

[0064] A call unit, configured to, after the new instance is registered, call the application interface by using the new instance.

[0065] The technical solution provided by this application receives a call request for an application interface; detects whether there is an instance corresponding to the application interface; if there is no instance corresponding to the application interface, creates a new instance corresponding to the application interface; acquires and judges whether the new instance needs to start a new JVM process according to the JVM process mode corresponding to the application interface; if the new instance needs to start a new JVM process, starts the new JVM process; runs the new instance by using the new JVM process, registers the new instance, and calls the application interface by using the new instance. According to different JVM process modes, it is judged whether a new JVM process needs to be started for the new instance, and according to the judgment result, it is decided whether to start a new JVM process to run the new instance, so as to avoid all instances running in the same JVM process and ensure the normal operation of the JVM process. Description of the Drawings

[0066] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0067] Figure 1 It is a flowchart of a method for instance management based on the JVM process provided by an embodiment of the present application;

[0068] Figure 2 Flow chart of a method for judging process startup provided by an embodiment of the present application;

[0069] Figure 3 Flow chart of another method for judging process startup provided by an embodiment of the present application;

[0070] Figure 4 Flow chart of a method for instance update provided by an embodiment of the present application;

[0071] Figure 5 Flow chart of a method for instance deletion provided by an embodiment of the present application;

[0072] Figure 6 Flow chart of a method for judging process shutdown provided by an embodiment of the present application;

[0073] Figure 7 Flow chart of another method for judging process shutdown provided by an embodiment of the present application;

[0074] Figure 8 Schematic diagram of the architecture of an instance management device based on the JVM process provided by an embodiment of the present application. Detailed implementation manners

[0075] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0076] In the present application, the term "comprising", "including" or any other variant thereof is intended to cover a non-exclusive inclusion, such that a process, method, article or device comprising a series of elements includes not only those elements but also other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the phrase "comprising a..." does not exclude the presence of additional identical elements in the process, method, article or device comprising the element.

[0077] As Figure 1 shown, a flow chart of an instance management method based on the JVM process provided by an embodiment of the present application includes the following steps:

[0078] S101: When a call request of an application interface is received, detect whether there is an instance corresponding to the application interface.

[0079] If there is no instance corresponding to the application interface, step S102 is executed.

[0080] Among them, the application interface is the API interface provided by the application. An instance generally refers to a specific object created through a class or interface, which is the specific manifestation of a certain class definition or interface convention in the code.

[0081] The so-called application is actually a customizable plug-in that can be integrated into the system by means of dynamic upload or built-in. The application implements relevant functions internally according to specifications and exposes them externally in the form of actions. Each application can define instance information that needs to be dynamically configured, such as custom fields like IP, port, username, password, etc. At the same time, each application can also configure the heap size required when the process starts (i.e., preset application settings heap). If not specified, the default value is used.

[0082] Optionally, the instance fields corresponding to each application are predefined by the application developer and support dynamic configuration of instance information. For example, the firewall application can be deployed on multiple devices, and the IP, port, username, password, etc. of each device are different. The device is equivalent to an instance of the firewall application, and the relevant interfaces of the device need to be called through these instance information.

[0083] It can be understood that when a call request for the application interface is received, it needs to be called through the instance corresponding to the application interface, and this instance is an already started instance. Therefore, it is necessary to first detect whether there is an instance corresponding to the application interface. If there is an instance corresponding to the application interface, then directly call the application interface using the instance corresponding to the application interface. If there is no instance corresponding to the application interface, then step S102 is executed.

[0084] S102: Create a new instance corresponding to the application interface.

[0085] It should be noted that when creating a new instance, it is necessary to select an already integrated application and fill in the custom instance information required by the application (such as IP, port, username, password, etc.). The filled information will be saved so that the instance can be correctly configured and used subsequently.

[0086] S103: Obtain the Java Virtual Machine (JVM) process mode corresponding to the application interface.

[0087] Among them, the Java Virtual Machine (JVM) process mode is divided into single-instance process mode, single-application instance shared process mode, and multi-application instance shared process mode.

[0088] The single-instance process mode means that each time a new instance is added, a process needs to be started.

[0089] The single application instance sharing process mode means that instances under the same application share a single process.

[0090] The multi-application instance sharing process mode means that instances under multiple applications can share a single process, and the number of applications sharing the process, the initial heap size of the process, and the process threshold (the percentage of the cumulative heap size of applications within the process to the initial heap size) can be configured and controlled; these settings are specified in a configuration file before the service starts and do not support dynamic modification.

[0091] It should be noted that the process mode is specified in a configuration file before the service starts and does not support dynamic modification.

[0092] S104: Determine whether a new JVM process needs to be started based on the JVM process mode for the new instance.

[0093] If a new JVM process needs to be started for the new instance, then execute step S105.

[0094] It can be understood that when determining whether a new JVM process needs to be started based on the JVM process mode for the new instance, the judgment logic is different for different JVM process modes. If it is determined that a new JVM process does not need to be started for the new instance, then the new instance can be directly run using the original JVM process.

[0095] Optionally, in another embodiment of the present application, the specific implementation of step S104 includes:

[0096] When the JVM process mode is the single instance process mode, it is determined that a new JVM process needs to be started for the new instance.

[0097] It can be understood that when the JVM process mode is the single instance process mode, that is, a new process needs to be started each time a new instance is added, then it is determined that a new JVM process needs to be started for the new instance, and the new JVM process is directly started using the java-jar command.

[0098] It should be noted that when starting a process using the java-jar command, the main method in the java-jar command is mainly used to start the Jetty service to listen for relevant requests, and different processing will be done for different URL requests. One of the URL listeners is used to determine whether the process has started successfully. When starting the process, requests are sent every three seconds within one minute. A successful response indicates that the process has started successfully. If the JVM process has started successfully, a registration instance request is sent.

[0099] In addition, if the current application does not set JVM parameter information, the process is started using the default JVM configuration (such as the heap size), otherwise the process is started using the JVM parameter information set by the application.

[0100] Optionally, in another embodiment of the present application, the specific implementation manner of step S104 is as Figure 2 shown, and includes the following steps:

[0101] S201: When the JVM process mode is the single application instance sharing process mode, detect whether there is an instance in the application that is the same as the newly added instance.

[0102] If there is an instance in the application that is the same as the newly added instance, then execute step S202; if there is no instance in the application that is the same as the newly added instance, then execute step S203.

[0103] It can be understood that detecting whether there is an instance in the application that is the same as the newly added instance is also detecting whether the newly added instance is the first addition to the application. If the newly added instance is the first addition to the application, then execute step S202; if the newly added instance is not the first addition to the application, then execute step S203.

[0104] It should be noted that when the JVM process is in the single application instance sharing process mode, all instances under this application will share the same JVM process. Specifically, when the application instance is added for the first time, a new JVM process will be started and the information of this process will be recorded. After that, when the application instance is added again, the system will check whether this JVM process has been started. If this process has been started, the new instance will share this process instead of starting a new JVM process.

[0105] S202: Determine that the newly added instance needs to start a new JVM process.

[0106] S203: Judge whether the status of the shared process in the application is the normal status.

[0107] If the status of the shared process in the application is the normal status, then execute step S204; if the status of the shared process in the application is not the normal status, then execute step S205.

[0108] It can be understood that judging whether the status of the shared process in the application is the normal status is also judging whether the shared process in the application is alive. If the status of the shared process in the application is the normal status, it means that the shared memory is in the alive state, then execute step S204; if the status of the shared process in the application is not the normal status, it means that the shared memory is in the invalid state, then execute step S205.

[0109] Specifically, to judge whether the shared process in the application is alive, there is a alive monitoring interface inside the shared process, and if it can respond normally, it means the process is alive.

[0110] S204: Determine that the newly added instance does not need to start a new JVM process.

[0111] It can be understood that when the status of the shared process in the application is normal, the newly added instance can be run using the shared process, and a registration instance request is sent to register the newly added instance.

[0112] S205: Determine that the newly added instance needs to start a new JVM process.

[0113] It can be understood that when the status of the shared process in the application is not normal, a new JVM process needs to be started, the newly added instance is run through the new JVM process, and a registration request for all instances in the application is sent to register all instances in the application.

[0114] Optionally, in another embodiment of the present application, the specific implementation manner of step S104, as Figure 3 shown, includes the following steps:

[0115] S301: When the JVM process mode is the multi-application instance shared process mode, obtain the number of applications registered in each shared process.

[0116] S302: Determine the shared process with the smallest number of applications as the current process.

[0117] For example, there are three shared processes, namely the first shared process (the number of applications is 5), the second shared process (the number of applications is 3), and the third shared process (the number of applications is 6). The shared process with the smallest number of applications is selected from the three shared processes as: the second shared process, and the second shared process is determined as the current process.

[0118] S303: Determine whether the number of applications in the current process is greater than the preset registration number.

[0119] If the number of applications in the current process is greater than the preset registration number, then execute step S304. If the number of applications in the current process is not greater than the preset registration number, then execute step S305.

[0120] Optionally, the preset registration number can be set according to the actual situation and is not specifically limited here.

[0121] S304: Determine that the newly added instance needs to start a new JVM process.

[0122] S305: Obtain and calculate the sum value of the preset application setting heap and the cumulative heap of the registered applications in the current process.

[0123] S306: Determine whether the sum value is greater than the preset process threshold.

[0124] If the sum value is greater than the preset process threshold, step S307 is executed; if the sum value is not greater than the preset process threshold, step S308 is executed.

[0125] Optionally, the preset process threshold can be set according to the actual situation and is not specifically limited here.

[0126] S307: Filter out the shared processes whose number of applications is greater than the number of applications of the current process and less than the number of applications of other processes from all the numbers of applications. After determining it as the current process, return to execute step S303.

[0127] Among them, the number of applications of other processes indicates the shared processes except the current process.

[0128] For example, if the current process is the second shared process, the number of applications of the first shared process is 5, the number of applications of the second shared process is 3, and the number of applications of the third shared process is 6. Filter out the shared processes whose number of applications is greater than the number of applications of the current process and less than the number of applications of other processes from all the numbers of applications. The shared process is the first shared process. After determining the first shared process as the current process, return to execute step S303.

[0129] S308: Determine whether the status of the current process is the normal status.

[0130] If the status of the current process is not the normal status, step S309 is executed; if the status of the current process is the normal status, step S310 is executed.

[0131] It should be noted that the specific implementation manner of step S308 can be correspondingly referred to step S203 and will not be elaborated here.

[0132] S309: Filter out the shared processes whose number of applications is greater than the number of applications of the current process and less than the number of applications of other processes from all the numbers of applications. After determining it as the current process, return to execute step S303.

[0133] It should be noted that the specific implementation manner of step S309 can be correspondingly referred to step S307 and will not be elaborated here.

[0134] S310: Determine that the new instance does not need to start a new JVM process.

[0135] It can be understood that if the status of the current process is the normal status, the new instance can be run using the shared process, and at this time it is determined that the new instance does not need to start a new JVM process.

[0136] Optionally, after all the shared processes are sequentially judged whether they can start the new instance, it is determined whether a new JVM process needs to be started according to the judgment results, so as to realize the reasonable allocation and optimization of system resources. Therefore, in another embodiment of the present application, a method for determining process startup is provided, including:

[0137] When there is no shared process with a number of applications greater than that of the current process among all the application numbers, it is determined that the new instance needs to start a new JVM process.

[0138] It can be understood that when there is no shared process with a number of applications greater than that of the current process among all the application numbers, that is, when all the shared processes do not meet the conditions for running the new instance, at this time, a new JVM process is started, the new instance is registered, and the process information and the cumulative heap of the registered applications inside the process of the new JVM process are recorded.

[0139] S105: Start a new JVM process.

[0140] Optionally, the java-jar command (such as java-jar BootStrap.ja) can be used to start a new JVM process.

[0141] S106: When the new JVM process starts up, use the new JVM process to run the new instance and register the new instance.

[0142] Among them, the main method in BootStrap.jar is mainly responsible for starting the Jetty service to listen for and handle related requests. For different URL requests, the system will perform different processing operations. Among them, there is a specific URL used to listen for and handle requests for "registering an instance". When this request is received, the configuration data (such as instance information) filled in when adding the new instance will be carried along and sent through this request. Subsequently, in the new JVM process, the registered instance information will be maintained for subsequent management and operation of the instances.

[0143] S107: When the new instance is registered, use the new instance to call the application interface.

[0144] Optionally, after step S107, when an instance update request is received, update the instance. Through the update, the system can maintain the latest functional and performance requirements, ensure stable operation, and adapt to changing requirements. Therefore, in another embodiment of the present application, an instance update method is provided, as Figure 4 shown, including the following steps:

[0145] S401: When an instance update request is received, determine whether the status of the JVM process corresponding to the instance is a normal status.

[0146] If the status of the JVM process corresponding to the instance is a normal status, execute step S402. If the status of the JVM process corresponding to the instance is not a normal status, execute step S403.

[0147] Among them, an instance update request indicates a request to update the instance information of an instance.

[0148] For example, the application instance corresponds to a firewall device, and fields such as IP, port, username, and password are defined. At this time, if the username and password of the device change, it is necessary to edit the instance information and synchronously update the instance information inside the process.

[0149] In step S401, it is judged whether the state of the JVM process corresponding to the instance is the normal state. Specifically, the JVM process provides a listening entry, and it is judged whether the state of the JVM process corresponding to the instance is the normal state according to the listening entry (that is, it is judged whether the JVM process corresponding to the instance is alive). If the listening entry can respond normally, it means that the JVM process corresponding to the instance is in the normal state. If it cannot respond normally, it means that the JVM process corresponding to the instance is in the abnormal state.

[0150] S402: Update the instance information of the instance in the JVM process.

[0151] It can be understood that updating the instance information of the instance in the JVM process, specifically, sending an instance update request to the JVM process, and the JVM process updates the instance information of the instance.

[0152] S403: Start a new JVM process.

[0153] Among them, when the JVM process is not alive, start a new instance process and register the instance.

[0154] Optionally, after step S107, when the system no longer needs to call the device-related interface, it is necessary to delete the instance to release the relevant system resources, reduce unnecessary load, and improve the performance and stability of the system. Therefore, in another embodiment of the present application, an instance deletion method is provided, as Figure 5 shown, including the following steps:

[0155] S501: When receiving an instance deletion request, obtain the process mode corresponding to the instance.

[0156] Among them, when the application interface does not need to be called, it is necessary to delete the instance corresponding to the application interface to release the relevant resources. For example, close the process and release the JVM memory. When receiving an instance deletion request, first obtain the process mode corresponding to the instance.

[0157] S502: Judge whether it is necessary to close the JVM process corresponding to the instance according to the process mode.

[0158] If it is necessary to close the JVM process corresponding to the instance, then step S503. If it is not necessary to close the JVM process corresponding to the instance, then execute step S504.

[0159] It can be understood that whether it is necessary to close the JVM process corresponding to the instance is judged according to the process mode. Different process modes have different processing logics, and it is necessary to decide according to the specific process mode.

[0160] Optionally, in another embodiment of the present application, the specific implementation manner of step S502 includes:

[0161] When the process mode is a single-instance process mode, it is determined that the JVM process corresponding to the instance needs to be closed.

[0162] It can be understood that when the java-jar BootStrap.jar starts the process, the main method in BootStrap.jar is mainly used to start the Jetty service to listen for relevant requests. Different processing will be done for different URL requests. Among them, when the URL listens to the instance deletion request, the instance is deleted and the JVM process corresponding to the instance is closed.

[0163] Optionally, in another embodiment of the present application, the specific implementation manner of step S502 is as Figure 6 shown, and includes the following steps:

[0164] S601: When the process mode is a single-application instance sharing process mode, the instance information of the instance is deleted.

[0165] S602: After the instance information of the instance is deleted, it is detected whether the instance is a preset instance.

[0166] If the instance is a preset instance, step S603 is executed; if the instance is not a preset instance, step S604 is executed.

[0167] Among them, the preset instance is the last instance in the application.

[0168] S603: Determine that the JVM process corresponding to the instance needs to be closed.

[0169] S604: Determine that it is not necessary to close the JVM process corresponding to the instance.

[0170] It can be understood that when the instance is not a preset instance, a request to delete the instance is sent to the JVM process, so that the JVM process deletes the instance.

[0171] Optionally, in another embodiment of the present application, the specific implementation manner of step S502 is as Figure 7 shown, and includes the following steps:

[0172] S701: When the process mode is a multi-application instance sharing process mode, the instance information of the instance is deleted.

[0173] S702: After the instance information deletion of an instance is completed, check whether there are other application instances in the shared process where the instance is located.

[0174] If there are no other application instances in the shared process where the instance is located, execute step S703; if there are other application instances in the shared process where the instance is located, execute step S704.

[0175] It can be understood that checking whether there are other application instances in the shared process where the instance is located is also to check whether the instance is the last instance of the last application in the shared process. If the instance is the last instance of the last application in the shared process, execute step S703; if the instance is the last instance of the last application in the shared process, execute step S704.

[0176] S703: Determine that the JVM process corresponding to the instance needs to be closed.

[0177] S704: Determine that the JVM process corresponding to the instance does not need to be closed.

[0178] S503: Delete the instance information of the instance and close the JVM process corresponding to the instance.

[0179] S504: Send an instance deletion request to the JVM process so that the JVM process deletes the instance.

[0180] Among them, if the JVM process corresponding to the instance does not need to be closed, send an instance deletion request to the JVM process, so that the JVM process deletes the corresponding instance according to the instance deletion request.

[0181] In summary, according to different JVM process modes, it will be judged whether a new JVM process needs to be started for a newly added instance. According to the judgment result, it is decided whether to start a new JVM process to run the newly added instance, so as to avoid all instances running in the same JVM process and ensure the normal operation of the JVM process.

[0182] As Figure 8 shown, the following is a schematic structural diagram of an instance management device based on the JVM process provided by an embodiment of the present application. The instance management device includes: a detection unit 100, a creation unit 200, an acquisition unit 300, a judgment unit 400, a start unit 500, a running unit 600, and a call unit 700.

[0183] The detection unit 100 is used to detect whether there is an instance corresponding to the application interface when receiving a call request of the application interface.

[0184] The creation unit 200 is used to create a newly added instance corresponding to the application interface if there is no instance corresponding to the application interface.

[0185] An obtaining unit 300, configured to obtain a Java Virtual Machine (JVM) process mode corresponding to an application interface.

[0186] A judging unit 400, configured to judge whether a new instance needs to start a new JVM process according to the JVM process mode.

[0187] Specifically, the judging unit 400 is configured to: when the JVM process mode is a single-instance process mode, determine that the new instance needs to start a new JVM process.

[0188] Specifically, the judging unit 400 is configured to: when the JVM process mode is a single-application-instance shared process mode, detect whether there is an instance in the application that is the same as the new instance; if there is an instance in the application that is the same as the new instance, determine that the new instance needs to start a new JVM process; if there is no instance in the application that is the same as the new instance, judge whether the state of the shared process in the application is a normal state; if the state of the shared process in the application is a normal state, determine that the new instance does not need to start a new JVM process; if the state of the shared process in the application is not a normal state, determine that the new instance needs to start a new JVM process.

[0189] Specifically, the judging unit 400 is configured to: when the JVM process mode is a multi-application-instance shared process mode, obtain the number of applications registered in each shared process; determine the shared process with the smallest number of applications as the current process; judge whether the number of applications in the current process is greater than a preset registration number; if the number of applications in the current process is greater than the preset registration number, determine that the new instance needs to start a new JVM process; if the number of applications in the current process is not greater than the preset registration number, obtain and calculate the sum value of the preset application setting heap and the cumulative heap of the registered applications in the current process; judge whether the sum value is greater than a preset process threshold; if the sum value is greater than the preset process threshold, screen out the shared processes whose number of applications is greater than the number of applications in the current process and less than the number of applications in other shared processes from all the numbers of applications, determine them as the current process, and then return to execute the step of judging whether the number of applications in the current process is greater than the preset registration number; the number of applications in other shared processes indicates the shared processes except the current process; if the sum value is not greater than the preset process threshold, judge whether the state of the current process is a normal state; if the state of the current process is not a normal state, screen out the shared processes whose number of applications is greater than the number of applications in the current process and less than the number of applications in other shared processes from all the numbers of applications, determine them as the current process, and then return to execute the step of judging whether the number of applications in the current process is greater than the preset registration number; if the state of the current process is a normal state, determine that the new instance does not need to start a new JVM process.

[0190] A starting unit 500, configured to start a new JVM process if the new instance needs to start a new JVM process.

[0191] The running unit 600 is used to run the newly added instances by using the new JVM process and register the newly added instances after the new JVM process starts and completes.

[0192] The calling unit 700 is used to call the application interface by using the newly added instances after the newly added instances are registered.

[0193] In summary, according to different JVM process modes, it is determined whether a new JVM process needs to be started for the newly added instances. According to the determination result, it is decided whether to start a new JVM process to run the newly added instances, so as to avoid all instances running in the same JVM process and ensure the normal operation of the JVM process.

[0194] Preferably, in combination with Figure 8 the content shown, the instance management device further includes: a determination unit, which is used to determine that a new JVM process needs to be started for the newly added instances when there is no shared process with an application number greater than the application number of the current process among all application numbers.

[0195] Preferably, in combination with Figure 8 the content shown, the instance management device further includes: a status judgment unit, an update unit, and a process start unit.

[0196] The status judgment unit is used to judge whether the status of the JVM process corresponding to the instance is a normal status when an instance update request is received.

[0197] The update unit is used to update the instance information of the instance in the JVM process if the status of the JVM process corresponding to the instance is a normal status.

[0198] The process start unit is used to start a new JVM process if the status of the JVM process corresponding to the instance is not a normal status.

[0199] Preferably, in combination with Figure 8 the content shown, the instance management device further includes: a mode acquisition unit, a process judgment unit, a deletion unit, and a sending unit.

[0200] The mode acquisition unit is used to acquire the process mode corresponding to the instance when an instance deletion request is received.

[0201] The process judgment unit is used to judge whether the JVM process corresponding to the instance needs to be closed according to the process mode.

[0202] The process judgment unit is specifically used for: when the process mode is a single-instance process mode, it is determined that the JVM process corresponding to the instance needs to be closed.

[0203] The process judgment unit is specifically configured to: when the process mode is the single application instance sharing process mode, delete the instance information of the instance; after the deletion of the instance information of the instance is completed, detect whether the instance is a preset instance; if the instance is a preset instance, determine that the JVM process corresponding to the instance needs to be closed; if the instance is not a preset instance, determine that the JVM process corresponding to the instance does not need to be closed.

[0204] The process judgment unit is specifically configured to: when the process mode is the multi-application instance sharing process mode, delete the instance information of the instance; after the deletion of the instance information of the instance is completed, detect whether there are other application instances in the shared process where the instance is located; if there are no other application instances in the shared process where the instance is located, determine that the JVM process corresponding to the instance needs to be closed; if there are other application instances in the shared process where the instance is located, determine that the JVM process corresponding to the instance does not need to be closed.

[0205] The deletion unit is configured to, if the JVM process corresponding to the instance needs to be closed, delete the instance information of the instance and close the JVM process corresponding to the instance.

[0206] The sending unit is configured to, if the JVM process corresponding to the instance does not need to be closed, send an instance deletion request to the JVM process so that the JVM process deletes the instance.

[0207] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts between the various embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for a system or a system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiment. The systems and system embodiments described above are merely illustrative. The units described as separate components may or may not be physically separated. The components shown as units may or may not be physical units, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without creative work.

[0208] Those skilled in the art may further realize that the units and algorithm steps of each example described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described according to functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present invention.

[0209] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for instance management based on JVM processes, characterized in that, Including: When receiving a call request for an application interface, detect whether there is an instance corresponding to the application interface; If there is no instance corresponding to the application interface, create a new instance corresponding to the application interface; Obtain the Java Virtual Machine (JVM) process mode corresponding to the application interface; Judge whether the new instance needs to start a new JVM process according to the JVM process mode; If the new instance needs to start the new JVM process, start the new JVM process; After the new JVM process is started, run the new instance using the new JVM process and register the new instance; After the new instance is registered, call the application interface using the new instance.

2. The method according to claim 1, wherein The judging whether the new instance needs to start a new JVM process according to the JVM process mode includes: When the JVM process mode is a single-instance process mode, determine that the new instance needs to start the new JVM process.

3. The method according to claim 1, characterized in that The judging whether the new instance needs to start a new JVM process according to the JVM process mode includes: When the JVM process mode is a single-application instance shared process mode, detect whether there is an instance in the application that is the same as the new instance; If there is an instance in the application that is the same as the new instance, determine that the new instance needs to start the new JVM process; If there is no instance in the application that is the same as the new instance, judge whether the state of the shared process in the application is a normal state; If the state of the shared process in the application is the normal state, determine that the new instance does not need to start the new JVM process; If the state of the shared process in the application is not the normal state, determine that the new instance needs to start the new JVM process.

4. The method according to claim 1, characterized in that The judging whether the new instance needs to start a new JVM process according to the JVM process mode includes: When the JVM process mode is a multi-application instance shared process mode, obtain the number of applications registered in each shared process; Determine the shared process with the smallest number of applications as the current process; Judge whether the number of applications in the current process is greater than a preset registration number; If the number of applications in the current process is greater than the preset registration number, determine that the new instance needs to start the new JVM process; If the number of applications in the current process is not greater than the preset registration number, obtain and calculate the sum value of the preset application setting heap and the cumulative heap of the registered applications in the current process; Judge whether the sum value is greater than a preset process threshold; If the sum value is greater than the preset process threshold, screen out the shared processes whose number of applications is greater than the number of applications in the current process and less than the number of applications in other shared processes from all the numbers of applications, and after determining them as the current process, return to execute the step of judging whether the number of applications in the current process is greater than the preset registration number; the other numbers of applications indicate the shared processes except the current process; If the sum value is not greater than the preset process threshold, judge whether the state of the current process is a normal state; If the status of the current process is not the normal status, filter out the shared processes from all the application counts that are greater than the application count of the current process and less than the application counts of other applications, and after determining it as the current process, return to execute the step of determining whether the application count of the current process is greater than the preset registration count; If the status of the current process is the normal status, determine that the new instance does not need to start a new JVM process.

5. The method according to claim 4, characterized in that Further included: When there is no shared process in all the application counts that is greater than the application count of the current process, determine that the new instance needs to start a new JVM process.

6. The method according to claim 1, characterized in that, Further included: When receiving an instance update request, determine whether the status of the JVM process corresponding to the instance is the normal status; If the status of the JVM process corresponding to the instance is the normal status, update the instance information of the instance in the JVM process; If the status of the JVM process corresponding to the instance is not the normal status, start a new JVM process.

7. The method according to claim 1, characterized in that, Further included: When receiving an instance deletion request, obtain the process mode corresponding to the instance; Judge whether it is necessary to close the JVM process corresponding to the instance according to the process mode; If it is necessary to close the JVM process corresponding to the instance, delete the instance information of the instance and close the JVM process corresponding to the instance; If it is not necessary to close the JVM process corresponding to the instance, send the instance deletion request to the JVM process so that the JVM process deletes the instance.

8. The method according to claim 7, wherein The judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes: When the process mode is the single-instance process mode, determine that it is necessary to close the JVM process corresponding to the instance.

9. The method according to claim 7, wherein The judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes: When the process mode is the single-application instance shared process mode, delete the instance information of the instance; After the instance information deletion of the instance is completed, detect whether the instance is a preset instance; If the instance is the preset instance, determine that it is necessary to close the JVM process corresponding to the instance; If the instance is not the preset instance, determine that it is not necessary to close the JVM process corresponding to the instance.

10. The method according to claim 7, characterized in that The judging whether it is necessary to close the JVM process corresponding to the instance according to the process mode includes: When the process mode is the multi-application instance shared process mode, delete the instance information of the instance; After the instance information deletion of the instance is completed, detect whether there are other application instances in the shared process where the instance is located; If there are no other application instances in the shared process where the instance is located, determine that it is necessary to close the JVM process corresponding to the instance; If there are other application instances in the shared process where the instance is located, determine that it is not necessary to close the JVM process corresponding to the instance.

11. An instance management device based on a JVM process, characterized in that, Included: A detection unit, configured to detect whether there is an instance corresponding to the application interface when receiving a call request of the application interface; A creation unit, configured to create a new instance corresponding to the application interface if an instance corresponding to the application interface does not exist; An acquisition unit, configured to acquire the Java Virtual Machine (JVM) process mode corresponding to the application interface; A judgment unit, configured to judge whether the new instance needs to start a new JVM process according to the JVM process mode; A start unit, configured to start the new JVM process if the new instance needs to start the new JVM process; An operation unit, configured to, after the new JVM process is started, run the new instance by using the new JVM process and register the new instance; A call unit, configured to, after the new instance is registered, call the application interface by using the new instance.