Blue-green deployment method and device, electronic equipment and computer readable storage medium

By using dynamic caching configuration of the reverse proxy module and the interceptor module, the flexibility and performance issues of blue-green deployment solutions are resolved, enabling efficient blue-green switching at any time and low-cost operation and maintenance.

CN120973383APending Publication Date: 2025-11-18BEIJING JINGDONG YUANSHENG TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410616444.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-17
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

Existing blue-green deployment solutions require switching at fixed times, which affects flexibility. In high-concurrency scenarios, they can lead to reduced service performance and are also complex and costly to maintain.

Method used

It employs a reverse proxy module and an interceptor module, dynamically configures whitelists and service groups through the first cache of multiple worker processes, and uses Lua scripts to dynamically update whitelists and service groups, supporting blue-green deployment at any time and avoiding shared memory contention in high-concurrency scenarios.

Benefits of technology

It improves the flexibility of blue-green deployment, avoids performance issues, supports switching at any time, reduces operation and maintenance costs, and ensures service performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973383A_ABST
    Figure CN120973383A_ABST
Patent Text Reader

Abstract

The invention provides a blue-green deployment method and device, electronic equipment and a computer readable storage medium, and relates to the technical field of computers, the blue-green deployment method and device are applied to a blue-green deployment system, the blue-green deployment system comprises a reverse proxy module and an interceptor module, the reverse proxy module comprises a plurality of working processes, each working process has a respective first cache, and the interceptor module comprises a second cache. The first cache comprises a white list, an initial service group and a target service group, and the service in the target service group is an updated version of the service in the initial service group. The method comprises the steps that in response to an operation of updating a first cache, a reverse proxy module is utilized to execute a preset script to obtain update information and synchronize the update information to the first cache corresponding to each working process, and the update information comprises white list update information or exchange information of an initial service group and a target service group; and executing a blue-green deployment process based on the update information in the first cache corresponding to each working process through the interceptor module. The flexibility of blue-green deployment can be improved, and the service performance is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer technology, and more specifically to a blue-green deployment method, blue-green deployment device, electronic device, and computer-readable storage medium. Background Technology

[0002] Blue-green deployment is a technique that reduces risk and downtime by running two identical environments. Two versions exist simultaneously in the production environment: a "blue environment" and a "green environment," with only one environment being the active environment, serving all production traffic.

[0003] Currently, blue-green deployment solutions require switching between blue-green deployments at fixed times, such as late at night when user traffic is low. This affects the flexibility of blue-green deployment to some extent. In high-concurrency scenarios, there is a problem of reduced service performance due to contention for shared memory.

[0004] It should be noted that the information in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0005] The purpose of this disclosure is to provide a blue-green deployment method, blue-green deployment apparatus, electronic device, and computer-readable storage medium, thereby improving the flexibility of blue-green deployment and ensuring service performance to at least some extent.

[0006] According to a first aspect of this disclosure, a blue-green deployment method is provided, applied to a blue-green deployment system. The blue-green deployment system includes a reverse proxy module and an interceptor module. The reverse proxy module includes multiple worker processes, each worker process having its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. The services in the target service group are updated versions of the services in the initial service group. The whitelist is used to indicate user traffic directed to the target service group. The method includes: in response to an operation to update the first cache, using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the worker processes. The update information includes whitelist update information or exchange information between the initial service group and the target service group. The interceptor module performs a blue-green deployment process based on the update information in the first cache corresponding to each of the worker processes.

[0007] In an exemplary embodiment, the blue-green deployment system further includes a persistent second cache. Before the operation of updating the first cache is performed by executing a preset script using the reverse proxy module to obtain update information and synchronize it to the first cache corresponding to each of the worker processes, the method further includes: initializing the first cache based on the second cache so that the first cache obtains the whitelist, initial service group, and target service group.

[0008] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes further includes: synchronizing the update information to the second cache for data persistence.

[0009] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes includes: if the operation of updating the first cache is an operation of updating the whitelist, then executing a preset script through the reverse proxy module to obtain whitelist update information; broadcasting the whitelist update information to synchronize the whitelist update information to the first cache corresponding to each of the worker processes.

[0010] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes includes: if the operation of updating the first cache is a blue-green switching operation, then exchanging the services in the initial service group with the services in the target service group, and obtaining the exchange information between the initial service group and the target service group by executing a preset script using the reverse proxy module; broadcasting the exchange information to synchronize the exchange information to the first cache corresponding to each of the worker processes.

[0011] In an exemplary embodiment, the initial service group includes multiple initial services, and the target service group includes a target service corresponding to each of the initial services. The initial service and the target service corresponding to the initial service have the same identification information. If the operation of updating the first cache is a blue-green switching operation, the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module. This includes: obtaining the target identification information of the blue-green switching operation, the target identification information being used to indicate the service that needs to undergo a blue-green switching operation; based on the target identification information, exchanging the initial service corresponding to the target identification information in the initial service group with the corresponding target service in the target service group, and obtaining the exchange information by executing a preset script through the reverse proxy module.

[0012] In one exemplary embodiment, the initial service group includes a front-end initial service and a back-end initial service, and the target service group includes a front-end target service corresponding to the front-end initial service and a back-end target service corresponding to the back-end initial service.

