Service deployment method and device, electronic equipment and readable storage medium
By caching service image files in advance in the server cluster, the problem of low deployment efficiency is solved, rapid deployment and efficient service invocation are achieved, and the high concurrency requirements of AI basic services are met.
Patent Information
- Application Number
- CN202410803951.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-20
- Publication Date
- 2024-09-06
AI Technical Summary
When deploying services in a server cluster, the image file is large and the network is poor, resulting in long download times and inability to meet service invocation requirements. Especially when multiple AI basic services need to be started quickly, service deployment efficiency is low.
By using the preheating method to cache the image files of the service in advance on the machines of the server cluster, including all preheating, batch preheating, supplementary preheating and re-preheating, etc., it ensures that the image files are cached during deployment and avoids download delays. .
It improves the service deployment efficiency of the server cluster, meets the service calling requirements, avoids download delays caused by image file size and network problems, and ensures rapid deployment and efficient operation.
Smart Images

Figure CN118605897A
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer technology, and in particular, to a service deployment method, a service deployment device, an electronic device, and a computer-readable storage medium. Background Art
[0002] Currently, when deploying services on machines in a server cluster, it first takes a long time to download the service image file to the machine, and then the service can be deployed on the machine based on the image file. At this time, if the image file is particularly large and there are problems such as poor network, most of the time will be spent on downloading the service file to the machine, which cannot meet the service call requirements.
[0003] For example, a service can be an AI (Artificial Intelligence) basic service. The number of AI basic services started is positively correlated with the size of the QPS (Queries Per Second). The higher the QPS, the more AI basic services need to be deployed on the machine, and the higher the number of AI basic service calls in a short period of time. Therefore, it is necessary to quickly start multiple AI basic services in a short period of time to meet service call requirements. It can be seen that if a large amount of time is spent on downloading the service image file to the machine, the service deployment efficiency is low and the service call requirements cannot be met. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a service deployment method that, before deploying the service on a server cluster, caches the service image file on the server in advance using a pre-set preheating method, thereby improving the service deployment efficiency of the server cluster and meeting service call requirements. The specific technical solution is as follows:
[0005] In one aspect of the present invention, a service deployment method is provided, which is applied to a server cluster including a plurality of machines. The method comprises:
[0006] Obtaining an image file of a service; wherein the service is a process or program running in the machine, the image file includes the service and a file system on which the service depends when running, and the file system includes dependencies required for the service to be deployed and run in the machine;
[0007] Obtaining a preheating method for the image file in the server cluster;
[0008] The image file is cached in all the machines in the server cluster according to the preheating method, so that when the service is deployed in the machines, the service is deployed according to the cached image file.
[0009] In another aspect of the present invention, a service deployment device is provided, which is applied to a server cluster including a plurality of machines. The device includes:
[0010] An image file acquisition module, configured to acquire an image file of a service; wherein the service is a process or program running on the machine, the image file includes the service and a file system on which the service depends when running, and the file system includes dependencies required for the service to be deployed and run on the machine;
[0011] A preheating mode acquisition module, used to obtain a preheating mode of the image file in the server cluster;
[0012] An image file caching module is used to cache the image file to all the machines in the server cluster according to the preheating method, so that when deploying the service in the machine, the service is deployed according to the cached image file.
[0013] In another aspect of the present invention, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on the computer, the computer executes any of the above-mentioned service deployment methods.
[0014] In another aspect of the present invention, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned service deployment methods.
[0015] The service deployment method provided by the embodiment of the present invention caches the image file of the service in the machine of the server cluster in advance through a set preheating method before deploying the service in the machine. When the service needs to be deployed in the machine, the service deployment can be quickly completed according to the cached image file. Since it takes a long time to download the image file of the service to the machine only when the service needs to be deployed in the machine, the problem of not being able to download the image file to the machine in time due to large image file size, network conditions, etc. can be avoided, thereby improving the service deployment efficiency of the server cluster and meeting the service call requirements. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for describing the embodiments or the prior art.
[0017] Figure 1 A flowchart of the steps of a service deployment method provided in an embodiment of the present invention;
[0018] Figure 2A flowchart of global preheating, batch preheating and re-preheating provided in an embodiment of the present invention;
[0019] Figure 3 This is a flow chart of a supplementary preheating method provided in an embodiment of the present invention;
[0020] Figure 4 A structural block diagram of a service deployment device provided in an embodiment of the present invention;
[0021] Figure 5 This is a structural block diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0022] The technical solutions in the embodiments of the present invention will be described below with reference to the accompanying drawings in the embodiments of the present invention.
[0023] Reference Figure 1 , is a flowchart of the steps of a service deployment method provided in an embodiment of the present invention, which is applied to a server cluster including several machines, such as Figure 1 As shown, the method may specifically include the following steps:
[0024] Step 101: Obtain an image file of a service; wherein the service is a process or program running in the machine, the image file includes the service and a file system on which the service depends when running, and the file system includes dependencies required for the service to be deployed and run in the machine.
[0025] Services can include AI infrastructure services, database services, network services, and more. Services typically run on a machine as processes or programs. A server's image file contains the service and the file system it relies on for runtime. The file system contains the service program and other dependencies required for the service to be deployed and run on the machine. These dependencies include the system, libraries, resources, and configuration needed for the service. When deploying a service on a machine, the service can be installed based on the image file corresponding to the service.
[0026] In an embodiment of the present invention, before deploying a service in a machine of a server cluster, if a preheating instruction is received from R&D personnel or other objects, the image file of the service can be obtained from a specified location based on the preheating instruction, and the image file required for deploying the service can be cached in the machine in advance. In this way, when the service needs to be formally deployed in the machine, the cached image file can be used to quickly complete the service deployment, saving the time of downloading the image file to the machine, and avoiding the problem of not being able to download the image file to the machine in time due to large image file size, network conditions, etc., thereby ensuring the service deployment efficiency in the server cluster.
[0027] Step 102: Obtain a preheating method for the image file in the server cluster.
[0028] In the embodiment of the present invention, preheating refers to downloading the image file of the service to the cache of the machine in advance, and the preheating method refers to downloading the image file of the service to the cache of the machine in advance.
[0029] Among them, there are usually multiple preheating methods, or there can be only one. For example, the preheating method can at least include a full preheating method, a batch preheating method, a supplementary preheating method and a re-preheating method, wherein, when preheating for the first time, the full preheating method or the batch preheating method can be selected. Of course, in actual applications, other preheating methods can also be set according to needs, and the embodiment of the present invention does not need to be limited to this. When the server cluster in the embodiment of the present invention obtains the image file, it can obtain the description data pre-stored locally on the server cluster that describes the preheating method, or it can receive description data including the description of the preheating method sent by other objects such as R&D personnel.
[0030] Specifically, the full preheating method refers to preheating all machines in the server cluster and limiting the total preheating time; the batch preheating method refers to preheating the machines in the server cluster in batches according to the batch preheating quantity. During the execution of the batch preheating method, the batch preheating quantity of the next batch will be adjusted according to the preheating status of the image files of each batch, and the minimum quantity and preheating time of each batch will be limited; the supplementary preheating method refers to regularly preheating all newly added machines for the image files of each service according to the changes in the machines in the server cluster (changes may refer to the increase or decrease or suspension of machines in the server cluster, etc.), without considering whether the full preheating method or the batch preheating method is selected when the image file of the service is initially preheated to the machine; the re-preheating method refers to preheating all machines that failed to preheat at intervals according to the preheating method used during the initial preheating (such as the full preheating method or the batch preheating method) for the image file of a certain service.
[0031] In one embodiment of the present invention, for the image file of the service that is preheated for the first time, the preheating method can be a full preheating method or a batch preheating method. Subsequently, for the machines that have not been preheated, other preheating methods such as the full preheating method or the batch preheating method can be selected for preheating.
[0032] Step 103: cache the image file in all the machines in the server cluster according to the preheating method, so that when deploying the service in the machines, the service is deployed according to the cached image file.
[0033] After obtaining the preheating method for the image file in the machine, the image file can be cached to the machine in the server cluster according to the corresponding preheating method. When the service needs to be formally deployed in the machine, the cached image file in the machine can be used to quickly complete the service deployment.
[0034] It should be noted that, in the specific implementation of the embodiments of the present invention, the prerequisites are: 1. When caching image files, priority is given to obtaining available machines (such as non-faulty machines) from the remaining machines in the server cluster that have not cached image files; 2. The completion of caching the image file in the machine indicates that preheating is complete.
[0035] The above-mentioned service deployment method is applied to a server cluster comprising several machines. Before deploying a service on a machine in the server cluster, an image file of the service is obtained. The service is a process or program running on the machine. The image file contains the service and the file system required for the service to run. The file system contains the dependencies required for the service to be deployed and run on the machine. After determining the preheating method of the image file on the machine, the image file is cached in the machine according to the preheating method. In this way, when the service needs to be deployed on the machine, the service can be deployed based on the cached image file. The embodiment of the present invention caches the image file of the service in the machine in advance according to the preheating method before deploying the service on the machine in the server cluster. When the service needs to be deployed on the machine, the service can be quickly deployed based on the cached image file. Since the service image file is not downloaded to the machine until the service needs to be deployed, it takes a long time. Therefore, the problem of not being able to download the image file to the machine in time due to large image files, network conditions, etc. can be avoided, thereby improving the service deployment efficiency of the server cluster and meeting the service call requirements.
[0036] In one embodiment of the present invention, the preheating method has a corresponding total preheating time and a preheating ratio; and step 103 of caching the image file to all the machines in the server cluster according to the preheating method includes:
[0037] When the preheating mode is the full preheating mode, caching the image files in the machines in sequence;
[0038] If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, an alarm message is sent to a preset designated object;
[0039] If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, caching the image file in the machines is stopped.
[0040] In an embodiment of the present invention, when preheating a service image file for the first time, a full preheat mode can be selected. The full preheat mode caches the service image file on all machines in the server cluster. The full preheat mode has a corresponding total preheat time and preheat ratio. For example, for a server cluster with a total of 100 machines, the total preheat time of the full preheat mode can be set to 60 minutes, and the preheat ratio can be set to 90%. The server cluster can access the machine through the network and perform a file search operation to determine whether the machine has cached the image file, or the machine can automatically report to the server cluster after caching the image file. Of course, if the machine cannot be accessed through the network, the machine can be considered to have no cached image file.
[0041] Specifically, when the full preheating method is adopted, the image file is cached in the machines of the server cluster in sequence, and the time spent caching the image file in the server cluster is counted. If the image file is cached in all the machines in the server cluster within the total preheating time, it is considered that the preheating of the image file is completed; if the image file is not cached in all the machines in the server cluster within the total preheating time, the proportion of machines that have cached the image file to all the machines in the server cluster is further determined. If the proportion does not exceed the preheating proportion, it means that some problems may have occurred in the process of caching the image file. An alarm message can be sent to a preset designated object to remind the preset designated object to handle and solve the problem. Among them, the designated object can be a staff member who manages service deployment. If the proportion exceeds the preheating proportion, it can also be considered that the preheating of the image file is completed, and the caching of the image file in the machine can be stopped. The current number of machines that have cached the image file can meet the needs of rapid deployment of services.
[0042] It should be noted that the total preheating time and preheating ratio corresponding to all preheating methods can be adjusted and configured according to specific circumstances to ensure that the image file can be cached in the machines of the server cluster within a reasonable time.
[0043] In the above embodiment, when the preheating mode is the full preheating mode, the image files of the service can be cached in the machines of the server cluster in sequence. If the image files of the service in all machines are cached, it is considered that the preheating is completed. If the image files of the service in all machines have not been cached, if the preheating time is short, that is, it does not exceed the total preheating time, it can be temporarily not processed. If the preheating time exceeds the total preheating time and the number of machines with completed image files in the server cluster exceeds the preheating ratio, it can also be considered that the preheating is completed. If the preheating time exceeds the total preheating time but the number of machines with completed image files in the server cluster does not exceed the preheating ratio, manual intervention is prompted. It can be seen that the embodiment of the present invention can automatically determine whether the preheating status is completed based on the total preheating time and the preheating ratio, which can reduce manual intervention and monitoring.
[0044] In one embodiment of the present invention, the preheating method has a corresponding preheating time and preheating ratio; and step 103 of caching the image file to all the machines in the server cluster according to the preheating method includes:
[0045] When the preheating mode is a batch preheating mode, obtaining the batch preheating quantity;
[0046] Obtaining the preheated number of machines in batches from the machines in the server cluster that have not cached the image file as target machines, and caching the image file in the target machines in turn;
[0047] If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, or the batch preheating quantity of the current batch is not the specified quantity, then adjusting the batch preheating quantity, returning to the step of obtaining the batch preheating quantity of machines from the machines in the server cluster that have not cached the image file as target machines, and caching the image file in the target machines in sequence;
[0048] If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, or the number of the target machines in the current batch is the specified number, then stop caching the image file in the machine.
[0049] In an embodiment of the present invention, when initially preheating a service image file, a batch preheating method can be selected. The batch preheating method caches the service image file in batches on the machines in the server cluster. The batch preheating method has a corresponding preheating time and preheating ratio. For example, for a server cluster with a total of 100 machines, the preheating time of the batch preheating method can be set to 10 minutes per batch, and the preheating ratio can be set to 90%. In addition, the batch preheating method also has a corresponding batch preheating quantity. For example, the batch preheating quantity for the first batch is 10, the batch preheating quantity for the second batch is 10, the batch preheating quantity for the third batch is 5, and so on. The specified quantity can be 1 or another smaller value compared to the total number of machines in the server cluster. If the batch preheating quantity for the current batch is 1, it indicates that the server cluster has few machines that have not cached the image file, which can meet the requirements for rapid service deployment, and preheating is considered complete. Conversely, if the batch preheating quantity for the current batch is not 1, it indicates that the server cluster has many machines that have not cached the image file, which does not meet the requirements for rapid service deployment and requires further preheating.
[0050] Specifically, when adopting the batch preheating method, first, determine the batch preheating number corresponding to the current batch, and obtain the machines with the batch preheating number of the current batch from the server cluster that have not cached the image files as target machines. For example, assuming that the batch preheating number corresponding to the current batch is 10, then select 10 machines from the machines in the server cluster that have not cached the image files as target machines (they can be randomly selected or the target machines can be selected according to the machine numbering order, etc.), then, cache the image files in the current machines in turn, and start to count the time spent on caching the image files of the current batch. If the image files are cached in all target machines within the preheating time of the current batch, it is considered that the preheating of the image files of the current batch is completed. If the current batch is not the last batch, the next batch can be used as the current batch and the above steps for the current batch are repeated. If the current batch is the last batch, it can be considered that the preheating of the image files is completed.
[0051] If the image file is not cached to all target machines within the preheating time of the current batch, the proportion of machines that have cached the image file to all machines in the server cluster is further determined. If the proportion does not exceed the preheating ratio, or the number of batch preheatings for the current batch is not the specified number (the specified number can be 1), it means that the number of machines that have cached the image file cannot meet the demand for rapid deployment of services, and the preheating of the current batch can be ended. At this time, since there are fewer machines in the server cluster that have not cached the image file and can work normally, it is necessary to adjust the number of batch preheatings before preheating the next batch. For example, assuming there are a total of 100 machines in the server cluster, and the initial batch preheating number is set to 10, then each batch will obtain 10 machines from the server cluster as target machines for preheating. When preheating to a certain batch, the 81st to 90th machines in the server cluster are obtained for preheating. However, the batch exceeds the set preheating time and 10 machines cannot be successfully preheated from the remaining machines that have not been preheated. At this time, the proportion of preheated machines to all machines does not reach the preset proportion. In this case, the preheating of this batch can be ended and the next batch of machines can be preheated. Considering that 10 normally functioning machines may not be found among the remaining 20 machines that have not been preheated, the batch preheating number needs to be adjusted at this time. For example, it can be adjusted from 10 to 5, so that the next batch will obtain 5 machines from the server cluster as target machines for preheating.
[0052] If the image file is not cached to all target machines within the warm-up time of the current batch, the ratio of machines that have cached the image file to all machines in the server cluster is further determined. If this ratio exceeds the warm-up ratio, or the number of batch warm-up of the current batch is the specified number (the specified number can be 1), the image file can be stopped from being cached in the machine, indicating that the number of machines that have cached the image file currently meets the requirements of rapid deployment of the service, and the warm-up of the image file can be considered completed.
[0053] It should be noted that the preheating time and preheating ratio corresponding to the batch preheating method can be adjusted and configured according to the specific situation to ensure that the image file can be cached in the machines of the server cluster within a reasonable time.
[0054] In the above embodiment, when the preheating mode is a batch preheating mode, the image files of the service can be cached in batches in sequence to the machines in the server cluster. If the image files in all target machines of the current batch are completely cached and the current batch is the last batch, the preheating ends. If the image files in all target machines of the current batch are completely cached and the current batch is not the last batch, the next batch is preheated. If the image files in all target machines of the current batch are not completely cached, those with a short preheating time, that is, those that have not exceeded the preheating time, are temporarily not processed. Otherwise, if the number of target machines in the current batch is a specified number or the preheating time of the current batch exceeds the preheating time and the proportion of machines in the server cluster that have completely cached the image files exceeds a preset ratio, the preheating of the image files is considered to be complete. Otherwise, the number of target machines in the next batch is adjusted. It can be seen that the embodiment of the present invention can automatically determine whether the preheating of the machines in the server cluster is complete based on the preheating time and the preheating ratio, which can reduce manual intervention and monitoring. Moreover, by adaptively adjusting the number of batch preheatings in different batches, it can avoid a batch taking a long time to find machines with the corresponding batch preheating number that can normally cache the image files, thereby effectively controlling the overall preheating time of the machines in the server cluster.
[0055] In one embodiment of the present invention, adjusting the batch preheating quantity includes:
[0056] Counting the number of the machines in the server cluster that do not cache the image file to obtain a first candidate preheating number;
[0057] A second candidate preheating quantity is calculated based on the batch preheating quantity and a preset coefficient; the preset coefficient is a value less than 1 and greater than 0;
[0058] The smallest value between the first candidate preheating quantity and the second candidate preheating quantity is used as the adjusted batch preheating quantity.
[0059] Among them, the preset coefficient is a value preset according to actual needs. The preset coefficient is a value less than 1 and greater than 0, and the value range can be specifically [0.1-0.9]. For example, the preset coefficient can be 0.5. Therefore, if the batch preheating number and the preset coefficient are added to obtain the second candidate preheating number, it will be smaller than the batch preheating number.
[0060] In an embodiment of the present invention, in a batch preheating mode, if it is necessary to adjust the batch preheating quantity of the next batch, the number of machines that have not cached the image file can first be determined to obtain a first candidate preheating quantity. Then, the second candidate preheating quantity can be calculated based on the batch preheating quantity of the current batch and the preset coefficient. The first candidate preheating quantity and the second candidate preheating quantity are compared, and the smallest value is used as the batch preheating quantity of the next batch. For example, assuming that the preset coefficient is 0.5 and the batch preheating quantity of the current batch is 10, if there are 20 machines in the server cluster that have not cached the image file, then the first candidate preheating quantity is 10, and the second candidate preheating quantity is 0.5*10=5. Since 5 is less than 10, 5 can be used as the adjusted batch preheating quantity, and the adjusted batch preheating quantity is used as the batch preheating quantity of the next batch.
[0061] In the above embodiment, since the situation of not being able to cache the batch preheating number of machines normally occurred when caching the image file last time, the embodiment of the present invention takes the number of machines that have not cached the image file and the batch preheating number of the current batch as considerations for the batch preheating number of the next batch. Specifically, the minimum value is selected from the first candidate preheating number (the number of machines that have not cached the image file) and the second candidate preheating number (the batch preheating number multiplied by the preset coefficient) as the batch preheating number of the next batch. Since the minimum value is used as the adjusted batch preheating number, the number of machines that need to be preheated in the next batch will be relatively small, which can avoid the next batch spending a long time to find the corresponding batch preheating number of machines that can cache the image file normally, thereby effectively controlling the overall preheating time of the machines in the server cluster.
[0062] In one embodiment of the present invention, after caching the image file in all the machines in the server cluster according to the preheating method in step 103 so that the service is deployed in the machines according to the cached image file, the method further includes:
[0063] When a preset time interval is reached, determining a preheating method of the server cluster for the image file of the service;
[0064] The image file is cached in the machine again according to the preheating method.
[0065] The preset time interval may be set according to actual conditions, for example, it may be set to 1 hour, and this is not limited in the embodiment of the present invention.
[0066] In a specific implementation, when preheating the machines in a server cluster according to the full preheating method or the batch preheating method, after a certain period of time, some machines may not work normally due to failures or other reasons, resulting in the invalidation of the cached image files. In order to avoid affecting the deployment efficiency of the server cluster's services, the machines in the server cluster will be re-preheated after the preset time interval is reached.
[0067] In an embodiment of the present invention, if the server cluster previously used a full preheating method, it can continue to use the full preheating method for re-preheating. If the server cluster previously used a batch preheating method, it can continue to use the batch preheating method for re-preheating. The preheating method for re-preheating in a server cluster is the same as that described above regarding the full preheating method or the batch preheating method, and will not be described in detail here.
[0068] In the above embodiment, after preheating is completed in the server cluster, after a preset time interval, the preheating method previously used by the server cluster can be continued to be used to re-preheat all machines. In this way, the image files cached in the machines of the server cluster can always be guaranteed to be valid.
[0069] In one embodiment of the present invention, after step 103, in which the image file is cached in all the machines in the server cluster according to the preheating method, the method further includes:
[0070] Obtaining machine information of the machine in the server cluster; wherein the machine information at least includes whether there is a new machine in the server cluster;
[0071] When it is determined according to the machine information that a new machine exists in the server cluster, the image files are sequentially cached in the new machine.
[0072] The machine information includes at least whether there are new machines in the server cluster, and may also include whether there are machines that have been removed from the server cluster, i.e., machines that have gone offline and are no longer functioning properly. In an embodiment of the present invention, the server cluster can use a monitoring system to track the information of all machines in real time. The monitoring system can record information such as the online status of each machine, and thus generate machine information based on this information. For example, if the monitoring system initially monitors the online status of 10 machines, but later only monitors the online status of 9 machines, machine information can be generated indicating that there are machines that have been removed from the server cluster.
[0073] In an embodiment of the present invention, machine information for machines in a server cluster that have completed preheating of image files for each service is periodically obtained. If changes are detected in the machine information, for example, if the number of machines in the server cluster is reduced, no further processing is required. If new machines are added to the server cluster, preheating can be performed on the new machines, i.e., the image files of the services are sequentially cached in the new machines, thereby achieving supplementary preheating of the machines in the server cluster. In particular, the embodiment of the present invention can preheat all new machines, regardless of whether to preheat them in full or in batches.
[0074] In the above embodiment, by obtaining the machine information of all machines in the server cluster, it is determined whether there are new machines, so that the new machines can be preheated in time, ensuring that all machines in the server cluster are preheated as much as possible, and ensuring the deployment efficiency of the service.
[0075] In one embodiment of the present invention, after sequentially caching the image files in the newly added machines, the method further includes:
[0076] If the preset supplementary warm-up time is exceeded, the image files are stopped from being cached in the newly added machines in sequence.
[0077] The preset supplementary preheating time can be set according to actual conditions, for example, it can be set to 30 minutes, and the embodiment of the present invention does not need to be limited to this.
[0078] In a specific implementation, a newly added machine in a server cluster may not work properly due to a fault or other reasons, resulting in an inability to cache the image file. In order to avoid affecting the overall warm-up progress of the server cluster, when the image file is cached for the newly added machine, the time spent on caching the image file is counted. If the preset supplementary warm-up time is exceeded, the image file can be stopped from being cached to the newly added machine.
[0079] In the above embodiment, the newly added machines in the server cluster will be preheated. If the preheating time for the newly added machines exceeds the preset preheating time, the preheating can be terminated to control the preheating time of the entire machine in the server cluster.
[0080] In order to enable those skilled in the art to better understand the embodiments of the present invention, a specific example is used below for illustration.
[0081] In an embodiment of the present invention, a service image file caching solution is designed for a server cluster. The preheating methods of the embodiment of the present invention can mainly include a full preheating method and a batch preheating method. Because new machines are added to the server cluster from time to time, regular preheating is required. Because the image file cache may fail, re-preheating is required.
[0082] Reference Figure 2 , is a flow chart of global preheating, batch preheating and re-preheating provided in an embodiment of the present invention. The specific process is as follows:
[0083] For service images cached for the first time in a server cluster, a preheating method will be selected: full preheating or batch preheating. Subsequent preheating and re-preheating scheduled tasks will use different preheating strategies based on the initially selected preheating method. Preheating and re-preheating scheduled tasks will preheat each service image file sequentially.
[0084] The preheating scheduled task first obtains the image files to be preheated, and preheats them one by one, that is, caches the image files to the machine one by one.
[0085] For image files that use the full preheating method, if the image file is cached in all machines, the preheating is completed. If not all machines have completed the cache, the preheating time is short, that is, it does not exceed the total preheating time, and it is not processed temporarily. If the preheating time exceeds the total preheating time and the proportion of machines with completed cache exceeds the preheating ratio, the preheating is considered complete. If the preheating time exceeds the total preheating time but the proportion of machines with completed cache does not exceed the preheating ratio, an alarm is issued to prompt manual intervention.
[0086] For image files that are preheated in batches, machines with the same number of preheating batches are obtained from the server cluster in batches for preheating. If the image files in all machines in the current batch are cached and the current batch is the last batch, the preheating ends. If the image files in all machines in the current batch are cached and the current batch is not the last batch, the next batch is preheated. If the image files in all machines in the current batch are not completely replaced, the preheating time is short, that is, it does not exceed the preheating time of the current batch, and it can be temporarily ignored. Otherwise, if the number of machines in the current batch (that is, the number of preheating batches) is 1 or the preheating time exceeds the preheating time and the number of cached machines exceeds the preheating ratio, the preheating is considered complete. Otherwise, the number of preheating batches for the next batch is adjusted, and the preheating of the next batch is carried out.
[0087] The re-preheat scheduled task first iterates through pre-preheated image files, obtains image files that were last pre-preheated more than a preset time interval ago, and re-preheats them one by one. For image files that use the full pre-preheat method, the re-preheat scheduled task follows the same process as the pre-preheat scheduled task. For image files that use the batch pre-preheat method, the re-preheat scheduled task follows the same process as the pre-preheat scheduled task.
[0088] Reference Figure 3 , is a flow chart of a supplementary preheating provided in an embodiment of the present invention. The supplementary preheating scheduled task will regularly obtain the image files and machine information of the preheated machines. If the machines in the server cluster change (increase or decrease), for each image file, the machine information of the reduced machines is updated, and no supplementary preheating is required. For the newly added machines, supplementary preheating is required.
[0089] In an embodiment of the present invention, during supplementary preheating, all newly added machines are preheated for each image file. In this case, it is not necessary to select either the full preheating mode or the batch preheating mode. If all newly added machines have completed preheating, the preheating process ends. Otherwise, if the preheating time for all machines does not exceed the preset supplementary preheating time, no further action is required. If the preheating time for all machines exceeds the preset supplementary preheating time, the preheating process ends.
[0090] By applying the embodiments of the present invention, before deploying a service in a machine of a server cluster, the image file of the service is cached in the machine in advance through a set preheating method. When the service needs to be deployed in the machine, the deployment of the service can be quickly completed based on the cached image file. Since it takes a long time to download the image file of the service to the machine only when the service needs to be deployed in the machine, the problem of not being able to download the image file to the machine in time due to large image files, network conditions, etc. can be avoided, thereby improving the service deployment efficiency of the server cluster and meeting the service call requirements.
[0091] Reference Figure 4 , is a structural block diagram of a service deployment device provided in an embodiment of the present invention, which is applied to a server cluster including several machines, such as Figure 4 As shown, the device may specifically include the following modules:
[0092] An image file acquisition module 401 is configured to acquire an image file of a service, wherein the service is a process or program running on the machine, and the image file includes the service and a file system on which the service depends when running, wherein the file system includes dependencies required for the service to be deployed and run on the machine;
[0093] A preheating mode acquisition module 402 is used to acquire a preheating mode of the image file in the server cluster;
[0094] The image file caching module 403 is configured to cache the image file in all the machines in the server cluster according to the preheating method, so that when the service is deployed in the machines, the service is deployed according to the cached image file.
[0095] In one embodiment of the present invention, the preheating method has a corresponding total preheating time and a preheating ratio; the image file cache module 403 is used to:
[0096] When the preheating mode is the full preheating mode, caching the image files in the machines in sequence;
[0097] If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, an alarm message is sent to a preset designated object;
[0098] If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, caching the image file in the machines is stopped.
[0099] In one embodiment of the present invention, the preheating method has a corresponding preheating time and preheating ratio; the image file cache module 403 is used to:
[0100] When the preheating mode is a batch preheating mode, obtaining the batch preheating quantity;
[0101] Obtaining the preheated number of machines in batches from the machines in the server cluster that have not cached the image file as target machines, and caching the image file in the target machines in turn;
[0102] If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, or the batch preheating quantity of the current batch is not the specified quantity, then adjusting the batch preheating quantity, returning to the step of obtaining the batch preheating quantity of machines from the machines in the server cluster that have not cached the image file as target machines, and caching the image file in the target machines in sequence;
[0103] If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, or the number of the target machines in the current batch is the specified number, then stop caching the image file in the machine.
[0104] In one embodiment of the present invention, the image file cache module 403 is used to:
[0105] Counting the number of the machines in the server cluster that do not cache the image file to obtain a first candidate preheating number;
[0106] A second candidate preheating quantity is calculated based on the batch preheating quantity and a preset coefficient; the preset coefficient is a value less than 1 and greater than 0;
[0107] The smallest value between the first candidate preheating quantity and the second candidate preheating quantity is used as the adjusted batch preheating quantity.
[0108] In one embodiment of the present invention, the device further comprises: a reheating module, configured to:
[0109] When a preset time interval is reached, determining a preheating method of the server cluster for the image file of the service;
[0110] The image file is cached in the machine again according to the preheating method.
[0111] In one embodiment of the present invention, the device further comprises: a supplementary preheating module, configured to:
[0112] Obtaining machine information of the machine in the server cluster; wherein the machine information at least includes whether there is a new machine in the server cluster;
[0113] When it is determined according to the machine information that a new machine exists in the server cluster, the image files are sequentially cached in the new machine.
[0114] In one embodiment of the present invention, the supplementary preheating module is further used to:
[0115] If the preset supplementary warm-up time is exceeded, the image files are stopped from being cached in the newly added machines in sequence.
[0116] As for the above-mentioned device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0117] The embodiment of the present invention further provides an electronic device, such as Figure 5As shown, it includes a processor 501, a communication interface 502, a memory 503 and a communication bus 504, wherein the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0118] Memory 503, used for storing computer programs;
[0119] The processor 501 is configured to execute the program stored in the memory 503 by performing the following steps:
[0120] Obtaining an image file of a service; wherein the service is a process or program running in the machine, the image file includes the service and a file system on which the service depends when running, and the file system includes dependencies required for the service to be deployed and run in the machine;
[0121] Obtaining a preheating method for the image file in the server cluster;
[0122] The image file is cached in all the machines in the server cluster according to the preheating method, so that when the service is deployed in the machines, the service is deployed according to the cached image file.
[0123] The communication bus mentioned in the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is used in the figure, but this does not mean that there is only one bus or only one type of bus.
[0124] The communication interface is used for communication between the above terminal and other devices.
[0125] The memory may include random access memory (RAM) or non-volatile memory, such as at least one disk storage. Alternatively, the memory may be at least one storage device located away from the processor.
[0126] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, and discrete hardware components.
[0127] In another embodiment of the present invention, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions that, when executed on a computer, enable the computer to execute the service deployment method described in any one of the above embodiments.
[0128] In another embodiment of the present invention, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer is enabled to execute the service deployment method described in any one of the above embodiments.
[0129] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware, or any combination thereof. When implemented using software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more available media. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).
[0130] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0131] Each embodiment in this specification is described in a related manner. Similar parts between the various embodiments can be referred to in conjunction with each other. Each embodiment focuses on the differences between the other embodiments. In particular, the system embodiment is generally similar to the method embodiment, so the description is relatively simple. For related parts, refer to the description of the method embodiment.
[0132] The above description is only a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention are included in the scope of protection of the present invention.
Claims
1. A service deployment method, It is characterized in that Applied to a server cluster including several machines, the method comprises: Obtaining an image file of a service; wherein the service is a process or program running in the machine, the image file includes the service and a file system on which the service depends when running, and the file system includes dependencies required for the service to be deployed and run in the machine; Obtaining a preheating method of the image file in the server cluster; The image file is cached in all the machines in the server cluster according to the preheating method, so that when the service is deployed in the machine, the service is deployed according to the cached image file.
2. The method according to claim 1, It is characterized in that The preheating method has a corresponding total preheating time and a preheating ratio; caching the image file to all the machines in the server cluster according to the preheating method includes: When the preheating mode is a full preheating mode, caching the image files in the machines in sequence; If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, sending an alarm message to a preset designated object; If the time for caching the image file exceeds the total preheating time and the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, caching the image file in the machines is stopped.
3. The method according to claim 1, It is characterized in that The preheating method has a corresponding preheating time and a preheating ratio; and caching the image file to all the machines in the server cluster according to the preheating method includes: When the preheating method is a batch preheating method, obtaining the batch preheating quantity; Obtaining the preheated number of machines in batches from the machines in the server cluster that do not cache the image file as target machines, and caching the image file in the target machines in turn; If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all the machines in the server cluster does not exceed the preheating proportion, or the batch preheating quantity of the current batch is not the specified quantity, then adjusting the batch preheating quantity, returning to the step of obtaining the batch preheating quantity of machines from the machines in the server cluster that have not cached the image file as target machines, and caching the image file in the target machines in turn; If the time for caching the image file in the current batch exceeds the preheating time, the proportion of the machines that have cached the image file to all machines in the server cluster exceeds the preheating proportion, or the number of the target machines in the current batch is the specified number, stop caching the image file in the machine.
4. The method according to claim 3, It is characterized in that The adjusting the batch preheating quantity comprises: Counting the number of the machines in the server cluster that do not cache the image file, to obtain a first candidate preheating number; A second candidate preheating quantity is calculated according to the batch preheating quantity and a preset coefficient; the preset coefficient is a value less than 1 and greater than 0; The smallest value between the first candidate preheating quantity and the second candidate preheating quantity is used as the adjusted batch preheating quantity.
5. The method according to claim 2, 3 or 4, It is characterized in that After caching the image file in all the machines in the server cluster according to the preheating method so as to deploy the service in the machines according to the cached image file, the method further includes: When a preset time interval is reached, determining a preheating method of the server cluster for the image file of the service; The image file is cached in the machine again according to the preheating method.
6. The method according to claim 1, It is characterized in that After caching the image file in all the machines in the server cluster according to the preheating method, the method further includes: Obtaining machine information of the machine in the server cluster; wherein the machine information at least includes whether there is a newly added machine in the server cluster; When it is determined according to the machine information that there is a newly added machine in the server cluster, the image files are cached in the newly added machines in sequence.
7. The method according to claim 6, It is characterized in that After sequentially caching the image files in the newly added machines, the method further includes: If the preset supplementary warm-up time is exceeded, the image files are stopped from being cached sequentially to the newly added machines.
8. A service deployment device, It is characterized in that Applied to a server cluster including several machines, the device includes: An image file acquisition module, used to acquire an image file of a service; wherein the service is a process or program running in the machine, the image file includes the service and a file system required for the service to run, and the file system includes dependencies required for the service to be deployed and run in the machine; A preheating mode acquisition module, used to acquire a preheating mode of the image file in the server cluster; The image file caching module is used to cache the image file in all the machines in the server cluster according to the preheating method, so that when the service is deployed in the machine, the service is deployed according to the cached image file.
9. An electronic device, It is characterized in that It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 7 when executing a program stored in a memory.
10. A computer-readable storage medium having a computer program stored thereon, It is characterized in that When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
11. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
