Service hot upgrade method and system based on cloud native platform, medium and product
By building new loader instances and dynamically loading new version program units on a cloud-native platform, the problem of interruption in traditional Java application service updates is solved, achieving seamless hot upgrades and improving release efficiency and system stability.
Patent Information
- Application Number
- CN202511570423.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-02-10
AI Technical Summary
Traditional Java application service feature updates rely on static compilation and overall release, which leads to service interruptions, long deployment cycles, high resource consumption, slow response speed, and the risk of unknown failures.
Build new loader instances on cloud-native platforms to dynamically load new version program units and achieve seamless upgrades through traffic control capabilities, avoiding service restarts. Use custom ClassLoader instances to break the parent delegation model and achieve isolation and secure loading of new and old versions.
It enables seamless hot upgrades of services, reduces service downtime, improves release efficiency, reduces resource consumption and system stability risks, and ensures business continuity and user experience.
Smart Images

Figure CN121509227A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of cloud native, and more particularly, to a service hot upgrade method based on a cloud native platform, a computer system implementing the method, and a computer readable storage medium and computer program product implementing the method. BACKGROUND
[0002] At present, cloud computing technology has become the mainstream, and cloud native architecture has become the de facto standard for building and running modern applications due to its characteristics of elastic scaling, high availability, and agile deployment. In this environment, how to quickly iterate functions and put services online to meet the needs of continuous delivery of business becomes crucial.
[0003] Currently, traditional Java application services, especially in the scenario of providing Application Programming Interface (API) services, usually rely on the mode of static compilation and overall release for function updates. Specifically, developers need to upload the modified complete application (such as Java Archive (JAR) or Web Application Archive (WAR) package) to the server, and load the new code by restarting the entire application server. This way of stopping publishing inevitably causes service interruption and affects user experience. For medium and large applications or services involving complex middleware, frequent restarts not only have long deployment cycles and require a lot of manual intervention, but also come with the risk of service interruption and unknown failures. In addition, each time a new version is deployed, the entire application needs to be reloaded, which may cause a significant increase in memory usage. If the application contains a large number of class files, the loading time will also be prolonged, thereby affecting the response speed after the system starts. Therefore, the existing technology has inherent defects such as low release efficiency, insufficient service flexibility, and high risk of system stability due to the rigidity of the update mechanism.
[0004] It should be noted that the information disclosed in the above BACKGROUND section is only used to strengthen the understanding of the background of the present disclosure, and therefore can include information that does not constitute prior art known to those of ordinary skill in the art. SUMMARY
[0005] To solve or at least alleviate one or more of the above problems, the following technical solutions are provided. Embodiments of the present disclosure provide a service hot upgrade method based on a cloud native platform, a computer system implementing the method, and a computer readable storage medium and computer program product implementing the method, which can realize non-stop, dynamic hot upgrade of services in a cloud native environment, thereby overcoming the problems of service interruption and low release efficiency caused by relying on restarting service instances in the traditional service update mode.
[0006] According to a first aspect of the present disclosure, a service hot upgrade method based on a cloud-native platform is provided, and the method comprises the following steps: in response to detecting a program unit update event for a target service, a new loader instance is constructed without restarting a service instance that carries the target service; a new version program unit corresponding to the target service is dynamically loaded in a runtime environment of the service instance by the new loader instance; and after the dynamic loading is completed, an access request for the target service is routed to service logic provided by the new version program unit by invoking a traffic control capability of the cloud-native platform.
[0007] Alternatively or additionally to the above solutions, in the service hot upgrade method according to an embodiment of the present disclosure, detecting a program unit update event for a target service comprises triggering a scanning action through a management endpoint of the service instance; by executing the scanning action, it is checked whether a new version program unit corresponding to the target service exists in a preset storage location; if it exists, it is determined that the program unit update event occurs.
[0008] Alternatively or additionally to the above solutions, in the service hot upgrade method according to an embodiment of the present disclosure, the method further comprises: querying a registry to determine whether a registered program unit corresponding to the target service exists; if it exists, comparing version identifiers of the registered program unit and the new version program unit; wherein the operation of dynamic loading is performed when the version identifiers of the registered program unit and the new version program unit are inconsistent, or the registered program unit does not exist.
[0009] Alternatively or additionally to the above solutions, in the service hot upgrade method according to an embodiment of the present disclosure, the method further comprises: after dynamically loading the new version program unit, updating the registry to establish a mapping relationship between the target service, the version identifier of the new version program unit and the new loader instance.
[0010] Alternatively or additionally to the above solutions, in the service hot upgrade method according to an embodiment of the present disclosure, the method further comprises: after performing the routing switching, performing a safe uninstallation process on a registered program unit that is an old version program unit.
[0011] Alternatively or additionally to the above solutions, in the service hot upgrade method according to an embodiment of the present disclosure, the safe uninstallation process comprises: in a case where all object instances associated with the old version program unit have been garbage collected, and a class object corresponding to the old version program unit and an old loader instance carrying the old version program unit are unreachable in a Java virtual machine, the reference to the old loader instance is removed, and the record related to the old version program unit in the registry is cleared.
[0012] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, the new loader instance dynamically loads the new version program unit corresponding to the target service in the runtime environment of the service instance through the new loader instance, which includes: the new loader instance responds to a loading request and looks up the new version program unit from a local cache maintained by itself; if the local cache is not hit, the new loader instance bypasses its parent loader and directly loads the bytecode of the new version program unit from a repository connected to the cloud native platform; and after successful loading, the loading result is cached in the local cache.
[0013] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, the new loader instance is a custom class loader instance that loads program units by breaking the parent delegation model; and / or the target service is an application programming interface service, and the cloud native platform is a Kubernetes container orchestration platform.
[0014] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, the program unit update event is triggered by an operation of creating or modifying a custom resource object in the cloud native platform.
[0015] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, the method further includes: the deployment strategy of the target service is declared in the custom resource object, and the deployment strategy includes at least one of the following: a resource allocation strategy, a gray release strategy, and a version rollback strategy.
[0016] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, routing the access request for the target service to the service logic provided by the new version program unit includes: according to the gray release strategy, routing a first part of the access request to the new version program unit, and routing a second part of the access request to an old version program unit, to implement multi-version parallel service.
[0017] As an alternative or supplement to the above solution, in the service hot upgrade method according to an embodiment of the disclosure, the method further includes: collecting runtime performance indicators related to the new version program unit; and dynamically adjusting the proportion of access requests routed to the new version program unit based on the runtime performance indicators.
[0018] As an alternative or supplement to the above solution, in a service hot upgrade method according to an embodiment of the present disclosure, based on the runtime performance indicator, dynamically adjusting the proportion of access requests routed to the new version program unit comprises: when the runtime performance indicator exceeds a preset abnormal threshold, performing a rollback operation, the rollback operation comprising: re-routing all access requests for the target service to service logic provided by an old version program unit.
[0019] According to a second aspect of the present disclosure, a computer system is provided, comprising: a memory; a processor; and a computer program stored on the memory and executable on the processor, execution of the computer program causing any one of the service hot upgrade methods according to the first aspect of the present disclosure to be performed.
[0020] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, the computer-readable storage medium comprising instructions that, when executed, perform any one of the service hot upgrade methods according to the first aspect of the present disclosure.
[0021] According to a fourth aspect of the present disclosure, a computer program product is provided, comprising a computer program that, when executed by a processor, implements any one of the service hot upgrade methods according to the first aspect of the present disclosure.
[0022] The service hot upgrade method based on the cloud-native platform according to one or more embodiments of the present disclosure helps to achieve seamless hot upgrade at the service instance level. By completing all update operations without restarting the service instance hosting the target service, the service downtime caused by service restart can be effectively reduced, thereby reducing the impact on business continuity. During this process, end users are generally unaware of the upgrade process, which helps to improve the service experience and is particularly useful for critical business scenarios that require continuous high availability.
[0023] Specifically, this solution provides a flexible and resource-efficient update mechanism by constructing a new loader instance and dynamically loading the new version program unit. The isolated loading method based on the new loader instance helps to isolate the new and old version program units in the runtime environment, thereby reducing the likelihood of system stability problems caused by class conflicts. The dynamic loading mechanism can avoid the resource overhead caused by reloading the entire application due to local code updates, which is beneficial to reducing the memory occupancy peak during the upgrade process and has a positive effect on improving the overall resource utilization efficiency of the system during the update phase. In addition, routing switching is achieved by invoking the traffic control capability of the cloud-native platform, so that the hot upgrade process can be combined with the orchestration capability of the underlying infrastructure, which helps to build an automated hot upgrade process from code loading to traffic scheduling. BRIEF DESCRIPTION OF DRAWINGS
[0024] The above and / or other aspects and advantages of the present disclosure will become more apparent by describing in detail various aspects of the present disclosure with reference to the attached drawings, in which like reference numerals refer to like elements, and wherein: Figure 1 a schematic flowchart of a service hot upgrade method 10 according to one or more embodiments of the present disclosure; Figure 2 a schematic flowchart of a service hot upgrade method 20 according to one or more embodiments of the present disclosure; and Figure 3 a schematic block diagram of a computer system 30 according to one or more embodiments of the present disclosure. DETAILED DESCRIPTION
[0025] The following detailed description is merely exemplary in nature and is not intended to limit the disclosed technology or the application and uses of the disclosed technology. Furthermore, there is no intention to be bound by any expressed or implied theory presented in the preceding technical field, background, brief summary or the following detailed description.
[0026] In the following detailed description of embodiments, numerous specific details are set forth in order to provide a more thorough understanding of the disclosed technology. However, it will be apparent to one of ordinary skill in the art having the benefit of this disclosure that the technology disclosed can be practiced without these specific details. In other instances, well-known features have not been described in detail to avoid unnecessarily complicating the description.
[0027] The terms such as "have" and "include" mean that there are not excluded the other elements (modules and steps) not directly or explicitly described in the specification and claims of the present disclosure, unless there is a clear and explicit expression of excluding the other elements (modules and steps). The terms such as "first" and "second" do not mean the order of the elements in time, space, size, etc., but are used only to distinguish the elements. Also, the steps in this document are not limited to the order of writing, but the step written later can be implemented simultaneously with the step written earlier, or before the step written earlier.
[0028] Hereinafter, various exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings.
[0029] Reference will now be made to the drawings, wherein: Figure 1 a schematic flowchart of a service hot upgrade method 10 according to one or more embodiments of the present disclosure.
[0030] It should be noted that the service hot upgrade method 10 of the present application can be executed by an application system deployed on a cloud native platform, which fully utilizes the elastic infrastructure and dynamic management capabilities provided by the cloud native platform, and aims to realize the uninterrupted update of service logic. The cloud native platform is a modern application running environment with core characteristics of containers, microservices, dynamic orchestration and continuous delivery, such as the widely used Kubernetes container orchestration platform. The platform provides key underlying support for the service hot upgrade method 10 of the present application, including but not limited to: encapsulating service instances as containers that can be independently deployed and expanded, implementing fine-grained traffic control through a service mesh or an ingress controller, and extending the management interface of the platform through custom resource definitions, so that the application running thereon can achieve high-level automation and flexibility.
[0031] As shown in Figure 1 The service hot upgrade method 10 starts from step 101, that is, in response to detecting a program unit update event for a target service, a new loader instance is constructed without restarting the service instance carrying the target service.
[0032] Step 101 is the triggering link of the entire hot upgrade process, and its core purpose is to create an isolated and controllable code execution environment for subsequent dynamic loading, which is a key technical cornerstone for implementing logic update without interruption. By constructing a loader instance independent of the original class path, the new and old versions of the program unit can be effectively isolated, avoiding runtime exceptions caused by class name and method signature conflicts, and providing a basic guarantee for safe and parallel multi-version coexistence.
[0033] In the context of the present disclosure, "program unit" refers to the smallest updateable code module that constitutes the service business logic, usually manifested as a Java class file or its packaged JAR (Java Archive) file that implements a specific interface. "Program unit update event" refers to the signal that triggers the hot upgrade process, and its generation mechanism can be diverse, including but not limited to external calls, scheduled tasks or platform events. "Service instance" refers to an independent process that carries and runs the target service, which is usually encapsulated as a container in a cloud native environment. "Loader instance" specifically refers to a custom ClassLoader object, which is a core component in the Java Virtual Machine (JVM) responsible for loading class bytecodes.
[0034] For the detection of program unit update events, a typical and reliable implementation is to trigger a scanning action through the management endpoint of the service instance. Specifically, the service instance can integrate a framework like Spring Boot Actuator, which exposes an HTTP endpoint dedicated for the management of hot upgrade. When the scanning action is triggered by the operation personnel through the invocation of this endpoint, the service instance will perform predefined checking logic, access a pre-configured storage location (e.g. a network file system or an object storage service in a cloud-native environment), and check whether there exists a version-updated program unit file corresponding to the current target service in this location. The system can determine whether there exists a new version by comparing file hash values, version numbers, or last modification times, etc. If the result of the check is positive, it is determined that a program unit update event has occurred, and the subsequent process of building a loader instance is started.
[0035] Optionally, the above-mentioned scanning action triggered through the management endpoint can be indirectly triggered by an operation of creating or modifying a custom resource object in the cloud-native platform. In this mode, instead of directly invoking the management endpoint of the service instance, a custom resource can be declared or modified through the Kubernetes API. Illustratively, a custom controller deployed in the cluster listens to the changes of this resource and initiates a call to the management endpoint of the target service instance, thereby indirectly triggering the scanning and updating events.
[0036] Further, in this embodiment driven by custom resources, the deployment strategies of the target service can be declared within the custom resource object. These strategies provide high-level guidance and control for the entire hot upgrade process, which can include but are not limited to: resource allocation strategies, i.e. specifying CPU, memory, etc. resource quotas for the new version service logic; gray release strategies for controlling the proportion and rhythm of traffic splitting; and version rollback strategies defining automatic fallback to the old version when certain monitoring indicators are abnormal. These strategy information can be passed to the service instance by the controller, or actively queried by the service instance in subsequent steps, thereby guiding the intelligent execution of the entire hot upgrade process.
[0037] Once the update event is confirmed, the system immediately starts to build a new customized loader instance. The key design of this customized loader instance is that it breaks the Java default parent delegation model. In the traditional parent delegation model, class loading requests are preferentially delegated to parent loaders, which guarantees the security of core class libraries, but also leads to the inability to load classes with the same name as the parent loader path. The customized loader instance in this embodiment can change this behavior by rewriting the loadClass method, so that when loading classes in the target program unit, it preferentially attempts to load from the specified update source, thereby ensuring that the new version of the class can be loaded instead of the old version loaded by the parent loader. This newly built loader instance with an independent class namespace prepares for the safe loading and running of the new version of the service logic.
[0038] After successfully building the new loader instance, the service hot upgrade method 10 enters step 103: dynamically loading the new version of the program unit corresponding to the target service in the runtime environment of the service instance through the new loader instance.
[0039] This step is the core execution link of the entire hot upgrade process, and its purpose is to use the independent class loading environment prepared in the previous step to convert the bytecodes of the new version of the program unit (such as a JAR package or a Class file) into a java.lang.Class object that can be directly executed in the runtime, and define it in the JVM of the current service instance. The dynamic loading here specifically refers to the process of introducing new class definitions into the runtime environment while the target service is running. This process is completely completed dynamically at runtime, without the need to stop the application server, thereby ensuring the continuity and high availability of the target service business logic. Through this step, the new service logic is already ready in memory, laying a solid foundation for seamlessly taking over production traffic later.
[0040] At the specific implementation level, the dynamic loading process can be implemented through multiple technical paths to adapt to different operation and maintenance scenarios and technical requirements.
[0041] In a basic embodiment, dynamic loading can use the standard class loading process. The new loader instance can locate the bytecode file according to the storage path of the program unit, and sequentially perform bytecode acquisition in the loading phase, verification, preparation, resolution in the linking phase, and static assignment in the initialization phase.
[0042] In another embodiment, the loading process loader instance first looks up from a local cache it maintains itself to see if there is a new version of the program unit. This cache is used to boost loading performance in frequent update scenarios. If there is no cache hit, the new loader instance bypasses its parent loader and directly downloads or reads the bytecode of the new version of the program unit from a remote repository connected to the cloud-native platform, such as an HTTP-based file server, a Maven repository, or an object storage service. After successfully loading remotely, the loader can perform the standard class loading process, including bytecode verification, memory allocation and initialization for static variables, and finally cache the generated Class object locally for later use. This cache-first, remote-fallback mechanism balances loading efficiency and flexibility in obtaining the latest code.
[0043] Optionally, in another embodiment, to ensure the accuracy and necessity of dynamic loading, before performing the loading operation through the new loader instance, an internal or external registry can be queried to determine whether there is a registered program unit corresponding to the target service. If there is, the system can compare the version identifier (e.g., a string based on semantic version number or a hash value of file content) of the registered program unit and the new version of the program unit. The above dynamic loading operation can only be performed when the version identifiers are inconsistent or the registered program unit does not exist. This pre-version arbitration mechanism effectively prevents the repeated loading of the same version and avoids unnecessary resource overhead and potential class loader redundancy.
[0044] Further, the loader instance in this application is designed as a custom class loader that breaks the parent delegation model. When implementing the loadClass method, it will first try to load the class in the target program unit from the specified update source path. This design ensures that the classes in the new version of the program unit can be loaded correctly without causing loading failure or conflict due to the parent loader having loaded the same old version class, which is the key to achieving precise version coverage.
[0045] After successfully completing the dynamic loading of the new version of the program unit, the method enters the final implementation stage, step 105: After completing the dynamic loading, the access request for the target service is routed to the service logic provided by the new version of the program unit by calling the traffic control capability of the cloud-native platform.
[0046] The technical effect of this step is to formally put the new version of the logic that has been ready into production environment to handle business traffic. By using the fine traffic management API provided by the cloud-native platform, the system can achieve smooth and controllable traffic migration from the old version to the new version of the service, thereby maintaining the continuity and high availability of the service during the whole process of business logic update.
[0047] Optionally, in one embodiment, in order to formally incorporate the new version service loaded ready in step 103 into the traffic system, the registry mentioned above can be updated. This update operation aims to establish or replace a mapping relationship that can take the unique identifier of the target service as the primary key, and bind it with the version identifier of the new version program unit and the reference information of the new loader instance that carries it. This update action marks the completion of the online registration of the new version service in the system internal state, enabling the service discovery and routing components to perceive and subsequently distribute traffic to this new version instance.
[0048] Optionally, in another embodiment, the system can also contain a cleaning mechanism for the old version resource to maintain the cleanliness of the runtime environment and prevent memory leakage. Specifically, after performing the routing switch, a safe uninstallation process can be performed on the registered program unit that is the old version program unit. The core of this process is to ensure that the old version class and its loader can be safely garbage collected by the Java virtual machine.
[0049] Illustratively, the safe uninstallation process can specifically include the following steps. First, it must be confirmed that all new service requests are directed to the new version through the routing rules, and there are no business threads in the service instance that still hold references to any class instances in the old version. Then, it is necessary to strictly verify whether the following two prerequisites are met at the same time: first, through the JVM garbage collection mechanism, it is confirmed that all object instances associated with the old version program unit have been recycled; second, through the reachability analysis algorithm, it is confirmed that the Class object corresponding to the old version program unit and the old loader instance carrying it are unreachable in the reference chain of the JVM. Only after the above conditions are met, the system will perform the final cleaning operation: first, all strong references to the old loader instance inside the service instance are explicitly released; then, the historical records related to the old version program unit in the registry are cleared. At this point, the old class loader and all the classes it loads become completely garbage objects and will be completely cleared in the next garbage collection of the JVM, thus releasing the memory resources such as Metaspace occupied by them.
[0050] Optionally, in an embodiment supporting gray release, according to the gray release policy predefined in the custom resource, the first part of access requests can be routed to the new version program unit, while the second part of access requests continue to be routed to the old version program unit. For example, by writing a gray release rule, a proportion-based traffic split (such as 90% of the traffic to the old version and 10% to the new version) or accurate user diversion based on request headers (such as a specific field containing userId) can be achieved. This capability of parallel service of multiple versions enables the new version to be verified in a small range of users in a real environment, greatly reducing the business risks that may be brought by direct full release.
[0051] Optionally, in an embodiment implementing gray release, a closed-loop monitoring and feedback adjustment mechanism can also be included. Specifically, after traffic is routed to the new version program unit according to the gray release strategy, and multi-version parallel service is implemented, runtime performance indicators related to the new version program unit can be continuously collected. These indicators are usually collected by the monitoring system deployed on the cloud native platform, and can include but are not limited to: the query rate per second of service requests, average response delay, error rate, and key metrics such as memory occupation and garbage collection frequency at the JVM level. Further, based on these real-time collected runtime performance indicators, the proportion of access requests routed to the new version program unit can be dynamically adjusted, for example: when the average delay of the new version service is stable within 110% of the old version and the error rate is less than 0.1%, the proportion of imported traffic is increased by 10% every 15 minutes. Conversely, when the runtime performance indicators exceed the preset abnormal threshold, such as when the error rate of the new version service suddenly rises above the preset abnormal threshold (such as 5%), protective operations can be performed, such as reducing the traffic proportion from the current 30% to 0 within 1 minute, i.e. performing a rollback operation, and all access requests for the target service are re-routed to the service logic provided by the old version program unit. This dynamic regulation based on real-time feedback enables the release process of the new version to have self-healing capability, maximizing the release efficiency while minimizing the potential impact on system stability.
[0052] The service hot upgrade method 10 according to one or more embodiments of the present application, by integrating cloud native infrastructure and JVM-level dynamic code loading technology, achieves a series of technical effects that traditional deployment methods cannot achieve. The core value lies in providing unprecedented flexibility and reliability guarantee for modern microservice architecture.
[0053] First, the service hot upgrade method 10 according to one or more embodiments of the present application realizes dynamic service update and version management. By combining the rolling update coordination capability of Kubernetes and the hot replacement mechanism of custom ClassLoader, this method supports seamless updating of API service business logic, dependent libraries or configuration files. This means that developers can continuously deliver new features or fix defects without interrupting existing services. When the updated version has problems, the system can quickly roll back to the previous stable version using the version management capabilities of the cloud native platform, which significantly improves the maintainability of the system and the reliability of the release process, effectively avoiding the risk of business interruption caused by version defects.
[0054] Secondly, the service hot upgrade method 10 according to one or more embodiments of the present application realizes fine-grained multi-version parallel and gray release. With the help of the label selector of Kubernetes, the traffic splitting rule of the service mesh, and the class isolation capability provided by the ClassLoader, the new and old versions of the service can safely coexist in the same runtime environment. This enables the operation and maintenance personnel to accurately deploy the new version of the service to a small number of users for real environment testing, and gradually expand the traffic proportion according to the preset strategy or real-time monitoring indicators. This controllable release process greatly reduces the potential risks brought by the online of new functions or major changes, while improving the experience of end users.
[0055] Finally, the service hot upgrade method 10 according to one or more embodiments of the present application supports highly customizable service deployment. By integrating the Kubernetes Operator mode, custom resource definition, and flexible loading mechanism of the ClassLoader, the method allows the deployment strategy of the API service to be customized according to specific business needs, performance requirements, or security specifications. Whether it is resource allocation, health check strategy, or complex canary release rules, they can all be managed through declarative configuration. This scalability gives the system great flexibility, enabling it to adapt to various complex scenarios from development testing to large-scale production.
[0056] In summary, the service hot upgrade method 10 according to one or more embodiments of the present application successfully solves the core pain points of service interruption, low efficiency, and high risk in traditional release modes by deeply combining the operation and maintenance automation capabilities of cloud-native platforms with the runtime flexibility of the JVM layer, providing a solid technical foundation for the continuous delivery, rapid iteration, and stable operation of cloud-native services.
[0057] The following continues to refer to Figure 2 , Figure 2 for the service hot upgrade method 20 according to one or more embodiments of the present application.
[0058] The scanning of the preset storage location can be triggered through the management endpoint (such as Spring Boot Actuator) of the service instance to detect whether there is a new version of the program unit corresponding to the target service in step 201.
[0059] In step 203, in response to detecting the new version of the program unit, the dynamic loading phase is entered. That is, first, a new loader instance is constructed, through which the new version of the program unit is loaded and the bytecode is parsed and verified.
[0060] In step 205, the service registry is queried to determine whether there is registration information of the program unit.
[0061] If the registration information already exists, indicating that the old version program unit is currently running, a safe uninstallation procedure needs to be performed first. This systematic uninstallation process is based on precondition checking, i.e. in step 207, it is confirmed that all object instances associated with the old version program unit have been garbage collected, and that the Class object and corresponding class loader are both unreachable in the Java virtual machine. After the conditions are met, in step 209, the uninstallation of the old version program unit is triggered through the management endpoint.
[0062] Regardless of whether there is an old version before, the system will complete the registration of the new version program unit through the management endpoint, so as to realize the dynamic update of the API service (step 211).
[0063] Figure 3 A schematic block diagram of a computer system 30 according to one or more embodiments of the present disclosure is shown. As shown, the computer system 30 includes a memory 310, a processor 320, and a computer program 330 stored on the memory 310 and executable on the processor 320, the execution of the computer program 330 causing the method 10 or 20 as shown in Figure 3 or Figure 1 to be performed. Figure 2
[0064] In addition, as described above, the present disclosure can also be implemented as a computer readable storage medium, in which a program for causing a computer to execute the method 10 or 20 as shown in Figure 1 or Figure 2 is stored. Here, as a computer storage medium, various modes of computer storage media such as a disk class (e.g. a magnetic disk, an optical disk, etc.), a card class (e.g. a memory card, an optical card, etc.), a semiconductor memory class (e.g. a ROM, a non-volatile memory, etc.), a tape class (e.g. a magnetic tape, a cassette tape, etc.), etc. can be used.
[0065] The present disclosure can also be implemented as a computer program product including a computer program which, when executed by a processor, implements the program of any of the above methods 10 or 20.
[0066] In applicable cases, various embodiments provided by the present disclosure can be implemented using hardware, software, or a combination of hardware and software. Also, in applicable cases, various hardware components and / or software components set forth herein can be combined into a composite component including software, hardware, and / or both without departing from the scope of the present disclosure. In applicable cases, various hardware components and / or software components set forth herein can be divided into sub-components including software, hardware, or both without departing from the scope of the present disclosure. In addition, in applicable cases, it is contemplated that a software component can be implemented as a hardware component, and vice versa.
[0067] Software (such as program code and / or data) according to the present disclosure can be stored on one or more computer storage media. It is also contemplated that software identified herein can be implemented using one or more general purpose or special purpose computers and / or computer systems, networked and / or otherwise. Where applicable, the order of the blocks can be changed, combined into composite blocks and / or separated into sub- blocks to provide for code efficiency, for compliance with rules and / or for readabi lity. Where applicable, the individual steps of various methods can be combined and / or separated into several steps to provide for code efficiency, for compliance with rules and / or for readabi lity.
[0068] The embodiments and examples set forth herein are presented to best explain the embodiments of the present disclosure and its specific application to provide those skilled in the art with a complete disclosure and description of how to make and use the present disclosure. However, those skilled in the art will appreciate that the above description and examples are provided for illustrative purposes only. The descriptions presented herein are not intended to be exhaustive or to limit the disclosure to the precise forms disclosed.
Claims
1. A service hot upgrade method based on a cloud-native platform, characterized in that, The method includes the following steps: In response to the detection of a program unit update event for the target service, a new loader instance is constructed without restarting the service instance hosting the target service; The new loader instance dynamically loads the new version of the program unit corresponding to the target service within the runtime environment of the service instance; and After dynamic loading is completed, the access request for the target service is routed to the service logic provided by the new version program unit by invoking the traffic control capability of the cloud-native platform.
2. The method according to claim 1, characterized in that, Detected program unit update events for the target service include: The scan action is triggered through the management endpoint of the service instance; By performing the scanning action, it is checked whether a new version program unit corresponding to the target service exists in the preset storage location; If it exists, then the program unit update event is determined to have occurred.
3. The method according to claim 1, characterized in that, The method further includes: The registry is queried to determine whether a registered program unit corresponding to the target service exists; If they exist, compare the version identifiers of the registered program unit and the new version program unit; The dynamic loading operation is performed when the version identifiers of the registered program unit and the new version program unit are inconsistent, or when the registered program unit does not exist.
4. The method according to claim 3, characterized in that, The method further includes: After the new version of the program unit is dynamically loaded, the registry is updated to establish a mapping relationship between the target service, the version identifier of the new version of the program unit, and the new loader instance.
5. The method according to claim 3, characterized in that, The method further includes: After the route switch is performed, a safe unloading process is performed on the registered program units that are old version program units.
6. The method according to claim 5, characterized in that, The secure uninstallation process includes: If it is determined that all object instances associated with the old version program unit have been garbage collected, and the class object corresponding to the old version program unit and the old loader instance carrying the old version program unit are unreachable in the Java Virtual Machine, the reference to the old loader instance is released, and the records related to the old version program unit in the registry are cleared.
7. The method according to claim 1, characterized in that, Using the new loader instance, dynamically loading the new version of the program unit corresponding to the target service in the runtime environment of the service instance includes: In response to the load request, the new loader instance looks up the new version of the program unit from its own locally maintained cache; If a local cache miss occurs, the new loader instance bypasses its parent loader and loads the bytecode of the new version of the program unit directly from the repository connected to the cloud-native platform; and After successful loading, the loading result is cached in the local cache.
8. The method according to claim 1, characterized in that, The new class loader instance is a custom class loader instance that loads program units by breaking the parent delegation model; and / or The target service is an application programming interface service, and the cloud-native platform is a Kubernetes container orchestration platform.
9. The method according to claim 1, characterized in that, The program unit update event is triggered by operations that create or modify custom resource objects in the cloud-native platform.
10. The method according to claim 9, characterized in that, The custom resource object declares the deployment strategy of the target service, and the deployment strategy includes at least one of the following: resource allocation strategy, canary release strategy, and version rollback strategy.
11. The method according to claim 10, characterized in that, The logic for routing access requests to the target service to the service provided by the new version program unit includes: According to the canary release strategy, the first part of the access requests are routed to the new version program unit, while the second part of the access requests are routed to the old version program unit, so as to realize multi-version parallel service.
12. The method according to claim 11, characterized in that, The method further includes: Collect runtime performance metrics related to the new version of the program unit; Based on the runtime performance metrics, the proportion of access requests routed to the new version of the program unit is dynamically adjusted.
13. The method according to claim 12, characterized in that, Based on the aforementioned runtime performance metrics, dynamically adjusting the proportion of access requests routed to the new version of the program unit includes: When the runtime performance metric exceeds a preset abnormal threshold, a rollback operation is performed. The rollback operation includes rerouting all access requests for the target service to the service logic provided by the old version program unit.
14. A computer system, characterized in that, Include: Memory; processor; as well as A computer program stored in the memory and executable on the processor, the execution of which causes the method according to any one of claims 1-13 to be performed.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed, perform the method according to any one of claims 1-13.
16. A computer program product comprising a computer program that, when executed by a processor, implements the method according to any one of claims 1-13.