[0013] In one exemplary embodiment, the preset script is a Lua script.

[0014] According to a second aspect of this disclosure, a blue-green deployment device is provided, applied to a blue-green deployment system. The blue-green deployment system includes a reverse proxy module and an interceptor module. The reverse proxy module includes multiple worker processes, each worker process having its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. The services in the target service group are updated versions of the services in the initial service group. The whitelist is used to indicate user traffic directed to the target service group. The device includes: an information update module, used to, in response to an operation of updating the first cache, use the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each worker process. The update information includes whitelist update information or exchange information between the initial service group and the target service group; and a blue-green deployment module, used to execute a blue-green deployment process based on the update information in the first cache corresponding to each worker process through the interceptor module.

[0015] According to a third aspect of this disclosure, an electronic device is provided, comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to implement the above-described method by executing the executable instructions.

[0016] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided that stores a computer program thereon, which, when executed by a processor, implements the method described above.

[0017] The blue-green deployment method provided in this disclosure has two advantages. Firstly, when an operation to update the first cache occurs (i.e., when updating the whitelist or switching the initial and target service groups), a preset script can be executed through the reverse proxy module to obtain update information. This update information is then synchronized to the first cache corresponding to each worker process, enabling the interceptor module to perform the blue-green deployment process based on the update information in the first cache of each worker process. This process dynamically configures the first cache corresponding to each worker process based on the update operation, ensuring that the update takes effect quickly and avoiding performance issues caused by updating the whitelist or switching the initial and target workgroups. This allows for production deployment and switching of blue-green branches (switching the initial and target workgroups) at any time, providing greater flexibility for blue-green deployment. Secondly, even in high-concurrency scenarios, because the first cache of each worker process can be dynamically updated, the interceptor module performs the blue-green deployment process based on the update information in the first cache of each worker process. This avoids different worker processes competing for shared memory, ensuring service performance during blue-green deployment.

[0018] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0019] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0020] Figure 1 The schematic diagram illustrates an architecture diagram of a blue-green deployment system in an exemplary embodiment of this disclosure.

[0021] Figure 2 The flowchart illustrating an exemplary embodiment of the present disclosure is shown.

[0022] Figure 3 This illustration schematically depicts a blue-green switching operation in an exemplary embodiment of the present disclosure.

[0023] Figure 4 The flowchart illustrates an implementation of dynamically updating a first cache in an exemplary embodiment of this disclosure.

[0024] Figure 5 The diagram illustrates a model of dynamically configuring a first cache in an exemplary embodiment of the present disclosure.

[0025] Figure 6 The flowchart schematically illustrates another implementation of dynamically configuring the first cache in an exemplary embodiment of this disclosure.

[0026] Figure 7 The flowchart schematically illustrates another implementation of dynamically configuring the first cache in an exemplary embodiment of this disclosure.

[0027] Figure 8 The schematic diagram illustrates a complete flowchart of a blue-green deployment in an exemplary embodiment of this disclosure.

[0028] Figure 9 This schematically illustrates the composition of a blue-green deployment device according to an exemplary embodiment of the present disclosure.

[0029] Figure 10 This schematic diagram illustrates the composition of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation

[0030] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, they are provided so that this disclosure will be more comprehensive and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art. The described features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0031] Furthermore, the accompanying drawings are merely illustrative of this disclosure and are not necessarily drawn to scale. The same reference numerals in the drawings denote the same or similar parts, and therefore repeated descriptions of them will be omitted. Some block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities may be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0032] First, the terms or concepts involved in the embodiments of this disclosure will be introduced.

[0033] Blue-green deployment: A technique to reduce risk and downtime by running two identical environments. Two versions exist simultaneously in the production environment: a "blue environment" and a "green environment," with only one environment being the active environment, serving all production traffic.

[0034] Nginx: A high-performance HTTP and reverse proxy web server.

[0035] Lua: Written in standard C, it boasts a concise yet powerful set of features and an easy-to-use C API (Application Programming Interface), allowing it to be compiled and run on virtually all operating systems and platforms. Lua scripts are easily called by C / C++ code and can also call C / C++ functions, making them easy to embed or extend to other languages.

[0036] ngx_lua is a module of Nginx that embeds Lua into Nginx. You can use Lua to write scripts and deploy them to Nginx to run. In other words, Nginx becomes a web container, allowing developers to use the Lua language to develop high-performance web applications.

[0037] Lua VM: The Lua virtual machine, whose basic function is to parse and execute Lua script code.

[0038] Lua coroutines: Similar to threads, they have their own stack, local variables, and instruction pointer, and can share global variables with other coroutines.

[0039] Initial service group: The group to which older versions of the service were deployed.

[0040] Target service group: The group to which the new version of the service will be deployed. All services in this service group are updated versions of the services in the initial service group.

[0041] Whitelist: Traffic from users on the whitelist will be directed to the target service group, which can be configured by the developers.

[0042] Blue-green deployment schemes in related technologies require switching between blue-green deployments at fixed times, such as late at night when user traffic is low, which affects the flexibility of blue-green deployment to some extent. In high-concurrency scenarios, there is a problem of reduced service performance due to shared memory.

