Micro-service framework generation method and device, equipment and storage medium
By pre-built microservice infrastructure template library and real-time monitoring strategies, the complexity of microservice architecture design and construction is solved, the technical threshold is lowered, the construction efficiency and service stability are improved, and business continuity is ensured.
Patent Information
- Application Number
- CN202411153857.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-21
- Publication Date
- 2024-11-15
AI Technical Summary
The existing technology is difficult to simplify the design and construction process of microservice architecture, which increases the technical threshold and time cost of developers, especially in the face of high concurrent access and service failure, and it is difficult to effectively implement peak-cutting and valley-filling strategies and fault isolation.
By obtaining business scenario information, pre-built the microservice infrastructure, forming a template library, and pre-processing and matching based on project information, building an adaptive microservice architecture, monitoring traffic and service status in real time, and executing preset exception maintenance strategies.
The design and construction process of microservice architecture is simplified, the technical threshold is lowered, the construction efficiency is improved, the stability and response speed of services are ensured, abnormal situations are handled in a timely manner, and the service interruption time is minimized.
Smart Images

Figure CN118963714A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to a method, device, equipment and storage medium for generating a microservice framework. Background Art
[0002] With the rapid development of Internet technology, the complexity of applications is increasing day by day. The microservice architecture has shown unparalleled advantages in the construction of large-scale systems with its excellent concurrent processing capabilities, high stability and strong scalability. However, manually building a microservice framework is not easy. Manual construction requires developers to not only have a solid programming foundation, but also a deep understanding of the complex principles of distributed systems, including service registration and discovery, load balancing mechanisms, fault tolerance and recovery strategies, etc. These technical difficulties undoubtedly increase the difficulty and time cost of project development.
[0003] In the actual application of microservice architecture, facing sudden high concurrent access and traffic peaks, how to effectively implement the peak-shaving and valley-filling strategy, reasonably control the request traffic, and prevent the system from overload and crash has become an important consideration in system architecture design; at the same time, when encountering service failures or anomalies, how to quickly locate the problem, implement fault isolation, ensure uninterrupted service, and ensure business continuity and stability are also key challenges that system designers must face.
[0004] It can be seen that the existing technology still needs to be improved and enhanced. Summary of the invention
[0005] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a method for generating a microservice framework, which simplifies the design and construction process of the microservice architecture, lowers the technical threshold, and enables developers to focus more on the implementation of business logic.
[0006] A first aspect of the present invention provides a method for generating a microservice framework, comprising: obtaining business scenario information, pre-building a variety of microservice infrastructures corresponding to business scenarios based on the business scenario information, and forming a microservice architecture template library; obtaining project information, pre-processing the project information to obtain key information; extracting the microservice infrastructure with the highest matching degree from the microservice architecture template library based on the key information; constructing a microservice architecture corresponding to the project information based on the key information and the extracted microservice infrastructure, monitoring the number of requests of the microservice architecture in real time, and performing flow control; monitoring the service status of the microservice architecture in real time, and executing a preset abnormal maintenance strategy when there is an abnormality in the service status.
[0007] Optionally, in a first implementation method of the first aspect of the present invention, the business scenario information is obtained, and a plurality of microservice infrastructures corresponding to the business scenarios are pre-built according to the business scenario information, and a microservice architecture template library is formed, including: obtaining business scenario information, wherein the business scenario information includes a plurality of types of business scenarios; obtaining a specified technology stack, and building an infrastructure corresponding to the business scenario type based on the obtained technology stack; setting the service registration mechanism of the infrastructure to a heartbeat mechanism, and setting the discovery mechanism of the infrastructure to a distributed consistency algorithm; setting a load balancing strategy and a peak shaving strategy in the infrastructure to complete the construction of the microservice infrastructure; integrating multiple microservice infrastructures to obtain a microservice architecture template library.
[0008] Optionally, in a second implementation method of the first aspect of the present invention, the load balancing strategy and the peak shaving strategy are set in the infrastructure to complete the construction of the microservice infrastructure, including: in the infrastructure, selecting a weighted polling algorithm as the load balancing algorithm, and setting the Flume distributed log collection framework for log collection and the Consul distributed coordination framework for updating configuration information to complete the setting of the load balancing strategy; in the infrastructure, constructing a peak shaving strategy management system to store multiple types of pre-selected peak shaving strategies in the constructed peak shaving strategy management system; adjusting the operating logic of the policy engine included in the peak shaving strategy management system to complete the setting of the peak shaving strategy; integrating the load balancing strategy and the peak shaving strategy to complete the construction of the microservice infrastructure.
[0009] Optionally, in a third implementation method of the first aspect of the present invention, the obtaining of project information, preprocessing of the project information, and obtaining key information include: obtaining project information, wherein the project information includes a project name and business information; using natural language processing technology to extract multiple keywords from the business information; and performing data cleaning processing on the extracted multiple keywords to obtain key information.
[0010] Optionally, in a fourth implementation method of the first aspect of the present invention, extracting the microservice infrastructure with the highest matching degree from the microservice architecture template library based on the key information includes: confirming the project scenario type and technology stack type based on the key information; based on the confirmed project scenario type and technology stack type, extracting multiple candidate microservice infrastructures from the microservice architecture template library using a classifier pre-built based on a machine learning algorithm; and using an automatic evaluation tool to extract the microservice infrastructure with the highest matching degree from multiple candidate microservice infrastructures.
[0011] Optionally, in a fifth implementation method of the first aspect of the present invention, a microservice architecture corresponding to the project information is constructed based on the key information and the extracted microservice infrastructure, the number of requests of the microservice architecture is monitored in real time, and traffic control is performed, including: based on the key information and the extracted microservice infrastructure, a microservice architecture corresponding to the project information is constructed; the number of requests of the microservice architecture is monitored in real time, and whether new service requests need to be rejected based on the request rate limiting strategy; if new service requests do not need to be rejected, traffic control is performed based on the constructed peak shaving strategy management system.
[0012] Optionally, in a sixth implementation manner of the first aspect of the present invention, the service status of the microservice architecture is monitored in real time, and when there is an abnormality in the service status, a preset abnormal maintenance strategy is executed, including: real-time monitoring of the service status of the microservice architecture, the service status including the heartbeat response time; using a statistical method to determine whether there is an abnormal problem in the service status based on the heartbeat response time; when there is an abnormal problem in the service status, triggering a recovery action according to the preset abnormal maintenance strategy.
[0013] The second aspect of the present invention provides a device for generating a microservice framework, including: a construction module, which is used to obtain business scenario information, pre-construct a variety of microservice infrastructures corresponding to business scenarios according to the business scenario information, and form a microservice architecture template library; a processing module, which is used to obtain project information, pre-process the project information, and obtain key information; a matching module, which is used to extract the microservice infrastructure with the highest matching degree from the microservice architecture template library according to the key information; a traffic monitoring module, which is used to construct a microservice architecture corresponding to the project information based on the key information and the extracted microservice infrastructure, monitor the number of requests of the microservice architecture in real time, and perform traffic control; a status monitoring module, which is used to monitor the service status of the microservice architecture in real time, and when there is an abnormality in the service status, execute a preset abnormal maintenance strategy.
[0014] Optionally, in a first implementation method of the second aspect of the present invention, the construction module includes: a first acquisition unit, used to acquire business scenario information, wherein the business scenario information includes multiple types of business scenarios; a first construction unit, used to acquire a specified technology stack, and build an infrastructure corresponding to the business scenario type based on the acquired technology stack; a first setting unit, used to set the service registration mechanism of the infrastructure to a heartbeat mechanism, and set the discovery mechanism of the infrastructure to a distributed consistency algorithm; a second setting unit, used to set load balancing strategies and peak shaving strategies in the infrastructure to complete the construction of a microservice infrastructure; an integration unit, used to integrate multiple microservice infrastructures to obtain a microservice architecture template library.
[0015] Optionally, in a second implementation of the second aspect of the present invention, the second setting unit includes: a setting unit, which is used to select a weighted polling algorithm as a load balancing algorithm in the infrastructure, and set the Flume distributed log collection framework for log collection and the Consul distributed coordination framework for updating configuration information to complete the setting of the load balancing strategy; a construction unit, which is used to construct a peak shaving strategy management system in the infrastructure, and store multiple types of pre-selected peak shaving strategies in the constructed peak shaving strategy management system; an adjustment unit, which is used to adjust the operating logic of the policy engine included in the peak shaving strategy management system to complete the setting of the peak shaving strategy; an integration unit, which is used to integrate the load balancing strategy and the peak shaving strategy to complete the construction of the microservice infrastructure.
[0016] Optionally, in a third implementation of the second aspect of the present invention, the processing module includes: a second acquisition unit, used to acquire project information, the project information including a project name and business information; a first extraction unit, used to extract multiple keywords from the business information using natural language processing technology; and a processing unit, used to perform data cleaning processing on the extracted multiple keywords to obtain key information.
[0017] Optionally, in a fourth implementation of the second aspect of the present invention, the matching module includes: a confirmation unit, used to confirm the project scenario type and technology stack type based on key information; a second extraction unit, used to extract multiple candidate microservice infrastructures from a microservice architecture template library based on the confirmed project scenario type and technology stack type, using a classifier pre-built based on a machine learning algorithm; and an evaluation unit, used to extract the microservice infrastructure with the highest matching degree from multiple candidate microservice infrastructures using an automatic evaluation tool.
[0018] Optionally, in a fifth implementation of the second aspect of the present invention, the traffic monitoring module includes: a second construction unit, used to construct a microservice architecture corresponding to the project information based on key information and the extracted microservice infrastructure; a first monitoring unit, used to monitor the number of requests of the microservice architecture in real time, and determine whether it is necessary to reject new service requests based on the request rate limiting strategy; a control unit, used to perform traffic control based on the constructed peak shaving strategy management system if there is no need to reject new service requests.
[0019] Optionally, in a sixth implementation of the second aspect of the present invention, the status monitoring module includes: a second monitoring unit, used to monitor the service status of the microservice architecture in real time, the service status including the heartbeat response time; a statistical unit, used to use statistical methods to determine whether there is an abnormal problem in the service status according to the heartbeat response time; a maintenance unit, used to trigger a recovery action according to a preset abnormal maintenance strategy when there is an abnormal problem in the service status.
[0020] A third aspect of the present invention provides a device for generating a microservice framework, the device comprising: a memory and at least one processor, the memory storing instructions; at least one of the processors calling the instructions in the memory so that the device for generating a microservice framework performs each step of the method for generating a microservice framework described in any one of the above items.
[0021] A fourth aspect of the present invention provides a computer-readable storage medium having instructions stored thereon, and when the instructions are executed by a processor, the steps of any of the above-mentioned methods for generating a microservice framework are implemented.
[0022] In the technical solution of the present invention, business scenario information is obtained to pre-build a variety of microservice infrastructures corresponding to business scenarios to form a microservice architecture template library; project information is obtained and pre-processed to obtain key information; the microservice infrastructure with the highest matching degree is extracted from the microservice architecture template library according to the key information; based on the key information and the microservice infrastructure, a microservice architecture corresponding to the project information is constructed, the number of requests of the microservice architecture is monitored in real time, and traffic control is performed; the service status of the microservice architecture is monitored in real time, and when the service status is abnormal, a preset abnormal maintenance strategy is executed; the method disclosed in the present application simplifies the design and construction process of the microservice architecture by constructing a microservice architecture template library, lowers the technical threshold, and enables developers to focus more on the implementation of business logic. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 A first flow chart of a data processing method provided by an embodiment of the present invention;
[0024] Figure 2 A second flow chart of the data processing method provided by an embodiment of the present invention;
[0025] Figure 3 A third flow chart of the data processing method provided by an embodiment of the present invention;
[0026] Figure 4 A fourth flow chart of the data processing method provided by an embodiment of the present invention;
[0027] Figure 5 A fifth flow chart of the data processing method provided by the embodiment of the present invention;
[0028] Figure 6 A sixth flow chart of the data processing method provided by an embodiment of the present invention;
[0029] Figure 7 A seventh flow chart of the data processing method provided by the embodiment of the present invention;
[0030] Figure 8 A schematic diagram of the structure of a data processing device provided by an embodiment of the present invention;
[0031] Fig. 9 A schematic diagram of the structure of a data processing device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present invention provides a method, apparatus, device and storage medium for generating a microservice framework. In the present invention, the terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "including" or "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0033] For ease of understanding, the specific process of the embodiment of the present invention is described below. Figure 1 , an embodiment of a method for generating a microservice framework in an embodiment of the present invention includes:
[0034] 101. Obtain business scenario information, pre-build a variety of microservice infrastructures corresponding to the business scenarios based on the business scenario information, and form a microservice architecture template library;
[0035] In this embodiment, by building a microservice architecture template library, it is ensured that when new project information is available in the future, the microservice infrastructure that best suits the needs can be quickly matched, thereby improving the construction efficiency of the microservice architecture.
[0036] 102. Obtain project information, pre-process the project information, and obtain key information;
[0037] In this embodiment, the extracted key information is used as a matching basis to improve matching accuracy.
[0038] 103. Extract the microservice infrastructure with the highest matching degree from the microservice architecture template library based on the key information;
[0039] In this embodiment, the microservice infrastructure with the highest matching degree is extracted based on key information. This process greatly shortens the time from project planning to implementation, while ensuring the applicability and accuracy of the matched microservice infrastructure.
[0040] 104. Based on the key information and the extracted microservice infrastructure, build a microservice architecture corresponding to the project information, monitor the number of requests of the microservice architecture in real time, and perform flow control;
[0041] In this embodiment, the service stability and response speed of the microservice architecture are ensured by performing flow control on the microservice architecture.
[0042] 105. Monitor the service status of the microservice architecture in real time. When there is an abnormality in the service status, execute the preset abnormal maintenance strategy;
[0043] In this embodiment, the service status of the microservice architecture is monitored in real time. When an abnormal service status problem is found, the preset abnormal maintenance strategy is triggered to quickly locate the problem and take measures to solve it, thereby minimizing the service interruption time and ensuring the continuity and stability of the service.
[0044] The present application discloses a method for generating a microservice framework, which obtains business scenario information to pre-build a variety of microservice infrastructures corresponding to business scenarios to form a microservice architecture template library; obtains project information and performs pre-processing to obtain key information; extracts the microservice infrastructure with the highest matching degree from the microservice architecture template library according to the key information; constructs a microservice architecture corresponding to the project information based on the key information and the microservice infrastructure, monitors the number of requests of the microservice architecture in real time, and performs flow control; monitors the service status of the microservice architecture in real time, and executes a preset abnormal maintenance strategy when there is an abnormality in the service status; the method disclosed in the present application simplifies the design and construction process of the microservice architecture by constructing a microservice architecture template library and matching the microservice infrastructure from the microservice architecture template library according to project information, thereby lowering the technical threshold, improving the construction efficiency, and enabling developers to focus more on the implementation of business logic.
[0045] See also Figure 2 , the second embodiment of the method for generating a microservice framework in the embodiment of the present invention includes:
[0046] 201. Acquire business scenario information, where the business scenario information includes multiple types of business scenarios;
[0047] 202. Obtain a specified technology stack, and build an infrastructure corresponding to the business scenario type based on the obtained technology stack;
[0048] In this embodiment, the specified technology stack is Node.js; Node.js is an open source and cross-platform JavaScript runtime environment that allows developers to run JavaScript code on the server side; it uses Chrome's V8 JavaScript engine to execute code, making the execution speed of JavaScript code very fast; by using Node.js, developers can use JavaScript as a language to complete all development work from front-end to back-end, thereby simplifying the development process and improving development efficiency.
[0049] 203. Set the service registration mechanism of the infrastructure to the heartbeat mechanism, and set the discovery mechanism of the infrastructure to the distributed consistency algorithm;
[0050] In this embodiment, by setting the service registration mechanism as a heartbeat mechanism, the service periodically sends a heartbeat packet to the registration center to indicate its survival status, and then records the response time and status code of the heartbeat packet through HTTP / HTTPS probes to achieve real-time monitoring of the service status; a distributed consistency algorithm is used as a discovery mechanism, which can help the system to promptly discover and handle data conflicts and update requests; when a node attempts to update data, the algorithm ensures that the update operation can be correctly executed on all nodes, and the data on all nodes will be updated to the latest status; therefore, no matter which node the user accesses the service from, accurate and latest information can be obtained, ensuring that the data and service information on all nodes remain consistent, thereby improving the reliability and availability of the system.
[0051] 204. Set up load balancing strategy and peak shaving strategy in the infrastructure to complete the construction of microservice infrastructure;
[0052] In this embodiment, by setting a load balancing strategy in the infrastructure, intelligent allocation of requests can be achieved, thereby optimizing resource utilization and improving the overall performance and availability of the microservice infrastructure; by setting a peak shaving strategy in the infrastructure, request peaks can be effectively buffered, the pressure resistance and stability of the microservice infrastructure can be improved, and the uncertainty of Internet services can be effectively dealt with, ensuring that high-quality service experience can be provided in various complex environments.
[0053] 205. Integrate multiple microservice infrastructures to obtain a microservice architecture template library.
[0054] See also Figure 3 , a third embodiment of the method for generating a microservice framework in an embodiment of the present invention includes:
[0055] 301. In the infrastructure, select the weighted round-robin algorithm as the load balancing algorithm, set the Flume distributed log collection framework for log collection and the Consul distributed coordination framework for updating configuration information, and complete the setting of the load balancing strategy;
[0056] In this embodiment, a weighted polling algorithm is used as a load balancing algorithm. The weighted polling algorithm assigns different weights to each server according to the processing capacity of the server. When allocating requests, servers with high weights are given priority to ensure that high-performance servers can handle more requests. The weighted polling algorithm is suitable for situations where server performance is uneven, and can make full use of resources to improve the overall performance of the system.
[0057] In this embodiment, the Flume distributed log collection framework is used for log collection and analysis. The Flume distributed log collection framework can collect the logs generated by each service in real time into a centralized database, such as Elasticsearch. Then, the logs are visualized and analyzed through tools such as Kibana, thereby helping operation and maintenance personnel to quickly locate problems and optimize performance.
[0058] In this embodiment, the Consul distributed coordination framework is used to update the configuration information. The Consul distributed coordination framework can ensure the real-time update and consistency of the configuration information, so that the various components in the microservice architecture can work together to improve the stability and reliability of the system.
[0059] 302. In the infrastructure, a peak shaving strategy management system is constructed, and multiple types of pre-selected peak shaving strategies are stored in the constructed peak shaving strategy management system;
[0060] In this embodiment, the multiple types of pre-selected peak shaving strategies may include a first-in-first-out (FIFO) queue model, a token bucket algorithm, and a leaky bucket algorithm.
[0061] The first-in-first-out queue model is used to implement asynchronous processing of requests. Specifically, by calculating the queue length and processing rate, the number of consumers is dynamically adjusted to buffer request peaks, and the producer-consumer model is used for task scheduling; the token bucket algorithm replenishes tokens to the "bucket" by setting a fixed rate, and consumes one token for each request processed; when tokens are insufficient, requests are delayed or rejected, thereby achieving dynamic current limiting; the token bucket algorithm needs to maintain token counters and timestamps, and use thread-safe data structures and timers to achieve precise control; the leaky bucket algorithm simulates a fixed-capacity funnel, and requests flow into the funnel at a constant rate, and the part exceeding the capacity is directly discarded; the leaky bucket algorithm implements flow control through queues, and cooperates with timers to simulate the leakage rate to ensure that the system processing capacity does not exceed the preset threshold.
[0062] 303. Adjust the operation logic of the strategy engine included in the peak shaving strategy management system to complete the setting of the peak shaving strategy;
[0063] In this embodiment, the policy engine is responsible for parsing and executing policies. By adjusting the operating strategy of the policy engine, the microservice architecture can dynamically select and adjust policies according to demand, ensuring the stable operation of the microservice architecture and improving the flexibility of the microservice architecture during operation. Furthermore, in order to ensure the effectiveness and security of the policy, the microservice architecture can also add some additional functions, such as policy conflict detection, policy execution logging and policy auditing, so as to promptly discover problems in the policy adjustment process.
[0064] 304. Integrate load balancing strategy and peak shaving strategy to complete the construction of microservice infrastructure.
[0065] See also Figure 4 , a fourth embodiment of the method for generating a microservice framework in an embodiment of the present invention includes:
[0066] 401. Obtain project information, where the project information includes a project name and business information;
[0067] 402. Use natural language processing technology to extract multiple keywords from business information;
[0068] In this embodiment, natural language processing technology (NLP) is used to extract multiple keywords from business information; the NLP tool can identify keywords, phrases, formats and other features in the business information and convert them into a format that can be understood by a computer; through NLP technology, semantic analysis, sentiment analysis and other operations can be performed on the business information to further understand the intent and applicability of the business information.
[0069] 403. Perform data cleaning on the extracted multiple keywords to obtain key information;
[0070] In this embodiment, the extracted keywords are deduplicated and format converted to complete key data cleaning processing, and the obtained key information includes multiple processed keywords, each processed keyword has a consistent format, thereby improving subsequent matching efficiency and matching accuracy.
[0071] See also Figure 5 , the fifth embodiment of the method for generating a microservice framework in the embodiment of the present invention includes:
[0072] 501. Confirm the project scenario type and technology stack type based on key information;
[0073] 502. Based on the confirmed project scenario type and technology stack type, extract multiple candidate microservice infrastructures from the microservice architecture template library using a pre-built classifier based on a machine learning algorithm;
[0074] In this embodiment, a classifier is pre-built based on a machine learning algorithm. The machine learning algorithm can match the microservice infrastructure according to the project scenario type and technology stack type in the project information. By continuously adjusting and optimizing the parameters of the classifier, the accuracy and efficiency of the microservice infrastructure matching can be improved.
[0075] 503. Use automatic evaluation tools to extract the microservice infrastructure with the highest matching degree from multiple candidate microservice infrastructures;
[0076] In this embodiment, the automatic evaluation tool calculates the matching score through evaluation indicators, where the evaluation indicators include scenario type similarity and technology stack similarity; the microservice infrastructure with the highest matching score is the microservice infrastructure with the highest matching score.
[0077] By combining the classifier with the automatic evaluation tool, the screening and matching evaluation of the microservice infrastructure can be realized, which improves the screening efficiency and accuracy of the microservice infrastructure and provides users with a more personalized and convenient service experience.
[0078] See also Figure 6 , the sixth embodiment of the method for generating a microservice framework in the embodiment of the present invention includes:
[0079] 601. Based on the key information and the extracted microservice infrastructure, construct a microservice architecture corresponding to the project information;
[0080] 602. Monitor the number of requests of the microservice architecture in real time, and determine whether new service requests need to be rejected based on the request rate limiting strategy;
[0081] In this embodiment, whether to reject new service requests is determined based on the request rate limiting strategy; specifically, a QPS limit value is set in advance, a sliding window algorithm is used to accurately count the QPS, and the timeline is divided into multiple small windows of fixed length, for example, each window is 1 second; a circular queue or a double-ended queue is used to maintain these windows, and the windows are continuously slid over time (i.e., the oldest window is removed and new windows are added), and in each window, a counter is used to count the number of requests in the window; when a request enters the system, the window where the current time is located and its request count are first checked. If the number of requests in the current window has exceeded the set QPS limit value, the service request is directly rejected, and a corresponding error message may be returned.
[0082] 603. If there is no need to reject new service requests, flow control is performed based on the constructed peak shaving strategy management system.
[0083] In this embodiment, when there is no need to reject new service requests, the policy engine selects an appropriate traffic control strategy for traffic control; that is, when a new service request enters the microservice architecture, it is first judged by the QPS current limiting strategy. If the request rate exceeds the limit, it is directly rejected; if it passes the QPS limit, a token bucket or leaky bucket algorithm is further used to perform more sophisticated traffic control to ensure that the microservice architecture can still maintain stable operation under high concurrency.
[0084] See also Figure 7 The seventh embodiment of the method for generating a microservice framework in the embodiment of the present invention includes:
[0085] 701. Monitor the service status of the microservice architecture in real time, where the service status includes the heartbeat response time;
[0086] 702. Use statistical methods to determine whether there is an abnormality in the service status based on the heartbeat response time;
[0087] In this embodiment, the statistical method may be a mean analysis method or a standard deviation analysis method. When the statistical value related to the heartbeat response time is lower than a preset abnormal threshold, it indicates that there is an abnormal problem in the service status.
[0088] 703. When there is an abnormal problem in the service status, a recovery action is triggered according to a preset abnormal maintenance strategy;
[0089] In this embodiment, the preset exception maintenance strategies include retrying, switching to backup instances, disabling non-core functions, etc.; the exception rule engine is trained based on the maintenance failure history records. When an abnormal problem occurs, the exception rule engine selects the most appropriate exception maintenance strategy, that is, the most appropriate recovery path, to ensure service continuity; that is, through the exception handling logic, it is ensured that when some components fail, the overall service can still maintain a minimum availability, thereby ensuring business continuity.
[0090] The above describes the method for generating a microservice framework in an embodiment of the present invention. The following describes the device for generating a microservice framework in an embodiment of the present invention. Figure 8 , an embodiment of a device for generating a microservice framework in an embodiment of the present invention includes:
[0091] The construction module 801 is used to obtain business scenario information, pre-build multiple microservice infrastructures corresponding to the business scenarios according to the business scenario information, and form a microservice architecture template library; the processing module 802 is used to obtain project information, pre-process the project information, and obtain key information; the matching module 803 is used to extract the microservice infrastructure with the highest matching degree from the microservice architecture template library according to the key information; the traffic monitoring module 804 is used to build a microservice architecture corresponding to the project information based on the key information and the extracted microservice infrastructure, monitor the number of requests of the microservice architecture in real time, and perform traffic control; the status monitoring module 805 is used to monitor the service status of the microservice architecture in real time, and execute the preset abnormal maintenance strategy when there is an abnormality in the service status.
[0092] In this embodiment, the construction module 801 includes: a first acquisition unit 8011, used to obtain business scenario information, and the business scenario information includes multiple types of business scenarios; a first construction unit 8012, used to obtain a specified technology stack, and build an infrastructure corresponding to the business scenario type based on the acquired technology stack; a first setting unit 8013, used to set the service registration mechanism of the infrastructure to a heartbeat mechanism, and set the discovery mechanism of the infrastructure to a distributed consistency algorithm; a second setting unit 8014, used to set a load balancing strategy and a peak shaving strategy in the infrastructure to complete the construction of a microservice infrastructure; an integration unit 8015, used to integrate multiple microservice infrastructures to obtain a microservice architecture template library.
[0093] In this embodiment, the second setting unit 8014 includes: a setting part 80141, which is used to select a weighted polling algorithm as a load balancing algorithm in the infrastructure, and set the Flume distributed log collection framework for log collection and the Consul distributed coordination framework for updating configuration information to complete the setting of the load balancing strategy; a construction part 80142, which is used to construct a peak shaving strategy management system in the infrastructure, and store multiple types of pre-selected peak shaving strategies in the constructed peak shaving strategy management system; an adjustment part 80143, which is used to adjust the operating logic of the strategy engine included in the peak shaving strategy management system to complete the setting of the peak shaving strategy; an integration part 80144, which is used to integrate the load balancing strategy and the peak shaving strategy to complete the construction of the microservice infrastructure.
[0094] In this embodiment, the processing module 802 includes: a second acquisition unit 8021, used to acquire project information, the project information including project name and business information; a first extraction unit 8022, used to extract multiple keywords from the business information using natural language processing technology; a processing unit 8023, used to perform data cleaning processing on the extracted multiple keywords to obtain key information.
[0095] In this embodiment, the matching module 803 includes: a confirmation unit 8031, which is used to confirm the project scenario type and the technology stack type according to the key information; a second extraction unit 8032, which is used to extract multiple candidate microservice infrastructures from the microservice architecture template library based on the confirmed project scenario type and the technology stack type, using a classifier pre-built based on a machine learning algorithm; an evaluation unit 8033, which is used to extract the microservice infrastructure with the highest matching degree from multiple candidate microservice infrastructures using an automatic evaluation tool.
[0096] In this embodiment, the traffic monitoring module 804 includes: a second construction unit 8041, which is used to construct a microservice architecture corresponding to the project information based on key information and the extracted microservice infrastructure; a first monitoring unit 8042, which is used to monitor the number of requests of the microservice architecture in real time, and determine whether it is necessary to reject new service requests based on the request rate limiting strategy; a control unit 8043, which is used to perform traffic control based on the constructed peak shaving strategy management system if there is no need to reject new service requests.
[0097] In this embodiment, the status monitoring module 805 includes: a second monitoring unit 8051, which is used to monitor the service status of the microservice architecture in real time, and the service status includes the heartbeat response time; a statistical unit 8052, which is used to use statistical methods to determine whether there is an abnormal problem in the service status according to the heartbeat response time; a maintenance unit 8053, which is used to trigger a recovery action according to a preset abnormal maintenance strategy when there is an abnormal problem in the service status.
[0098] above Figure 8 The apparatus for generating a microservice framework in an embodiment of the present invention is described in detail from the perspective of modular functional entities. The device for generating a microservice framework in an embodiment of the present invention is described in detail from the perspective of hardware processing.
[0099] Fig. 91 is a schematic diagram of a structure of a device for generating a microservice framework provided by an embodiment of the present invention. The device 900 for generating a microservice framework may have relatively large differences due to different configurations or performances, and may include one or more processors (central processing units, CPU) 910 (for example, one or more processors) and a memory 920, and one or more storage media 930 (for example, one or more massive storage devices) storing application programs 933 or data 932. Among them, the memory 920 and the storage medium 930 may be short-term storage or persistent storage. The program stored in the storage medium 930 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the device 900 for generating a microservice framework. Furthermore, the processor 910 may be configured to communicate with the storage medium 930, and execute a series of instruction operations in the storage medium 930 on the device 900 for generating a microservice framework, so as to implement the steps of the method for generating a microservice framework provided in the above-mentioned method embodiments.
[0100] The device 900 for generating a microservice framework may also include one or more power supplies 940, one or more wired or wireless network interfaces 950, one or more input and output interfaces 960, and / or one or more operating systems 931, such as Windows Serve, Mac OS X, Unix, Linux, FreeBSD, etc. It will be appreciated by those skilled in the art that Fig. 9 The structure of the device for generating a microservice framework shown does not constitute a limitation on the device for generating a microservice framework, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0101] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When the instructions are executed on a computer, the computer executes the steps of the method for generating a microservice framework.
[0102] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system, device, or unit can refer to the corresponding process in the aforementioned method embodiment and will not be repeated here.
[0103] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program codes.
[0104] Finally, it should be noted that the above description is only a preferred example of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art can still modify the technical solutions described in the aforementioned embodiments or replace some of the technical features therein by equivalents. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for generating a microservice framework, characterized in that: include: Obtain business scenario information, pre-build a variety of microservice infrastructures corresponding to business scenarios based on the business scenario information, and form a microservice architecture template library; Obtain project information, pre-process the project information, and obtain key information; According to the key information, extract the microservice infrastructure with the highest matching degree from the microservice architecture template library; Based on the key information and the extracted microservice infrastructure, build a microservice architecture corresponding to the project information, monitor the number of requests of the microservice architecture in real time, and perform flow control; Monitor the service status of the microservice architecture in real time, and execute the preset abnormal maintenance strategy when there is an abnormality in the service status.
2. The method for generating a microservice framework according to claim 1, characterized in that: The business scenario information is obtained, and a plurality of microservice infrastructures corresponding to the business scenarios are pre-built according to the business scenario information, and a microservice architecture template library is formed, including: Acquire business scenario information, where the business scenario information includes multiple types of business scenarios; Obtain the specified technology stack, and build the infrastructure corresponding to the business scenario type based on the obtained technology stack; Set the infrastructure service registration mechanism to the heartbeat mechanism, and set the infrastructure discovery mechanism to the distributed consensus algorithm; Set up load balancing and peak-cutting strategies in the infrastructure to complete the construction of the microservice infrastructure; Integrate multiple microservice infrastructures to obtain a microservice architecture template library.
3. The method for generating a microservice framework according to claim 2, characterized in that: The load balancing strategy and peak shaving strategy are set in the infrastructure to complete the construction of the microservice infrastructure, including: In the infrastructure, select the weighted round-robin algorithm as the load balancing algorithm, set the Flume distributed log collection framework for log collection and the Consul distributed coordination framework for updating configuration information, and complete the setting of the load balancing strategy; In the basic architecture, a peak shaving strategy management system is constructed, and multiple types of pre-selected peak shaving strategies are stored in the constructed peak shaving strategy management system; Adjust the operation logic of the strategy engine included in the peak shaving strategy management system to complete the setting of the peak shaving strategy; Integrate load balancing strategy and peak shaving strategy to complete the construction of microservice infrastructure.
4. The method for generating a microservice framework according to claim 1, characterized in that: The project information is obtained and preprocessed to obtain key information, including: Acquire project information, wherein the project information includes project name and business information; Use natural language processing technology to extract multiple keywords from business information; The extracted multiple keywords are cleaned and processed to obtain key information.
5. The method for generating a microservice framework according to claim 4, characterized in that: According to the key information, the microservice infrastructure with the highest matching degree is extracted from the microservice architecture template library, including: Confirm the project scenario type and technology stack type based on key information; Based on the confirmed project scenario type and technology stack type, a pre-built classifier based on machine learning algorithm is used to extract multiple candidate microservice infrastructures from the microservice architecture template library; An automatic evaluation tool is used to extract the microservice infrastructure with the highest matching degree from multiple candidate microservice infrastructures.
6. The method for generating a microservice framework according to claim 3, characterized in that: Based on the key information and the extracted microservice infrastructure, a microservice architecture corresponding to the project information is constructed, the number of requests of the microservice architecture is monitored in real time, and flow control is performed, including: Based on the key information and the extracted microservice infrastructure, build a microservice architecture corresponding to the project information; Monitor the number of requests in the microservice architecture in real time, and determine whether new service requests need to be rejected based on the request rate limiting strategy; If there is no need to reject new service requests, flow control is performed based on the constructed peak shaving strategy management system.
7. The method for generating a microservice framework according to claim 1, characterized in that: The real-time monitoring of the service status of the microservice architecture and the execution of a preset abnormal maintenance strategy when the service status is abnormal include: Real-time monitoring of the service status of the microservice architecture, including the heartbeat response time; Use statistical methods to determine whether the service status is abnormal based on the heartbeat response time; When there are abnormal problems in the service status, the recovery action is triggered according to the preset abnormal maintenance strategy.
8. A device for generating a microservice framework, characterized in that: include: The construction module is used to obtain business scenario information, pre-build a variety of microservice infrastructures corresponding to the business scenarios based on the business scenario information, and form a microservice architecture template library; The processing module is used to obtain project information, pre-process the project information, and obtain key information; A matching module is used to extract the microservice infrastructure with the highest matching degree from the microservice architecture template library based on key information; The traffic monitoring module is used to build a microservice architecture corresponding to the project information based on key information and the extracted microservice infrastructure, monitor the number of requests of the microservice architecture in real time, and perform traffic control; The status monitoring module is used to monitor the service status of the microservice architecture in real time. When there is an abnormality in the service status, the preset abnormal maintenance strategy is executed.
9. A device for generating a microservice framework, characterized in that: The device for generating a microservice framework comprises: a memory and at least one processor, wherein instructions are stored in the memory; At least one of the processors calls the instructions in the memory so that the device for generating a microservice framework executes each step of the method for generating a microservice framework as described in any one of claims 1 to 7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by the processor, the steps of the method for generating a microservice framework as described in any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Emergency processing method, device and equipment for persistent data registration center
CN119892604A
