A service preheating method and device
The service preheating method addresses the cold start issue in microservice architecture by dynamically determining and executing preheating logic within services, ensuring rapid and flexible preheating across diverse service types, enhancing stability and throughput in high-concurrency scenarios.
Patent Information
- Application Number
- CN202211694207.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-12-28
AI Technical Summary
Microservice architecture faces the challenge of service cold start, where service providers experience long startup times and significant mobilization fluctuations, leading to poor overall service stability, especially in high-concurrency scenarios requiring fast response and high throughput.
A service preheating method that involves obtaining service objects and configurations, determining preheating entries and input parameters through reflection, and executing preheating logic to rapidly preheat services, allowing for flexible and configurable preheating across various service types without relying on external resources.
The method enables efficient, low-cost preheating suitable for high-throughput scenarios, improving user experience by ensuring rapid service availability and stability, while supporting diverse service sources and configurations.
Smart Images

Figure CN116016648B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a service preheating method and device. Background Art
[0002] Microservice architecture can divide a single application into several relatively independent services, and the services coordinate and cooperate with each other to jointly provide service capabilities for users. However, microservice architecture has the problem of service cold start, that is, when the service provider starts, the service caller's instant TP takes a long time and the mobilization fluctuates greatly, resulting in poor overall service stability. To address the cold start problem, the mainstream solution is to preheat the service.
[0003] In the related technology, preheating is mainly achieved based on flow control, which improves system stability by reducing system throughput. This method has the characteristics of complex process, high cost and poor adaptability, and limits the source of preheating services. It is not suitable for high-concurrency scenarios that require fast response and high throughput at the same time. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a service preheating method and device, which can realize rapid preheating of services with low cost and high efficiency, is suitable for scenarios requiring rapid response and maintaining high throughput, has a wide preheating range, and is flexible and configurable.
[0005] To achieve the above object, according to one aspect of an embodiment of the present invention, a service preheating method is provided, comprising:
[0006] In response to the start of the service, obtaining each service object and preheating configuration corresponding to the service;
[0007] Determine a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration;
[0008] Preheating logic is executed according to the preheating input parameters and the preheating entry to preheat the service.
[0009] Optionally, determining a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration includes:
[0010] Determining whether the service object includes a first preset annotation; the first preset annotation indicates a preheating type identifier;
[0011] In the case where the service object includes the first preset annotation, obtaining each method corresponding to the service object;
[0012] Determining whether the method includes a second preset annotation; the second preset annotation indicates a preheating method identifier;
[0013] In the case where the method includes the second preset annotation, determining the method as a preheating entry;
[0014] According to the preheating type identifier and the preheating method identifier, a preheating input parameter corresponding to the preheating entry is obtained from the preheating configuration.
[0015] Optionally, the preheating configuration is one or more of annotation configuration, file configuration and unified configuration center configuration.
[0016] Optionally, after determining that the method is a preheating entrance, the method further includes:
[0017] According to the preheating type identifier and the preheating method identifier, a preheating rule corresponding to the preheating entry is acquired from the preheating configuration.
[0018] Optionally, the preheating configuration includes a correspondence between a first preheating parameter and a second preheating parameter, the first preheating parameter includes a preheating type identifier and a preheating method identifier, the second preheating parameter includes a preheating input parameter and a preheating rule, and the preheating rule includes the number of preheating executions.
[0019] Optionally, the preheating rule includes a timed preheating mode, and after executing the preheating logic according to the preheating input parameter and the preheating entry, it also includes:
[0020] Determine whether the timed preheating mode is turned on;
[0021] When the timed preheating mode is turned on, an execution time and an execution cycle corresponding to the timed preheating mode are obtained, so as to repeatedly execute the preheating logic according to the execution time and execution cycle.
[0022] Optionally, the preheating configuration is a unified configuration center configuration, and after determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration, the method further includes:
[0023] Register the preheating entry, the preheating input parameter and the preheating rule into the preheating context;
[0024] In response to monitoring a modification instruction for the unified configuration center, obtaining modified configuration content corresponding to the modification instruction, the configuration content including a preset entry, a preheating input parameter, and a preheating rule;
[0025] The modified configuration content is synchronized to the preheating context.
[0026] According to another aspect of an embodiment of the present invention, there is provided a service preheating device, comprising:
[0027] An acquisition module, in response to the start of a service, acquires each service object and preheating configuration corresponding to the service;
[0028] A determination module, which determines a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration;
[0029] An execution module executes preheating logic according to the preheating input parameter and the preheating entry to preheat the service.
[0030] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0031] one or more processors;
[0032] a storage device for storing one or more programs,
[0033] When the one or more programs are executed by the one or more processors, the one or more processors implement the service preheating method provided by the present invention.
[0034] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the service preheating method provided by the present invention is implemented.
[0035] An embodiment of the above invention has the following advantages or beneficial effects: by obtaining the service object and preheating configuration corresponding to the service when the service is started, obtaining the preheating entry according to the service object, determining the preheating input parameters according to the preheating entry and the preheating configuration, and then executing the preheating logic according to the preheating input parameters and the preheating entry, the preheating of the service is realized. This method can be applied to any service in the microservice architecture. The method is executed inside each service, and the preheating of each service does not affect each other, and the number of services does not affect the preheating speed; the method obtains the preheating entry and preheating input parameters through reflection capability to realize the execution of the preheating logic, so that the method does not have to rely on external resources and does not limit the type of service source; the preheating range is flexible and configurable, and the preheating of services from different sources can be flexibly realized by adjusting the configuration content in the preheating configuration; the method is suitable for scenarios with fast response and high throughput at the same time, which can improve user experience, and the preheating method is low in cost and high in efficiency.
[0036] The further effects of the above-mentioned non-conventional optional manner will be described below in conjunction with the specific implementation manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings are used to better understand the present invention and do not constitute an improper limitation of the present invention.
[0038] Figure 1is a schematic diagram of the main process of a service preheating method according to an embodiment of the present invention;
[0039] Figure 2 is a schematic diagram of the main process of another service preheating method according to an embodiment of the present invention;
[0040] Figure 3 is a schematic diagram of the main process of another service preheating method according to an embodiment of the present invention;
[0041] Figure 4 is a schematic diagram of the main process of another service preheating method according to an embodiment of the present invention;
[0042] Figure 5 is a schematic diagram of main modules of a service preheating device according to an embodiment of the present invention;
[0043] Figure 6 is an exemplary system architecture diagram to which embodiments of the present invention may be applied;
[0044] Figure 7 It is a schematic diagram of the structure of a computer system of a terminal device or a server suitable for implementing an embodiment of the present invention. DETAILED DESCRIPTION
[0045] The following is a description of exemplary embodiments of the present invention in conjunction with the accompanying drawings, including various details of the embodiments of the present invention to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for clarity and conciseness, the description of well-known functions and structures is omitted in the following description.
[0046] It should be noted that the acquisition, storage and application of personal information etc. involved in the embodiments of the present invention are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0047] Figure 1 is a schematic diagram of the main process of a service preheating method according to an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:
[0048] Step S101: in response to the start of a service, obtaining each service object and preheating configuration corresponding to the service;
[0049] Step S102: determining a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration;
[0050] Step S103: Execute the preheating logic according to the preheating input parameters and the preheating entry to preheat the service.
[0051] In an embodiment of the present invention, the service preheating method can be used to preheat any service in a microservice architecture. Supported service sources include RPC (Remote Procedure Call), HTTP (Hyper Text Transfer Protocol), MQ (Message Queue), database, cache and other services, which basically cover all types of business services and can meet diversified services.
[0052] In an embodiment of the present invention, when the service is started, the service object will be initialized and loaded during the service startup process, at which time the service object is obtained and the preheating configuration is read at the same time. Among them, the method can be implemented by the Spring (a Java language open source framework) framework. The service object can be a bean object (the framework is responsible for maintaining the object instance of the life cycle under the Spring framework), and the preheating configuration can provide the service with configuration content related to preheating. Among them, the preheating configuration can be determined by reading the application configuration, that is, the parameters corresponding to the preheating configuration are indicated in the application configuration.
[0053] In an embodiment of the present invention, the data source of the preheating configuration can be one or more of the annotation configuration, file configuration and unified configuration center configuration. The data source of the preheating configuration can also be expanded according to business needs. The preheating configuration of different data sources can match different reading parsers to read the configuration content, and can support the addition of different data sources by adding custom parsers. Among them, the annotation configuration can configure the configuration content by adding annotations, which is convenient and fast, and there is no need to write additional configuration content. For example, the service to be executed and the preheating entry can be determined according to the annotation configuration. File configuration, that is, local configuration, can be preheated by customizing the file content configuration, without relying on third-party components. The file is readable and easy to write. JSON (a lightweight data exchange format) object can be used as the format of the configuration file. The user can enable the file configuration function by setting the configuration file path. If the configuration content needs to be modified, the modified configuration file can be used to replace the configuration file before modification without modifying the code file. The unified configuration center configuration is a middleware that can realize the storage and management of configuration content. It can be implemented through a centralized configuration service platform. It has the characteristics of real-time effectiveness after modification. At the same time, the configuration content can be shared, and the format of the configuration file can also adopt the JSON object format.
[0054] In the embodiment of the present invention, Figure 2 As shown, after obtaining the service object and preheating configuration corresponding to the service, the preheating entry and preheating input parameters corresponding to the service object are determined according to the service object and the preheating configuration, including:
[0055] Step S201: determining whether the service object contains a first preset annotation; the first preset annotation indicates a preheating type identifier;
[0056] Step S202: when the service object includes the first preset annotation, obtaining each method corresponding to the service object;
[0057] Step S203: determining whether the method includes a second preset annotation; the second preset annotation indicates a preheating method identifier;
[0058] Step S204: when the method includes the second preset annotation, determining the method as a preheating entry;
[0059] Step S205: According to the preheating type identifier and the preheating method identifier, obtain the preheating input parameter corresponding to the preheating entry from the preheating configuration.
[0060] In an embodiment of the present invention, under the Spring framework, the preheating entry and preheating input parameters corresponding to the service object are determined through annotation configuration. The preheating entry is the preheating method that needs to be executed when the preheating logic is executed. The preheating input parameters are passed to the preheating entry, and the preheating logic can be executed. First, it is necessary to determine whether the service object contains the first preset annotation, and the first preset annotation indicates the preheating type identifier. If the service object contains the first preset annotation, it means that the service is a service to be preheated. If the service object does not contain the first preset annotation, it means that the service is not a service to be preheated, and the process can be terminated. Among them, the preheating type identifier can be a custom-set identifier indicating the preheating type, and the preheating type identifier can be a preheating type name. For example, @WarmUpType (type = "remote") specifies that the type of preheating parameters used by the service with this annotation is remote.
[0061] When the service object contains the first preset annotation, the various methods corresponding to the service object can be obtained through reflection capability, and then for each method, it is determined whether the method contains the second preset annotation, which indicates the preheating method identifier, and the preheating method identifier can be the preheating method name. If the method includes the second preset annotation, it means that the method is a preheating entry. For example, @WarmUpPoint(method="http") is loaded on the method, which specifies that the method of a certain service object uses the preheating configuration as the preheating input parameter of http. If the method does not include the second preset annotation, it means that the method is not a preheating entry. After determining the preheating entry, the preheating input parameter can be obtained from the preheating configuration through reflection capability according to the preheating method identifier and the preheating type identifier.
[0062] In an embodiment of the present invention, the configuration content of the preheating configuration includes: a preheating type identifier, a preheating method identifier, and a preheating input parameter. Further, the configuration content of the preheating configuration includes a correspondence between the preheating type identifier and the preheating method identifier and the preheating input parameter, that is, the corresponding preheating input parameter can be obtained from the preheating configuration in real time and dynamically according to the preset type identifier and the preheating method identifier.
[0063] In an embodiment of the present invention, after determining that the method is a preheating entry, it also includes: according to the preheating type identifier and the preheating method identifier, obtaining the preheating rules corresponding to the preheating entry from the preheating configuration. That is to say, the configuration content of the preheating configuration also includes preheating rules, that is, including the correspondence between the first preheating parameter and the second preheating parameter, the first preheating parameter includes the preheating type identifier and the preheating method identifier, and the second preheating parameter includes the preheating input parameter and the preheating rule, that is, according to the preheating type identifier and the preheating method identifier, the corresponding preheating input parameter and preheating rule can be obtained from the preheating configuration. Among them, the preheating rules include the number of preheating executions, and the number of preheating executions can be customized and can be multiple times, such as executing the preheating method corresponding to the preheating entry, that is, the preheating context, multiple times, that is, implementing the execution of the preheating logic to ensure that the service is fully preheated.
[0064] In the embodiment of the present invention, the configuration content of the preheating configuration may also include turning on or off the preheating, stopping the service if the preheating fails, etc. By configuring the stopping service if the preheating fails, the service can be shut down when the preheating fails, so as to prevent the failure caused by the preheating from affecting the normal operation of the service and avoid abnormal online services.
[0065] In an embodiment of the present invention, the preheating rules include a preheating mode at startup, and executing the preheating logic according to the preheating input parameter and the preheating entry is the preheating mode at startup, that is, executing the preheating logic when the service is started, such as executing the preheating context multiple times. The preheating mode at startup enables the service to quickly provide service capabilities, and does not cause TP (Top Percentile) fluctuation problems caused by the service not being preheated. It can avoid the incalculable consequences of abnormalities caused by preheating after the service has been started for a long time, that is, it can avoid the risks caused by preheating abnormalities, and if preheating abnormalities occur, they can also be handled in time.
[0066] In the embodiment of the present invention, the preset rules also include whether to start the timed preheating mode and the execution time and cycle of the timed preheating. Figure 3 As shown, after executing the preheating logic according to the preheating input parameter and the preheating entry, it also includes:
[0067] Step S301: determine whether the timed preheating mode is turned on; if so, execute step S302; if not, execute step S303;
[0068] Step S302: when the timed preheating mode is turned on, obtaining the execution time and execution cycle corresponding to the timed preheating mode, so as to repeatedly execute the preheating logic according to the execution time and execution cycle;
[0069] Step S303: The preheating logic is not executed repeatedly and the process ends.
[0070] In the embodiment of the present invention, since many application scenarios in actual business, such as interactive marketing scenarios, have the characteristics of a timing cycle, a service can be preheated in advance by preheating the service on a timing basis. The timing preheating method can be implemented by using a timing task, and the timing task can be created based on the Quartz architecture.
[0071] In an embodiment of the present invention, after the preheating mode is executed at startup, that is, after the preheating logic is executed according to the preheating input parameter and the preheating entry, it is determined whether the timed preheating mode is turned on. If the timed preheating mode is turned on, the execution time and execution cycle corresponding to the timed preheating mode are further obtained, so that the preheating logic can be repeatedly executed according to the execution time and execution cycle. For example, if the execution time is the 1st of each month and the execution cycle is 3 months, the preheating logic will be executed on the 1st of each month in the past 3 months, that is, the preheating logic will be repeatedly executed 3 times, and each execution of the preheating logic can be a multiple preheating context. If the timed preheating mode is not turned on, the preheating logic will not be repeatedly executed, that is, only the startup preheating mode is used.
[0072] In the embodiment of the present invention, when the preheating configuration is a unified configuration center configuration, such as Figure 4 As shown, after determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration, it includes:
[0073] Step S401: register the preheating entry, preheating input parameters and preheating rules into the preheating context;
[0074] Step S402: in response to monitoring a modification instruction for the unified configuration center, obtaining modified configuration content corresponding to the modification instruction, the configuration content including a preset entry, preheating input parameters and preheating rules;
[0075] Step S403: Synchronize the modified configuration content to the preheating context.
[0076] In an embodiment of the present invention, after determining the preheating entry and preheating input corresponding to the service object, the preheating entry, preheating input and preheating rules are registered in the preheating context, that is, the service that needs to be preheated is loaded into the preheating context. The preheating context includes various methods corresponding to the service object that provide preheating for the service, and the execution of the preheating logic can be realized by executing the preheating context. The preheating context can be used to manage the configuration content of the preheating configuration such as the preheating entry, preheating input and preheating rules, and can avoid the leakage of important data such as sensitive information such as user names and passwords. Monitor the modification instructions of the configuration content of the unified configuration center, obtain the modified configuration content corresponding to the modification instructions, and then synchronize the modified configuration content to the preheating context to realize the rapid dynamic modification of the configuration content, so that the modified configuration content takes effect in real time. Among them, the configuration content may include one or more of the preheating entry, preheating input and preheating rules. For example, the modified configuration content may be the execution time and execution cycle of the timed preheating. The configuration content may also include turning on or off the preheating.
[0077] The service preheating method provided by the embodiment of the present invention realizes preheating of the service by obtaining the service object and preheating configuration corresponding to the service when the service is started, obtaining the preheating entry according to the service object, determining the preheating input parameter according to the preheating entry and the preheating configuration, and then executing the preheating logic according to the preheating input parameter and the preheating entry. The method can be applied to any service in the microservice architecture. The method is executed inside each service, and the preheating of each service does not affect each other, and the number of services does not affect the preheating speed; the method obtains the preheating entry and preheating input parameter through reflection capability, and realizes the execution of the preheating logic in combination with the preheating rules, so that the method does not need to rely on external resources, and does not limit the type of service source, and can support the preheating of services such as RPC, HTTP, MQ, cache, and database. The preheating range is flexible and configurable, and the preheating of services from different sources can be flexibly realized by adjusting the configuration content in the preheating configuration; the method can realize diversified triggering, can preheat at startup and preheat in a timed period, meet diversified preheating scenarios, can be suitable for scenarios with fast response and high throughput, and can improve user experience; and the preheating method has low cost and high efficiency.
[0078] like Figure 5 As shown, according to another aspect of an embodiment of the present invention, a service preheating device 500 is provided, comprising:
[0079] The acquisition module 501 acquires each service object and preheating configuration corresponding to the service in response to the start of the service;
[0080] A determination module 502 determines a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration;
[0081] The execution module 503 executes the preheating logic according to the preheating input parameter and the preheating entry to preheat the service.
[0082] In an embodiment of the present invention, the determination module 502 is further used to: determine whether the service object contains a first preset annotation; the first preset annotation indicates a preheating type identifier; when the service object contains the first preset annotation, obtain each method corresponding to the service object; determine whether the method contains a second preset annotation; the second preset annotation indicates a preheating method identifier; when the method contains the second preset annotation, determine that the method is a preheating entry; according to the preheating type identifier and the preheating method identifier, obtain the preheating input parameter corresponding to the preheating entry from the preheating configuration.
[0083] In the embodiment of the present invention, the preheating configuration is one or more of annotation configuration, file configuration and unified configuration center configuration.
[0084] In the embodiment of the present invention, the determination module 502 is further used to: after determining that the method is the preheating entry, obtain the preheating rule corresponding to the preheating entry from the preheating configuration according to the preheating type identifier and the preheating method identifier.
[0085] In an embodiment of the present invention, the preheating configuration includes a correspondence between a first preheating parameter and a second preheating parameter, the first preheating parameter includes a preheating type identifier and a preheating method identifier, the second preheating parameter includes a preheating input parameter and a preheating rule, and the preheating rule includes the number of preheating executions.
[0086] In an embodiment of the present invention, the preheating rules include a timed preheating method, and the determination module 502 is also used to: after executing the preheating logic according to the preheating input parameters and the preheating entry, determine whether the timed preheating method is turned on; when the timed preheating method is turned on, obtain the execution time and execution cycle corresponding to the timed preheating method, so as to repeatedly execute the preheating logic according to the execution time and execution cycle.
[0087] In an embodiment of the present invention, the preheating configuration is a unified configuration center configuration, and the determination module 502 is also used to: after determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration, register the preheating entry, preheating input parameters and preheating rules in the preheating context; in response to monitoring a modification instruction for the unified configuration center, obtain the modified configuration content corresponding to the modification instruction, the configuration content includes the preset entry, preheating input parameters and preheating rules; 5 synchronize the modified configuration content to the preheating context.
[0088] According to another aspect of an embodiment of the present invention, there is provided an electronic device, including:
[0089] One or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, the one or more processors implement the service preheating method provided by the present invention.
[0090] According to another aspect of an embodiment of the present invention, a computer-readable medium is provided, on which a computer program is stored. When the program is executed by a processor, the service preheating method provided by the present invention is implemented.
[0091] Figure 6 An exemplary system architecture 600 to which the preheating execution method or preheating execution apparatus according to the embodiment of the present invention can be applied is shown.
[0092] like Figure 6 As shown, the system architecture 600 may include terminal devices 601, 602, 603, a network 604, and a server 605. The network 604 is used to provide a medium for communication links between the terminal devices 601, 602, 603 and the server 605. The network 604 may include various connection types, such as wired, wireless communication links, or optical fiber cables, etc.
[0093] The user can use the terminal devices 601, 602, 603 to interact with the server 6055 through the network 604 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 601, 602, 603, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (only as examples).
[0094] The terminal devices 601, 602, and 603 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.
[0095] The server 605 may be a server that provides various services, such as a backend management server (only an example) that provides support for shopping websites browsed by users using the terminal devices 601, 602, and 603. The backend management server may analyze and process the received data such as product information query requests, and feed back the processing results (such as target push information, product information - only an example) to the terminal device.
[0096] It should be noted that the preheating execution method provided in the embodiment of the present invention is generally executed by the server 605 , and accordingly, the preheating execution device is generally arranged in the server 605 .
[0097] It should be understood that Figure 6 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0098] Reference below Figure 7 , which shows a schematic diagram of the structure of a computer system 700 of a terminal device suitable for implementing an embodiment of the present invention. Figure 7 The terminal device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0099] like Figure 7 As shown, the computer system 700 includes a central processing unit (CPU) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage part 708 into a random access memory (RAM) 703. In the RAM 703, various programs and data required for the operation of the system 700 are also stored. The CPU 701, the ROM 702, and the RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0100] The following components are connected to the I / O interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the I / O interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed, so that a computer program read therefrom is installed into the storage section 708 as needed.
[0101] In particular, according to the embodiments disclosed in the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present invention include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the central processing unit (CPU) 701, the above-mentioned functions defined in the system of the present invention are executed.
[0102] It should be noted that the computer-readable medium shown in the present invention may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present invention, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.
[0103] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0104] The modules involved in the embodiments of the present invention may be implemented in software or hardware. The modules described may also be provided in a processor, for example, may be described as: a processor including an acquisition module, a determination module and an execution module. The names of these modules do not, in some cases, constitute limitations on the modules themselves, for example, the determination module may also be described as "a module for determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration".
[0105] As another aspect, the present invention also provides a computer-readable medium, which may be included in the device described in the above embodiment; or it may exist independently without being assembled into the device. The above computer-readable medium carries one or more programs, and when the above one or more programs are executed by a device, the device includes: in response to the start of the service, obtaining the service object and preheating configuration corresponding to the service; determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration; executing the preheating logic according to the preheating input parameters and the preheating entry to preheat the service.
[0106] According to the technical solution of the embodiment of the present invention, when the service is started, the service object and preheating configuration corresponding to the service are obtained, the preheating entry is obtained according to the service object, the preheating input parameter is determined according to the preheating entry and the preheating configuration, and then the preheating logic is executed according to the preheating input parameter and the preheating entry to realize the preheating of the service. The method can be applied to any service in the microservice architecture. The method is executed inside each service, and the preheating of each service does not affect each other, and the number of services does not affect the preheating speed; the method obtains the preheating entry and preheating input parameter through reflection capability, and combines the preheating rules to realize the execution of the preheating logic, so that the method does not have to rely on external resources, and does not limit the type of service source, and can support the preheating of services such as RPC, HTTP, MQ, cache, database, etc. The preheating range is flexible and configurable, and the preheating of services from different sources can be flexibly realized by adjusting the configuration content in the preheating configuration; the method can realize diversified triggering, including preheating at startup and preheating in a timed period, meet diversified preheating scenarios, can be applicable to scenarios with fast response and high throughput, and can improve user experience; and the preheating method is low in cost and high in efficiency.
[0107] The above specific implementations do not constitute a limitation on the protection scope of the present invention. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions may occur depending on design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A service preheating method, characterized in that: include: In response to the start of the service, obtaining each service object and preheating configuration corresponding to the service; Determine a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration; Executing preheating logic according to the preheating input parameter and the preheating entry to preheat the service; Among them, determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration includes: judging whether the service object contains a first preset annotation; the first preset annotation indicates a preheating type identifier; when the service object contains the first preset annotation, obtaining each method corresponding to the service object; judging whether the method contains a second preset annotation; the second preset annotation indicates a preheating method identifier; when the method contains the second preset annotation, determining that the method is a preheating entry; according to the preheating type identifier and the preheating method identifier, obtaining the preheating input parameters corresponding to the preheating entry from the preheating configuration.
2. The method according to claim 1, characterized in that The preheating configuration is one or more of annotation configuration, file configuration and unified configuration center configuration.
3. The method according to claim 1, characterized in that After determining that the method is a preheating entrance, it also includes: According to the preheating type identifier and the preheating method identifier, a preheating rule corresponding to the preheating entry is acquired from the preheating configuration.
4. The method according to claim 3, characterized in that The preheating configuration includes a correspondence between a first preheating parameter and a second preheating parameter, the first preheating parameter includes a preheating type identifier and a preheating method identifier, the second preheating parameter includes a preheating input parameter and a preheating rule, and the preheating rule includes the number of preheating executions.
5. The method according to claim 3, characterized in that: The preheating rule includes a timed preheating mode, and after executing the preheating logic according to the preheating input parameter and the preheating entry, it also includes: Determine whether the timed preheating mode is turned on; When the timed preheating mode is turned on, an execution time and an execution cycle corresponding to the timed preheating mode are obtained, so as to repeatedly execute the preheating logic according to the execution time and execution cycle.
6. The method according to claim 3, characterized in that: The preheating configuration is a unified configuration center configuration, and after determining the preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration, it includes: Register the preheating entry, the preheating input parameter and the preheating rule into the preheating context; In response to monitoring a modification instruction for the unified configuration center, obtaining modified configuration content corresponding to the modification instruction, the configuration content including one or more of a preset entry, a preheating input parameter, and a preheating rule; The modified configuration content is synchronized to the preheating context.
7. A service preheating device, characterized in that: include: An acquisition module, in response to the start of a service, acquires each service object and preheating configuration corresponding to the service; A determination module, which determines a preheating entry and preheating input parameters corresponding to the service object according to the service object and the preheating configuration; An execution module executes a preheating logic according to the preheating input parameter and the preheating entry to preheat the service; Among them, the determination module is further used to: determine whether the service object contains a first preset annotation; the first preset annotation indicates a preheating type identifier; when the service object contains the first preset annotation, obtain each method corresponding to the service object; determine whether the method contains a second preset annotation; the second preset annotation indicates a preheating method identifier; when the method contains the second preset annotation, determine that the method is a preheating entry; according to the preheating type identifier and the preheating method identifier, obtain the preheating input parameter corresponding to the preheating entry from the preheating configuration.
8. An electronic device, characterized in that: include: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
9. A computer readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