[0043] Furthermore, most current blue-green deployment solutions rely on other complex services, resulting in high complexity and operational costs. For front-end and back-end blue-green deployments, two separate blue-green deployment solutions are often required, leading to long development cycles, high costs, and high complexity.

[0044] In view of the above-mentioned problems, current blue-green deployment solutions suffer from poor flexibility, impact on service performance, and high complexity. This disclosure provides a blue-green deployment method. The blue-green deployment system includes a reverse proxy module and an interceptor module. The reverse interceptor module includes multiple worker processes, each with its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. The services in the target service group are updated versions of the services in the initial service group. The whitelist is used to indicate user traffic directed to the target service group. Therefore, during blue-green deployment, if an operation to update the first cache occurs—that is, an operation to update the whitelist or exchange the initial and target service groups—the reverse proxy module can execute a preset script to obtain the update information and synchronize it to the first cache corresponding to each worker process. This allows the interceptor module to perform the blue-green deployment process based on the update information in the first cache corresponding to each worker process. This process dynamically configures the first cache corresponding to each worker process based on update operations, enabling rapid updates to the first cache and avoiding service performance issues caused by updating the whitelist or switching the initial and target workgroups. This allows for production deployment and switching of blue-green branches (switching the initial and target workgroups) at any time, providing greater flexibility for blue-green deployments. Furthermore, even in high-concurrency scenarios, the dynamic updating of the first cache of each worker process allows the interceptor module to execute the blue-green deployment process based on the updated information in each worker process's first cache, avoiding competition for shared memory between different worker processes and ensuring service performance during blue-green deployments.

[0045] The architecture diagram of the blue-green deployment system of this disclosure embodiment can be found in [reference]. Figure 1 As shown, it includes a reverse proxy module 11 and an interceptor module 12. The reverse proxy module 11 includes multiple worker processes 13, each worker process 13 has its own corresponding first cache 14, which stores information on whitelists, initial service groups and target service groups.

[0046] Each user request is processed by a Lua coroutine within the worker process. After processing the user request, the interceptor module 12 redirects different user requests to the corresponding services based on the whitelist, initial service group, and target service group stored in the first cache 14 corresponding to the worker process. Within each worker process, the first cache can be a virtual machine cache, such as the Lua VM cache.

[0047] In this embodiment of the disclosure, when it is necessary to update the whitelist or switch the blue-green version (i.e., exchange services in the initial service group and the target service group), the update information can be dynamically configured into the first cache corresponding to each working process through the reverse proxy module to achieve millisecond-level updates and avoid affecting service performance.

[0048] Furthermore, a persistent second cache can be included in the blue-green deployment system to persistently store the data required during the blue-green deployment process. This allows for the retrieval of persistent data from the second cache in case of errors in the first cache, ensuring service performance. The second cache can be Redis (Remote Dictionary Server), but other caches can be chosen based on actual needs; no specific restrictions are imposed.

[0049] The technical methods of the embodiments of this disclosure are described below with reference to specific examples. These specific examples can be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The blue-green deployment method of the embodiments of this disclosure is described below with reference to the accompanying drawings.

[0050] Figure 2 A flowchart of a blue-green deployment method according to an exemplary embodiment of the present disclosure is shown, such as... Figure 2 The blue-green deployment method of this disclosure embodiment may include steps S210 and S220:

[0051] In step S210, in response to the operation of updating the first cache, the reverse proxy module executes a preset script to obtain update information and synchronizes it to the first cache corresponding to each working process. The update information includes whitelist update information or exchange information between the initial service group and the target service group.

[0052] In an exemplary embodiment of this disclosure, the operation of updating the first cache includes updating the whitelist and a blue-green switching operation, which will cause changes to the information in the first cache. The whitelist update operation can adjust user traffic redirected to the target service group, and the blue-green switching operation switches the services in the initial service group with the services in the target service group, such as... Figure 3 As shown, the application services in the initial service group (blue group) and the target service group (green group) switch to each other through the blue-green switching operation.

[0053] The default script can be a Lua script. The reverse proxy module obtains the update information corresponding to the update operation by implementing the default script and synchronizes the update information to the first cache of each worker process. The update information is global information, which can be referenced by all objects or functions in the blue-green deployment system. By synchronizing the update information to the first cache of each worker process, the blue-green deployment process can be performed using the most recent whitelist or initial service group and target service group when processing user requests.

[0054] In step S220, the blue-green deployment process is executed by the interceptor module based on the update information in the first cache corresponding to each worker process.

[0055] In an exemplary embodiment of this disclosure, the interceptor module is used to redirect user requests corresponding to a worker process to the corresponding initial service group or target service group based on the first cache.

[0056] Specifically, if a user request in the worker process is not a whitelisted request, the interceptor module redirects the service request to a service in the initial service group. Conversely, if a user request in the worker process is a whitelisted request, the interceptor module redirects the service request to a service in the target service group, thereby achieving user traffic distribution.

[0057] The blue-green deployment method provided in this disclosure has two advantages. Firstly, when an operation to update the first cache occurs (i.e., when updating the whitelist or switching the initial and target service groups), a preset script can be executed through the reverse proxy module to obtain update information. This update information is then synchronized to the first cache corresponding to each worker process, enabling the interceptor module to perform the blue-green deployment process based on the update information in the first cache of each worker process. This process dynamically configures the first cache corresponding to each worker process based on the update operation, ensuring that the update takes effect quickly and avoiding performance issues caused by updating the whitelist or switching the initial and target workgroups. This allows for production deployment and switching of blue-green branches (switching the initial and target workgroups) at any time, providing greater flexibility for blue-green deployment. Secondly, even in high-concurrency scenarios, because the first cache of each worker process can be dynamically updated, the interceptor module performs the blue-green deployment process based on the update information in the first cache of each worker process. This avoids different worker processes competing for shared memory, ensuring service performance during blue-green deployment.

[0058] The following provides a more detailed explanation of steps S210 and S220.

[0059] In one exemplary embodiment, an implementation method for initializing a first cache is provided. The blue-green deployment system may include a persistent second cache. Based on this, before executing a preset script using a reverse proxy module to obtain update information and synchronize it to the first cache corresponding to each worker process in response to an operation updating the first cache, the method may further include:

[0060] The first cache is initialized based on the second cache so that the first cache obtains the whitelist, initial service group, and target service group.

[0061] The second cache serves as persistent storage and includes a pre-configured whitelist, as well as information on the initial and target service groups. During the cold start phase, when the Nginx service starts, it can load the second cache and initialize the first cache using it. This ensures that the whitelist, initial service group, and target service group in the first cache are consistent with those in the second cache, facilitating subsequent blue-green deployment.

[0062] This embodiment of the disclosure updates the whitelist, initial service group, and target service group in persistent storage to the first cache during the cold start phase. This can avoid storing too much information in the first cache, improve system performance, and ensure the accuracy of the information in the first cache by initializing the first cache, so as to guarantee the accuracy of the subsequent blue-green deployment process.

[0063] Based on the foregoing embodiments, a method for synchronously updating the second cache is also provided. Step S210, in response to the operation of updating the first cache, further includes using a reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each working process, and may also include:

[0064] The updated information is synchronized to the second cache for data persistence.

[0065] In addition to synchronizing the update information to the first cache of each working process to guide the blue-green distribution after triggering the whitelist update operation or the blue-green switch operation, the update information can also be updated to the second cache to achieve persistent data storage. This makes it convenient to initialize the first cache during the next cold start, providing an accurate information basis for the blue-green deployment process.

[0066] In one exemplary embodiment, an implementation method for dynamically updating a first cache is provided. For example... Figure 4 As shown, in response to the operation of updating the first cache, executing a preset script using the reverse proxy module to obtain update information and synchronize it to the first cache corresponding to each working process may include steps S410 and S420:

[0067] Step 410: If the operation to update the first cache is an operation to update the whitelist, then execute the preset script through the reverse proxy module to obtain the whitelist update information.

[0068] Step 420: Broadcast the whitelist update information to synchronize the whitelist update information to the first cache corresponding to each worker process.

[0069] The whitelist update operation can be triggered by staff or can be an update operation that starts in response to a trigger command. The trigger command can be sent by the user's terminal device or can be triggered locally by the system in response to some automated events.

[0070] The operation of updating the first cache can be an update operation during the initialization phase or an update operation during any other phase, and all of these are within the protection scope of the embodiments disclosed herein.

[0071] Figure 5 A model diagram of dynamically configuring the first cache is shown below, combined with... Figure 5 The dynamic configuration of the first cache in this embodiment is described below. The reverse proxy module includes a master process and multiple worker processes. Each worker process corresponds to a virtual machine cache, such as a Lua VM cache, in the first cache.

[0072] During the cold start phase, the Nginx service first starts and obtains whitelist update information by executing a preset script through the master process in the reverse proxy module. For example, the master process can initialize global variables using `init_by_lua` to obtain the update information, which includes the whitelist update. Next, the master process broadcasts the global variables to each worker process to update the first cache corresponding to each worker process.

[0073] In other stages, if an operation updating the first cache is equivalent to updating the whitelist, the whitelist update information can be obtained by executing a preset script through the master process in the reverse proxy module. For example, Nginx triggers the master process to update global variables via `init_by_lua` during reload, thus obtaining the update information, which includes the whitelist update information. Secondly, the master process broadcasts the global variables to each worker process to update the first cache corresponding to each worker process.

[0074] It should be noted that for each user request, a Lua coroutine will be started within the Lua VM of each worker child process to handle the request, and multiple Lua coroutines share the variables of that Lua VM. For the specific architecture of Nginx-Lua, please refer to relevant technical documentation; details will not be elaborated here.

[0075] This embodiment of the disclosure implements a hot-reload method for updating the whitelist to the first cache, ensuring that the whitelist update operation does not affect the performance of each service and is imperceptible to the user. This allows the whitelist to be updated at any time as needed, improving the flexibility of blue-green deployment solutions. Furthermore, even in high-concurrency scenarios, the dynamic configuration of the first cache avoids the problem of worker processes competing for shared memory, thus guaranteeing service performance.

[0076] In one exemplary embodiment, after updating the whitelist to the first cache, service verification can also be performed. That is, the new version of the service in the target service group is verified by the whitelisted user.

[0077] Service verification refers to verifying new versions of services in the target service group using users on a whitelist. This includes verifying whether the new version functions correctly and whether the method is feasible. This embodiment of the disclosure does not specifically limit the service verification process. For different verification scenarios, the new service can be modified and redeployed in the target service group for verification until it passes.

[0078] Once the new version of the service in the target service group has been verified by white-collar users, a blue-green switch operation can be performed, which means exchanging the service in the initial service group with the service in the target service group so that the vast majority of users can start using the new version of the service.

[0079] Based on this, this disclosure also provides another implementation method for dynamically configuring the first cache. For example... Figure 6 As shown, in response to the operation of updating the first cache, executing a preset script using the reverse proxy module to obtain update information and synchronize it to the first cache corresponding to each working process may include steps S610 and S620:

[0080] Step S610: If the operation to update the first cache is a blue-green switching operation, then the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module.

[0081] Step S620: Broadcast the exchange information to synchronize the exchange information to the first buffer corresponding to each working process.

[0082] The blue-green switching operation can be triggered by staff or as an update operation that starts in response to a trigger command. The trigger command can be sent by the user's terminal device or triggered locally by the system in response to some automated events.

[0083] The first cache update operation caused by the blue-green switching operation can be an update operation in the initialization phase or an update operation in any other phase, and all of them are within the protection scope of this disclosure.

[0084] See also Figure 5As shown, during the cold start phase, the Nginx service first starts, and the master process in the reverse proxy module obtains information about the initial service group and the target service group by executing a preset script. For example, the master process can initialize global variables through `init_by_lua`, thus obtaining updated information. This updated information includes information about the initial service group and the target service group. Next, the master process broadcasts the global variables to each worker process to update the first cache corresponding to each worker process.

[0085] In other phases, if the operation updating the first cache is a blue-green switch operation, the master process in the reverse proxy module can obtain the exchange information between the initial service group and the target service group by executing a preset script. For example, Nginx triggers the master process to update global variables via init_by_lua through reload, thus obtaining the updated information. This updated information includes the exchange information between the services in the initial service group and the target service group. Secondly, the master process broadcasts the global variables to each worker process to update the first cache corresponding to each worker process.

[0086] It should be noted that the information exchanged between the initial service group and the target service group can include the service types that need to be exchanged in these two service groups. It can be all types of services in the two service groups, or only some types of services.

[0087] This embodiment of the disclosure implements a hot-loading method to update the initial service group and target service group to the first cache for blue-green switching operations. This ensures that the blue-green switching operation does not affect the performance of each service and is imperceptible to the user. Furthermore, it allows switching between blue-green branches at any time as needed, improving the flexibility of the blue-green deployment scheme. Moreover, even in high-concurrency scenarios, the dynamic configuration of the first cache avoids the problem of worker processes competing for shared memory, thus guaranteeing service performance.

[0088] In this embodiment of the disclosure, in order to enable individual blue-green deployment for each service, the initial service group includes multiple initial services, and the target service group includes target services corresponding to each initial service. The initial services and the target services corresponding to the initial services have the same identification information.

[0089] For example, see Figure 3 As shown, the initial service group includes multiple initial services A of different types, and the target service group includes target services B corresponding to each initial service A in the initial service group, and each initial service A and the target service B corresponding to that initial service A have the same identification information.

[0090] Based on the foregoing embodiments, this disclosure also provides another implementation method for dynamically configuring the first cache. For example... Figure 7 As shown, if the operation to update the first cache is a blue-green switching operation, then the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module, which may include steps S710 and S720:

[0091] Step S710: Obtain the target identifier information for the blue-green switching operation. The target identifier information is used to indicate the service that needs to undergo the blue-green switching operation.

[0092] Blue-green switching operations can be performed individually for each service. Therefore, the target identifier information of the blue-green switching operation can be obtained from the target identifier information to determine the service to be switched in this operation.

[0093] Step S720: Based on the target identification information, exchange the initial service corresponding to the target identification information in the initial service group with the target service corresponding to the target service in the target service group, and obtain the exchange information by executing a preset script through the reverse proxy module.

[0094] Since the target identifier information is a unique identifier for each service, after obtaining the target identifier information, the initial service corresponding to the target identifier information in the initial service group can be obtained based on the target identifier information, as well as the service corresponding to the target identifier information in the target service group. Then, the determined service pairs are exchanged, and the exchange information is obtained by executing a preset script through the reverse proxy module.

[0095] Based on this, after synchronizing the exchange information to the first cache of each working process, the interceptor module enables the blue-green deployment process of fine-grained services based on the first cache, that is, fine-grained blue-green switching with high flexibility.

[0096] In one exemplary embodiment, the initial service group includes a front-end initial service and a back-end initial service, and the target service group includes a front-end target service corresponding to the front-end initial service and a back-end target service corresponding to the back-end initial service.

[0097] Specifically, the blue-green deployment method of this disclosure is based on a blue-green deployment system. It can utilize a single blue-green deployment scheme, including a front-end initial service and a back-end initial service in the initial service group, and a corresponding target service in the target service group. By using smaller service units as the granularity of blue-green deployment, it eliminates the need to distinguish between front-end and back-end services. As long as services are deployed within the initial and target service groups, simultaneous blue-green deployment of both front-end and back-end services can be achieved. Furthermore, due to the establishment of a first cache, it can be updated via hot reloading and hot updating, achieving second-level switching. There is no resource contention issue related to shared memory, ensuring service performance during blue-green deployment.

[0098] In one exemplary embodiment, the aforementioned preset script is a Lua script. Based on ngx_lua, Lua is embedded into Nginx, so that scripts can be written using Lua. When the Nginx master process loads the configuration file (such as loading or restarting the Nginx process), the preset script will run on the global Lua VM layer to update global variables (obtain update information).

[0099] It should be noted that for specific details about Lua, ngx_lua, etc., please refer to the relevant technologies, which will not be elaborated here.

[0100] To achieve the above solution, this embodiment of the disclosure can integrate Nginx and Lua with modules such as jwt, cjson, and redis to maintain the first cache, redirect user traffic, switch between blue and green servers, and maintain whitelists. This allows the blue-green deployment scheme of this embodiment to avoid the problem of having to shut down the service, support production deployment at any time, and avoid impacting service performance.

[0101] Furthermore, after the blue-green switch is launched—that is, after the majority of user traffic is redirected to the new version through the blue-green switch operation—if a service anomaly is detected, the system can switch back to the previous stable version corresponding to the anomaly service through the blue-green switch operation. The specific switching process can be found in steps S710 and S720, and will not be elaborated upon here.

[0102] The following combination Figure 8 The blue-green deployment method of the present disclosure embodiments is described in its entirety.

[0103] First, deploy the new version to the target service group, while the corresponding stable version is in the initial service group.

[0104] Secondly, staff pre-configure the whitelist, initial service group, and target service group in the second cache.

[0105] Next, a cold start is performed, and the first cache is initialized based on the second cache so that the first cache obtains the whitelist, initial service group, and target service group.

[0106] Then, a whitelist update operation can be triggered, and the update information is synchronized to the first cache corresponding to each working process through hot recording, a process that is imperceptible to the user.

[0107] Specifically, the whitelist update information is obtained by executing a preset script through the reverse proxy module, and the whitelist update information is broadcast to synchronize the whitelist update information to the first cache corresponding to each working process.

[0108] Correspondingly, the updated information can also be synchronously updated to the second cache for data persistence.

[0109] Furthermore, the new version of the service is verified by registered users. If the verification fails, the new version is improved and redeployed until the service is verified.

[0110] Furthermore, a blue-green switch operation is triggered, exchanging services in the initial service group with services in the target service group. The reverse proxy module executes a preset script to obtain the exchange information between the initial and target service groups, and broadcasts the exchange information to synchronize the exchange information to the first cache corresponding to each worker process.

[0111] Correspondingly, the exchanged information can also be synchronously updated to the second cache for data persistence.

[0112] At this point, the interceptor module can redirect the vast majority of user traffic to the new version's corresponding environment based on the first cache of each worker process, thus switching the production traffic service to the new version.

[0113] Finally, if service anomalies occur after the blue-green switch is launched, the abnormal service can be switched back to the previous stable version through the blue-green switch operation.

[0114] The detailed descriptions of the above processes have been recorded in the above embodiments and will not be repeated here.

[0115] The blue-green deployment method provided in this disclosure has two advantages. Firstly, when an operation to update the first cache occurs (i.e., when updating the whitelist or switching the initial and target service groups), a preset script can be executed through the reverse proxy module to obtain update information. This update information is then synchronized to the first cache corresponding to each worker process, enabling the interceptor module to perform the blue-green deployment process based on the update information in the first cache of each worker process. This process dynamically configures the first cache corresponding to each worker process based on the update operation, ensuring that the update takes effect quickly and avoiding performance issues caused by updating the whitelist or switching the initial and target workgroups. This allows for production deployment and switching of blue-green branches (switching the initial and target workgroups) at any time, providing greater flexibility for blue-green deployment. Secondly, even in high-concurrency scenarios, because the first cache of each worker process can be dynamically updated, the interceptor module performs the blue-green deployment process based on the update information in the first cache of each worker process. This avoids different worker processes competing for shared memory, ensuring service performance during blue-green deployment. On the other hand, by setting the services in the initial service group and the target service group with fine granularity, a blue-green deployment scheme can be used to achieve blue-green deployment of the front end and the back end, as well as blue-green deployment at the service granularity, which makes blue-green deployment highly flexible.

[0116] It should be noted that the above figures are merely illustrative of the processes included in the method according to exemplary embodiments of this disclosure, and are not intended to be limiting. It is readily understood that the processes shown in the above figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.

[0117] Further reference Figure 9 As shown, an exemplary embodiment of this disclosure provides a blue-green deployment device 900, applied to a blue-green deployment system. The blue-green deployment system includes a reverse proxy module and an interceptor module. The reverse proxy module includes multiple worker processes, each with its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. The services in the target service group are updated versions of the services in the initial service group. The whitelist is used to indicate user traffic redirected to the target service group. The blue-green deployment device 900 includes an information update module 910 and a blue-green deployment module 920. Wherein:

[0118] Information update module 910 is used to respond to the operation of updating the first cache by using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the worker processes. The update information includes whitelist update information or exchange information between the initial service group and the target service group. Blue-green deployment module 920 is used to execute the blue-green deployment process based on the update information in the first cache corresponding to each of the worker processes through the interceptor module.

[0119] In one exemplary embodiment, the input information further includes status indication information, which is used to indicate the completeness of the information of the current clothing.

[0120] The image recognition module 920 is configured to perform the following: at preset intervals, acquire clothing with status indication information indicating a state to be supplemented as the current clothing; and call the clothing image of the current clothing based on the clothing code corresponding to the current clothing to recognize the clothing image of the current clothing and obtain the first clothing information.

[0121] In an exemplary embodiment, the blue-green deployment system further includes a persistent second cache. Before the operation of updating the first cache is performed by executing a preset script using the reverse proxy module to obtain update information and synchronize it to the first cache corresponding to each of the worker processes, the method further includes: initializing the first cache based on the second cache so that the first cache obtains the whitelist, initial service group, and target service group.

[0122] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes further includes: synchronizing the update information to the second cache for data persistence.

[0123] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes includes: if the operation of updating the first cache is an operation of updating the whitelist, then executing a preset script through the reverse proxy module to obtain whitelist update information; broadcasting the whitelist update information to synchronize the whitelist update information to the first cache corresponding to each of the worker processes.

[0124] In an exemplary embodiment, the step of responding to the operation of updating the first cache by executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes includes: if the operation of updating the first cache is a blue-green switching operation, then exchanging the services in the initial service group with the services in the target service group, and obtaining the exchange information between the initial service group and the target service group by executing a preset script using the reverse proxy module; broadcasting the exchange information to synchronize the exchange information to the first cache corresponding to each of the worker processes.

[0125] In an exemplary embodiment, the initial service group includes multiple initial services, and the target service group includes a target service corresponding to each of the initial services. The initial service and the target service corresponding to the initial service have the same identification information. If the operation of updating the first cache is a blue-green switching operation, the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module. This includes: obtaining the target identification information of the blue-green switching operation, the target identification information being used to indicate the service that needs to undergo a blue-green switching operation; based on the target identification information, exchanging the initial service corresponding to the target identification information in the initial service group with the corresponding target service in the target service group, and obtaining the exchange information by executing a preset script through the reverse proxy module.

[0126] In one exemplary embodiment, the initial service group includes a front-end initial service and a back-end initial service, and the target service group includes a front-end target service corresponding to the front-end initial service and a back-end target service corresponding to the back-end initial service.

[0127] In one exemplary embodiment, the preset script is a Lua script.

[0128] The specific details of each module in the above-mentioned blue-green deployment device 900 have been described in detail in the method section of the implementation. For any undisclosed details, please refer to the implementation content of the method section. That is, the explanation and beneficial effects of the blue-green deployment method of the above embodiment are also applicable to the blue-green deployment device of the present disclosure embodiment, and will not be elaborated here.

[0129] Those skilled in the art will understand that various aspects of this disclosure can be implemented as a system, method, or program product. Therefore, various aspects of this disclosure can be specifically implemented in the following forms: a completely hardware implementation, a completely software implementation (including firmware, microcode, etc.), or a combination of hardware and software aspects, collectively referred to herein as a "circuit," "module," or "system."

[0130] The following reference Figure 10 To describe an electronic device 1000 according to such an embodiment of the present disclosure. Figure 10 The electronic device 1000 shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.

[0131] like Figure 10 As shown, the electronic device 1000 is manifested in the form of a general-purpose computing device. The components of the electronic device 1000 may include, but are not limited to: at least one processing unit 1010, at least one storage unit 1020, a bus 1030 connecting different system components (including storage unit 1020 and processing unit 1010), and a display unit 1040.

[0132] The storage unit stores program code that can be executed by the processing unit 1010, causing the processing unit 1010 to perform the steps described in the "Exemplary Methods" section above according to various exemplary embodiments of this disclosure.

[0133] Storage unit 1020 may include readable media in the form of volatile storage units, such as random access memory (RAM) 10201 and / or cache memory 10202, and may further include read-only memory (ROM) 10203.

[0134] Storage unit 1020 may also include a program / utility 10204 having a set (at least one) program module 10205, such program module 10205 including but not limited to: operating system, one or more application programs, other program modules and program data, each or some combination of these examples may include an implementation of a network environment.

[0135] Bus 1030 can represent one or more of several types of bus structures, including a memory cell bus or memory cell controller, a peripheral bus, a graphics acceleration port, a processing unit, or a local bus using any of the multiple bus structures.

[0136] Electronic device 1000 can also communicate with one or more external devices 1100 (e.g., keyboard, pointing device, Bluetooth device, etc.), one or more devices that enable a user to interact with electronic device 1000, and / or any device that enables electronic device 1000 to communicate with one or more other computing devices (e.g., router, modem, etc.). This communication can be performed via input / output (I / O) interface 1050. Furthermore, electronic device 1000 can also communicate with one or more networks (e.g., local area network (LAN), wide area network (WAN), and / or public networks, such as the Internet) via network adapter 1060. As shown, network adapter 1060 communicates with other modules of electronic device 1000 via bus 1030. It should be understood that, although not shown in the figures, other hardware and / or software modules can be used in conjunction with electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0137] Furthermore, exemplary embodiments of this disclosure also provide a computer-readable storage medium storing a program product capable of implementing the methods described above. In some possible embodiments, various aspects of this disclosure may also be implemented as a program product including program code that, when run on a terminal device, causes the terminal device to perform the steps described in the "Exemplary Methods" section of this specification according to various exemplary embodiments of this disclosure.

[0138] It should be noted that the computer-readable medium disclosed herein may be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium may be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof.

[0139] In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can transmit, propagate, or transfer a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wireless, wireline, optical fiber, RF, etc., or any suitable combination thereof.

[0140] Furthermore, program code for performing the operations of this disclosure can be written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Java and C++, and conventional procedural programming languages ​​such as C or similar languages. The program code can execute entirely on the user's computing device, partially on the user's computing device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0141] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and embodiments are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.

Claims

1. A blue-green deployment method, characterized in that, The method is applied to a blue-green deployment system, which includes a reverse proxy module and an interceptor module. The reverse proxy module includes multiple worker processes, each with its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. The services in the target service group are updated versions of the services in the initial service group. The whitelist is used to indicate user traffic directed to the target service group. In response to the operation of updating the first cache, the reverse proxy module executes a preset script to obtain update information and synchronizes it to the first cache corresponding to each of the worker processes. The update information includes whitelist update information or exchange information between the initial service group and the target service group. The interceptor module executes the blue-green deployment process based on the update information in the first cache corresponding to each of the worker processes.

2. The method according to claim 1, characterized in that, The blue-green deployment system also includes a persistent second cache. Before the operation of updating the first cache is performed, the method further includes executing a preset script using the reverse proxy module to obtain update information and synchronizing it to the first cache corresponding to each of the worker processes. The first cache is initialized based on the second cache, so that the first cache obtains the whitelist, the initial service group, and the target service group.

3. The method according to claim 2, characterized in that, The step of responding to the operation of updating the first cache by using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the worker processes further includes: The updated information is synchronously updated to the second cache for data persistence.

4. The method according to claim 1, characterized in that, The step of responding to the operation of updating the first cache by using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the worker processes includes: If the operation of updating the first cache is an operation of updating the whitelist, then the whitelist update information is obtained by executing a preset script through the reverse proxy module; The whitelist update information is broadcast to synchronize the whitelist update information to the first cache corresponding to each of the worker processes.

5. The method according to claim 1, characterized in that, The step of responding to the operation of updating the first cache by using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the worker processes includes: If the operation to update the first cache is a blue-green switching operation, then the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module. The exchange information is broadcast to synchronize it to the first cache corresponding to each of the worker processes.

6. The method according to claim 5, characterized in that, The initial service group includes multiple initial services, and the target service group includes target services corresponding to each of the initial services. The initial service and the target service corresponding to the initial service have the same identification information. If the operation to update the first cache is a blue-green switching operation, then the services in the initial service group are exchanged with the services in the target service group, and the exchange information between the initial service group and the target service group is obtained by executing a preset script through the reverse proxy module, including: Obtain the target identifier information for the blue-green switching operation, wherein the target identifier information is used to indicate the service that needs to undergo the blue-green switching operation; Based on the target identification information, the initial service corresponding to the target identification information in the initial service group is exchanged with the target service corresponding to the target service group, and the exchange information is obtained by executing a preset script through the reverse proxy module.

7. The method according to any one of claims 1 to 6, characterized in that, The initial service group includes a front-end initial service and a back-end initial service, and the target service group includes a front-end target service corresponding to the front-end initial service and a back-end target service corresponding to the back-end initial service.

8. The method according to any one of claims 1 to 6, characterized in that, The preset script is a Lua script.

9. A blue-green deployment device, characterized in that, An application is provided for blue-green deployment systems, which include a reverse proxy module and an interceptor module. The reverse proxy module includes multiple worker processes, each with its own corresponding first cache. The first cache includes a whitelist, an initial service group, and a target service group. Services in the target service group are updated versions of services in the initial service group. The whitelist is used to indicate user traffic directed to the target service group. The device includes: The information update module is used to respond to the operation of updating the first cache by using the reverse proxy module to execute a preset script to obtain update information and synchronize it to the first cache corresponding to each of the working processes. The update information includes whitelist update information or exchange information between the initial service group and the target service group. The blue-green deployment module is used to execute the blue-green deployment process based on the update information in the first cache corresponding to each of the worker processes through the interceptor module.

10. An electronic device, characterized in that, include: processor; as well as Memory for storing the executable instructions of the processor; The processor is configured to perform the method of any one of claims 1 to 8 by executing the executable instructions.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 8.