Image update method, device, electronic device, and storage medium

By calculating the scoring results based on the image usage frequency in the mirror repository and cache high-frequency images to the cache server, the problem of low image hit rate and container creation is solved, and more efficient image pull and container creation is achieved.

CN115023693BActive Publication Date: 2025-08-22SHENZHEN HEYTAP TECHNOLOGY CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202080095159.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-05-29
Publication Date
2025-08-22
Estimated Expiration
2040-05-29

AI Technical Summary

Technical Problem

In the prior art, the mirror pull method cannot effectively determine whether the image stored in the cache server is a hotspot image, resulting in low image hit rate and container creation efficiency.

Method used

By obtaining the usage frequency of the mirror in the image storage area, calculating the scoring result based on the usage frequency, the image that meets the threshold score is moved to the cache server as the second image, and the image is obtained from the cache server when a new container is created is preferred.

Benefits of technology

Improves the hit rate of image pull and container creation efficiency, ensures that images with high frequency use are stored in the cache server, and improves the success rate of container creation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115023693B_ABST
    Figure CN115023693B_ABST
Patent Text Reader

Abstract

A mirror update method, device, electronic device and storage medium. The method includes: obtaining the usage frequency of the first mirror in the mirror storage area (S110); based on the usage frequency, obtaining the scoring result of the first mirror (S120); moving the corresponding first mirror whose scoring result meets the threshold score to the cache server as the second mirror; wherein, when a new container is created, the mirror corresponding to the newly created container is preferentially obtained from the cache server (S130). Through the above method, the first mirror whose scoring result meets the threshold score is cached in the cache server as the second mirror, so that the image with high usage frequency is stored in the cache server, so that when the corresponding image is preferentially pulled from the cache server when creating a container, it can make it more likely to successfully pull the required image from the cache server, thereby improving the hit rate of pulling the image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to an image update method, device, electronic device, and storage medium. Background Art

[0002] An image is an identical copy of a disk file stored on another disk. It is a special file system that provides the programs, libraries, resources, and configuration files required for container runtime. The image also contains some configuration parameters prepared for the container runtime (such as anonymous volumes, environment variables, and users). Therefore, when creating a container, you need to pull the image. However, the hit rate of pulling images when creating containers using these methods needs to be improved. Summary of the Invention

[0003] In view of the above problems, the present application proposes an image update method, device, electronic device and storage medium to improve the above problems.

[0004] In a first aspect, an embodiment of the present application provides an image update method, which is applied to an image warehouse, wherein the image warehouse includes an image storage area and a cache server, and the method includes: obtaining the usage frequency of a first image in the image storage area; based on the usage frequency, obtaining a scoring result of the first image; moving the first image whose corresponding scoring result meets a threshold score to the cache server as a second image; wherein, when a new container is created, the image corresponding to the newly created container is preferentially obtained from the cache server.

[0005] In a second aspect, an embodiment of the present application provides an image update device, comprising: a statistical module for obtaining the usage frequency of the first image in the image storage area; a calculation module for obtaining a scoring result of the first image based on the usage frequency; and an image distribution module for moving the first image whose corresponding scoring result meets a threshold score to the cache server as a second image; wherein, when a new container is created, the second image corresponding to the container is preferentially obtained from the cache server.

[0006] In a third aspect, an embodiment of the present application provides an electronic device comprising one or more processors and a memory; one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the above-mentioned method.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which program code is stored, wherein the above method is executed when the program code is run.

[0008] The embodiments of the present application provide a method, device, electronic device and storage medium for image updating. The usage frequency of the first image in the first storage area is obtained, and based on the usage frequency, a scoring result of the first image is obtained. If the scoring result meets the threshold score, the first image is moved to the cache server as the second image, wherein, when a new container is created, the second image corresponding to the container is first obtained from the cache server. Through the above method, the first image whose scoring result meets the threshold score is cached in the cache server as the second image, so that the image with high usage frequency is stored in the cache server, so that when the corresponding image is pulled from the cache server first when creating a container, the probability of successfully pulling the required image from the cache server can be increased, thereby improving the hit rate of pulling the image while also improving the efficiency of creating the container. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0010] Figure 1 A schematic diagram of the structure of an image repository proposed in one embodiment of the present application is shown;

[0011] Figure 2 A flowchart of an image update method proposed in another embodiment of the present application is shown;

[0012] Figure 3 A flowchart of an image update method proposed in another embodiment of the present application is shown;

[0013] Figure 4 A flowchart of an image update method proposed in another embodiment of the present application is shown;

[0014] Figure 5 The following is a structural block diagram of a mirror image update device proposed in an embodiment of the present application;

[0015] Figure 6 The following is a structural block diagram of a mirror image update device proposed in an embodiment of the present application;

[0016] Figure 7 A structural block diagram of an electronic device for executing the image update method according to an embodiment of the present application in real time of the present application;

[0017] Figure 8The present invention shows a storage unit in real time for storing or carrying program codes for implementing the resource acquisition method according to an embodiment of the present invention. DETAILED DESCRIPTION

[0018] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0019] An image is an identical copy of a disk file stored on another disk. It is a special file system that provides the programs, libraries, resources, and configuration files required for container runtime. The image also contains some configuration parameters prepared for the container runtime (such as anonymous volumes, environment variables, users, etc.). Therefore, when creating a container, you need to pull the image.

[0020] However, the inventors discovered in their research on related image pulling methods that when a user pulls an image from an image repository when creating a container, the user will first check whether the image to be pulled exists in the cache server, and then decide whether to cache the image based on whether the image to be pulled exists in the cache server. However, in the process of pulling an image to create a container, it is impossible to determine whether the pulled image is a hot image or whether it needs to be cached. As a result, it cannot be guaranteed that the images stored in the cache server are all frequently used images, resulting in the hit rate of pulling images when directly pulling images from the cache server to create a container still needs to be improved.

[0021] Therefore, the inventor proposed the method, device, electronic device and storage medium of obtaining the usage frequency of the first image in the first storage area in the present application, based on the usage frequency, obtaining the scoring result of the first image, and if the scoring result meets the threshold score, moving the first image to the cache server as the second image, wherein, when a new container is created, the second image corresponding to the container is first obtained from the cache server, and the first image whose scoring result meets the threshold score is cached in the cache server, so that the image with high usage frequency is stored in the cache server, so that when creating a container, the corresponding image will be pulled from the cache server first, and the required image can be successfully pulled from the cache server with a greater probability, thereby improving the hit rate of pulling the image while also improving the efficiency of container creation.

[0022] See also Figure 1, an embodiment of the present application provides an image warehouse 100, and the image warehouse 100 may include an image storage area 110 and a cache server 120. Among them, the image storage area 110 is an area for centrally storing image files. When the image warehouse 100 is closed, all images are stored in the image storage area 110; when the image warehouse 100 is started and initialized, all images stored in the image storage area 110 are scored, and according to the scoring results of all images, a part of the images in the image storage area 110 are cached in the cache server 120. When pulling an image to create a container, first check whether the pulled image exists in the cache server 120. If it exists, the image is directly pulled from the cache server 120 to create a container; if it does not exist, the image is pulled from the image storage area 110 to create a container. Among them, the image stored in the image storage area 110 can be called the first image, and the image stored in the cache server 120 can be called the second image.

[0023] See also Figure 2 An image update method provided in an embodiment of the present application is applied to an image warehouse, wherein the image warehouse includes an image storage area and a cache server, and the method includes:

[0024] Step S110: Obtain the usage frequency of the first image in the image storage area.

[0025] As a method, a user can pull a first image from an image storage area to create a container. In the process of pulling the first image to create a container, the number of times each first image is pulled can be counted as the usage frequency of the image. Furthermore, the usage frequency of each image in the image storage area can be obtained according to a variety of methods. As a method, the usage frequency of each first image in the image storage area from a certain time in the past to the current moment can be counted as the usage frequency of the first image in the image storage area, or the total usage frequency of each first image in the image storage area from the start of the image repository to the current moment can be counted as the usage frequency of the first image in the image storage area.

[0026] Optionally, the usage frequency of the first image in the image storage area can be stored in a specific file. When the usage frequency of the first image is needed, this specific file can be directly queried. As a method, when storing the usage frequency of the first image, the image identifier of the first image can also be stored in this specific file, and a corresponding relationship between the image identifier and the usage frequency can be established. Then, when the usage frequency of the first image is needed, the corresponding usage frequency can be obtained by searching the image identifier of the first image. The image identifier can include the image name and the image version number.

[0027] Step S120: obtaining a scoring result of the first image based on the usage frequency.

[0028] As one approach, a score threshold range can be pre-set, with different scores within the score threshold range corresponding to different usage frequencies, with higher scores corresponding to higher usage frequencies. The score threshold range can then be queried to determine the score corresponding to the usage frequency of the first image.

[0029] As another approach, based on the usage frequency of the first image in the image storage area obtained in the above-described manner, a computing model is obtained, the first image is scored, and a scoring result for the first image is obtained. The computing model may include multiple different computing models, and a corresponding computing model may be selected based on the currently created container to score the first image.

[0030] Furthermore, the calculation formula of the calculation model can be: the weight corresponding to the frequency of the mirror per unit time * the frequency of use of the mirror per unit time = scoring result. For example, the mirror is scored according to the frequency of use of a certain mirror in the last 5 hours, and the mirror can be scored according to the weight corresponding to the frequency of the mirror in these 5 unit times and the frequency of use. During initialization, the weights of the last 5 hours are all 0.2, so the calculation formula for the scoring result of the mirror is: (0.2*f1)+(0.2*f2)+(0.2*f3)+(0.2*f4)+(0.2*f5)=scoring result; wherein f1, f2, f3, f4 and f5 are the usage frequencies of the mirror per unit time.

[0031] Step S130: moving the first image whose scoring result meets the threshold score to the cache server as the second image; wherein, when a new container is created, the image corresponding to the newly created container is preferentially obtained from the cache server.

[0032] As a way, the threshold score can be set by the user as needed.

[0033] As another example, the threshold score is the score corresponding to the image with the lowest score in the cache server.

[0034] Through the above method, the scoring results corresponding to multiple first images can be obtained, and the scoring results of the multiple first images can be compared with the threshold score. If the scoring result of the image in the multiple first images meets the threshold score, the first image corresponding to the scoring result meeting the threshold score is cached in the cache server.

[0035] Furthermore, since the first images that meet the threshold score are images with high usage frequency, after caching the first images that meet the threshold score in the cache server, when creating a container, the image is pulled from the cache server first, which can increase the probability of pulling the image corresponding to the container from the cache server.

[0036] An embodiment of the present application provides a method for updating an image, which obtains the usage frequency of a first image in a first storage area, obtains a scoring result of the first image based on the usage frequency, and moves the first image to a cache server as a second image if the scoring result meets a threshold score, wherein when a new container is created, the second image corresponding to the container is first obtained from the cache server. Through the above method, the first image whose scoring result meets the threshold score is cached in the cache server as the second image, so that the image with a high usage frequency is stored in the cache server, so that when the corresponding image is pulled from the cache server first when creating a container, the probability of successfully pulling the required image from the cache server can be increased, thereby improving the hit rate of pulling the image while also improving the efficiency of creating the container.

[0037] See also Figure 3 An image update method provided in an embodiment of the present application is applied to an image warehouse, wherein the image warehouse includes an image storage area and a cache server, and the method includes:

[0038] Step S210: Obtain the usage frequency of the first image in the image storage area.

[0039] As a method, the usage frequency of the first image within a specified number of unit times may be obtained. For example, the usage frequency of the first image within a specified six unit times may be obtained.

[0040] Step S220: Obtain the weight of the usage frequency of the first image in multiple unit times.

[0041] As a method, multiple time periods can be pre-configured according to the frequency of container creation, and each time period corresponds to a different weight configuration method. The weights of the usage frequencies corresponding to the multiple unit times are obtained according to the weight configuration method corresponding to the time period at the moment of weight configuration, and the weight configuration method corresponding to each time period is different. Among them, the different weight configuration methods can be understood as the weights corresponding to the same unit time configured based on different weight configuration methods can be different. For example, the multiple time units include a first time unit, a second time unit, a third time unit, a fourth time unit, and a fifth time unit. Then, in one weight configuration method, the weight corresponding to the usage frequency in the first time unit is 0.2, and in another weight configuration method, the weight corresponding to the usage frequency in the first time unit is 0.4.

[0042] Exemplarily, the configured multiple time periods include a first time period, a second time period, and a third time period. If the current moment of weight configuration is within the third time period, the weight configuration method corresponding to the third time period is used to determine the weights of the usage frequencies corresponding to the multiple unit times.

[0043] Step S230: scoring the first image based on the weight and the usage frequencies corresponding to the plurality of unit times to obtain a scoring result.

[0044] Specifically, a corresponding calculation model may be obtained according to the weight and the usage frequencies of the first image in a plurality of unit times, and the first image may be scored to obtain a scoring result of the first image.

[0045] As a method, after scoring the first image based on the weight and the usage frequencies corresponding to the multiple unit times to obtain a scoring result, it also includes: obtaining multiple cache hit rates of the cache server within the multiple unit times; using a gradient descent algorithm to fit the multiple cache hit rates, and using the weight corresponding to the highest cache hit rate among the multiple cache hit rates as the weight of the multiple unit times.

[0046] Among them, the step of obtaining multiple cache hit rates of the cache server within the multiple unit times includes: obtaining the number of mirrors that are not hit by the cache server corresponding to the multiple unit times; obtaining the number of mirrors that are hit by the cache server corresponding to the multiple unit times; and calculating the multiple cache hit rates of the cache server within the multiple unit times based on the number of mirrors that are not hit and the number of mirrors that are hit by the cache server corresponding to the multiple unit times.

[0047] Specifically, when pulling an image to create a container, if the image is available in the cache server, it's called a hit. If the image is not in the cache server and needs to be pulled from the image storage area, it's called a miss. Each time an image is pulled to create a container, the cache server's cache hit rate is calculated. Furthermore, the cache server's cache hit rate can be calculated using the formula: cache hit rate = number of hits / (number of hits + number of misses).

[0048] Optionally, the multiple cache hit rates obtained can be iteratively solved using a gradient descent algorithm, and the weight corresponding to the highest cache hit rate among the multiple cache hit rates can be used as the weight of the multiple unit times. The weight can be calculated using a gradient descent algorithm. Furthermore, the cache hit rate of the cache server can be calculated once for each weight. If the cache hit rate corresponding to the weight is the highest, the weight is used as the weight for each time unit.

[0049] It's important to note that the gradient descent algorithm is an iterative method that can be used to solve least-squares problems (both linear and nonlinear). When solving model parameters for machine learning algorithms, or unconstrained optimization problems, the gradient descent algorithm is one of the most commonly used methods. Another common method is the least-squares method. When minimizing a loss function, the gradient descent algorithm can be used to iterate step by step to obtain the minimized loss function and model parameter values.

[0050] Furthermore, a preset update time is obtained, and the weights of the multiple unit times are updated according to the update time.

[0051] Specifically, the weight update time can be pre-set, and the weights of the multiple unit times can be updated according to the set update time. For example, the weights can be updated every three hours, and the weights can be updated once a container is created.

[0052] Step S240: Obtain the usage frequency of the second image in the cache server.

[0053] As a method, when pulling an image to create a container, the system first checks whether the image exists in the cache server. If the image exists, the system directly pulls the image from the cache server. If the image does not exist, the system pulls the image from the image storage area. Furthermore, the usage frequency of the image pulled from the cache server to create the container can be obtained.

[0054] Step S250: obtaining a scoring result of the second image based on the usage frequency of the second image.

[0055] As one approach, according to the obtained usage frequency of the second image, a calculation model is obtained to score the second image to obtain a scoring result of the second image.

[0056] Step S260: Determine the threshold score according to the scoring result of the second image.

[0057] As one approach, a cache server stores multiple second images, scores the multiple second images to obtain multiple scoring results, and uses the score corresponding to the second image with the lowest score among the multiple scoring results as the threshold score. For example, there are four second images in the cache server, namely, image 1, image 2, image 3, and image 4. Image 1 has a score of 8, image 2 and image 3 both have a score of 9, and image 4 has a score of 8.5. The scores of image 1, image 2, image 3, and image 4 are compared one by one, resulting in the following comparison result: 9 = 9 > 8.5 > 8, thereby determining the threshold score to be 8.

[0058] Step S270: moving the first image whose scoring result meets the threshold score to the cache server as the second image; wherein, when a new container is created, the image corresponding to the newly created container is preferentially obtained from the cache server.

[0059] It should be noted that the cache capacity of the cache server is not infinite, and there is also a cache upper limit. If there are multiple first images in the image storage area whose scoring results meet the threshold score, then the multiple first images need to be cached in the cache server. In the process of caching the multiple first images in the cache server, it may be impossible to cache all the first images that meet the threshold conditions in the cache server due to insufficient capacity of the cache server, and then the second image with the lowest score result in the cache server can be deleted. Specifically, if it is detected that the cache capacity of the cache server is insufficient, the second image with the lowest score result in the cache server will be deleted.

[0060] In the process of caching a first image that meets a threshold score into a cache server, if it is found that the cache server's storage capacity is insufficient, the scoring results of the second images in the cache server are compared, and the second images with scores in the last few digits in the cache server can be deleted, thereby ensuring that the images in the cache server are the most frequently used images. For example, the cache server currently stores six second images, and the scores of these six second images are 8, 7, 9, 10, 8.5, and 7.5, respectively. The scores of these six images are sorted. If there are eight first images that need to be stored in the cache server, but the cache server can only store six first images, the second images corresponding to the scores of 7 and 7.5 at the bottom of the cache server can be deleted.

[0061] Optionally, multiple methods can be used to delete the second image in the cache server. As one method, the cache capacity of the cache server can be detected before the first image whose scoring result meets the threshold score is moved to the cache server as the second image. If it is detected that the cache capacity of the cache server is insufficient, the second image in the cache server is deleted. Through the above method, the second image of the cache server is deleted before the first image is cached to the cache server, which can ensure that all first images that meet the threshold score can be cached in the cache server, thereby improving the cache hit rate of the cache server.

[0062] As another approach, the growth rate of the usage frequency corresponding to each first image in the image storage area can be pre-detected. If the growth rate of the usage frequency corresponding to one or more first images is detected to be very high, it can be determined that the one or more first images are likely to be moved to the cache server as second images. In this case, sufficient storage space can be reserved in the cache server in advance to cache the one or more first images. Therefore, the cache capacity of the cache server can be pre-detected. If it is detected that the cache capacity of the cache server is insufficient, the second images of the cache server can be deleted to ensure that sufficient storage space is reserved for caching the one or more first images. In this way, the cleaning of the second images in the cache server can be achieved more quickly and intelligently.

[0063] Optionally, when moving the corresponding first image whose scoring result meets the threshold score to the cache server as the second image, the cache server's cache capacity is checked each time a first image is cached. When insufficient cache capacity is detected, the second image with the lowest score is deleted based on the second image's scoring result. In this way, the first image whose scoring result meets the threshold score can be cached in the cache server in real time, achieving real-time updating of the second images in the cache server.

[0064] As another method, the second image with a short cache validity period may be deleted according to the cache validity period of the second image in the cache server.

[0065] Optionally, a number of first images may be cached as needed, and the corresponding second images cached in the cache servers may be deleted. Furthermore, these corresponding second images may be the second images ranked at the bottom of the scoring results in the cache servers. For example, if three first images need to be cached in the cache servers, the corresponding second images cached in the three cache servers may be deleted.

[0066] The embodiment of the present application provides a mirror update method, which obtains the usage frequency of a first mirror in a mirror storage area, obtains the weight of the usage frequency of the first mirror in multiple unit times, scores the first mirror based on the weight and the usage frequencies corresponding to the multiple unit times to obtain a scoring result, obtains the usage frequency of a second mirror in a cache server, obtains the scoring result of the second mirror based on the usage frequency of the second mirror, and then determines a threshold score according to the scoring result of the second mirror, and moves the first mirror whose corresponding scoring result meets the threshold score to the cache server as the second mirror. Through the above method, the scoring results of the mirrors in the mirror storage area are compared with the scoring results of the mirrors in the cache server, and the mirrors in the mirror storage area with a higher scoring result than the lowest scoring result in the cache server are cached in the cache server. Furthermore, when it is detected that the cache capacity of the cache server is insufficient, the mirror with the lowest scoring result in the cache server is deleted, ensuring that the mirrors in the cache server are mirrors with high usage frequencies, thereby improving the cache hit rate of the cache server.

[0067] See also Figure 4 An image update method provided in an embodiment of the present application is applied to an image warehouse, wherein the image warehouse includes an image storage area and a cache server, and the method includes:

[0068] Step S310: Obtain the historical usage frequency of the image.

[0069] As one approach, the image's historical usage frequency is the statistical usage frequency of the image before the image is pulled to create a new container. During initialization, the cache server has no images stored. Based on the acquired historical usage frequency of the first image, the first image with the highest usage frequency in the image storage area can be cached in the cache server as the second image.

[0070] Step S320: Based on the historical usage frequency of the image, determine whether the image is a hotspot image.

[0071] As one method, the step of determining whether the mirror is a hotspot mirror based on the historical usage frequency of the mirror includes: obtaining the historical usage frequency of the mirror in unit time, and if the historical usage frequency is greater than a preset threshold, determining that the mirror is a hotspot mirror.

[0072] Specifically, the preset threshold is a preset threshold usage frequency of a mirror. During initialization, the historical usage frequency of the first mirror in the mirror storage area is obtained, and the first mirror in the mirror storage area whose historical usage frequency is greater than the preset threshold is used as a hotspot mirror based on the historical usage frequency of the first mirror. For example, for example, if the preset threshold is set to 6 times, the historical usage frequencies of the 5 first mirrors in the mirror storage area are obtained to be 5 times, 6 times, 7 times, 9 times and 11 times respectively, and the historical usage frequencies of these 5 first mirrors are compared with the preset threshold of 6 times respectively, and the first mirror with a usage frequency greater than 6 times is determined as a hotspot mirror, and then the first mirrors corresponding to the usage times of 7 times, 9 times and 11 times can be determined as hotspot mirrors.

[0073] Step S330: If the image is a hotspot image, the hotspot image that meets the preset conditions is cached in the cache server as a second image.

[0074] As a method, if the mirror is a hotspot mirror, the step of caching the hotspot mirror that meets the preset conditions in the cache server as the second mirror includes: obtaining the scoring result of the hotspot mirror; sorting the hotspot mirror according to the scoring result of the hotspot mirror; and caching the hotspot mirror with a higher ranking in the cache server as the second mirror.

[0075] Specifically, if the image is a hotspot image, the image is scored based on its usage frequency to obtain a scoring result for the image. The higher the usage frequency of the image, the higher the image score. Furthermore, the number of times the image has been downloaded can be used as the usage frequency of the image. Through the above method, the scoring results of multiple hotspot images are obtained, and the scoring results of the multiple hotspot images are sorted, and the top-ranked images are cached in the cache server as the second image.

[0076] Among them, sorting the multiple hotspot mirrors according to the scoring results can include multiple sorting methods. As one method, the hotspot mirrors with the same scoring results can be randomly sorted in different adjacent rankings. For example, for example, there are 5 hotspot mirrors, namely Mirror A, Mirror B, Mirror C, Mirror D and Mirror E, where the scoring results of Mirror D and Mirror E are both 9 points, the scoring result of Mirror A is 8 points, the scoring result of Mirror C is 10 points, and the scoring result of Mirror B is 7 points. Then the sorting results of these 5 hotspot mirrors can be Mirror C>Mirror E>Mirror D>Mirror A>Mirror B, or Mirror C>Mirror D>Mirror B>Mirror A>Mirror B. As another method, the hotspot mirrors with the same scoring results can be ranked in the same rank, and the number of hotspot mirrors with the same ranking can be recorded. After the hotspot mirrors are sorted in the above method, the hotspot mirrors with the highest ranking can be cached in the cache server according to the sorting results.

[0077] Among them, the step of caching the top-ranked hotspot mirror into the cache server as the second mirror includes: obtaining the available cache capacity of the cache server; if the available cache capacity does not meet the target threshold capacity, obtaining the target hotspot mirror among the top-ranked hotspot mirrors; caching the target hotspot mirror into the cache server as the second mirror.

[0078] Specifically, for the first sorting method, when it is detected that the available cache capacity of the cache server does not meet the target threshold capacity, the target image in the top-ranked hot spot image can be directly cached in the cache server; for the second sorting method, when it is detected that the available cache capacity of the cache server does not meet the target threshold capacity, multiple target images with the same ranking are randomly stored in the cache server, or the target images can be stored in the cache server according to the size of the multiple target images.

[0079] Furthermore, the size of the target threshold capacity can be set arbitrarily, and can be set according to the cache capacity of the cache server.

[0080] Optionally, the target hotspot image can be determined in a variety of ways. As one approach, the hotspot image that ranks higher among the top-ranked hotspot images can be used as the target hotspot image. As another approach, the hotspot image with the highest execution order can be used as the target hotspot image based on the execution order of the mirrored services. Furthermore, the hotspot image with the longest cache validity period can be used as the target hotspot image based on the cache validity period of the hotspot image.

[0081] Step S340: Obtain the usage frequency of the first image in the image storage area.

[0082] Step S350: Based on the usage frequency, a scoring result of the first image is obtained.

[0083] Step S360: moving the first image whose scoring result meets the threshold score to the cache server as the second image; wherein, when a new container is created, the image corresponding to the newly created container is preferentially obtained from the cache server.

[0084] Step S370: When it is detected that a new container is created by pulling an image, it is determined whether the cache server contains the pulled image.

[0085] As a way, when you need to pull an image to create a container, you can first check whether a container creation request is received. If a container creation request is received, check whether the image exists in the cache server.

[0086] Step S380: Based on the judgment result, the number of images that are not hit and the number of images that are hit by the cache server in the current unit time are updated.

[0087] As one approach, when the judgment result is yes, the number of mirrors hit by the cache server in the current unit time is increased by one.

[0088] Specifically, if it is detected that the cache server stores the image, the number of images hit by the cache server in the current unit time is increased by one.

[0089] As another way, when the judgment result is no, the number of mirrors that the cache server does not hit in the current unit time is increased by one.

[0090] Specifically, if it is detected that the cache server does not store the image, the number of images that the cache server does not hit in the current unit time is increased by one.

[0091] The above method is used to obtain the number of images that the cache server does not hit and the number of images that it hits. Then, the cache hit rate of the cache server in the unit time can be calculated based on the obtained data.

[0092] An embodiment of the present application provides a mirror update method, which obtains the historical usage frequency of the mirror, and based on the historical usage frequency of the mirror, determines whether the mirror is a hotspot mirror. If the mirror is a hotspot mirror, the hotspot mirror that meets the preset conditions is cached in the cache server as the second mirror, and obtains the usage frequency of the first mirror in the mirror storage area. Based on the usage frequency, the scoring result of the first mirror is obtained, and the first mirror whose corresponding scoring result meets the threshold score is moved to the cache server as the second mirror, wherein, when a new container is created, the mirror corresponding to the newly created container is obtained from the cache server first. Furthermore, when it is detected that a new container is created by pulling an image, it is determined whether the cache server contains the pulled image, and based on the judgment result, the number of images that are not hit by the cache server and the number of images that are hit in the current unit time are updated. Through the above method, during initialization, the hotspot image with high usage frequency is cached in the cache server as the initial second image. When pulling the image to create a new container, it is first checked whether the pulled image exists in the cache server. The number of images that are not hit and the number of images that are hit are updated in real time based on the judgment result, thereby improving the accuracy of the cache hit rate of the cache server.

[0093] See also Figure 5 The present application provides an image update device 400, which includes:

[0094] The statistics module 410 is configured to obtain a usage frequency of the first image in the image storage area.

[0095] The calculation module 420 is configured to obtain a scoring result of the first image based on the usage frequency.

[0096] The calculation module 420 is also used to obtain multiple cache hit rates of the cache server in the multiple unit times; use the gradient descent algorithm to fit the multiple cache hit rates, and use the weight corresponding to the highest cache hit rate among the multiple cache hit rates as the weight of the multiple unit times.

[0097] Furthermore, the calculation module 420 is also used to obtain the number of mirrors that are not hit by the cache server corresponding to the multiple unit times; obtain the number of mirrors that are hit by the cache server corresponding to the multiple unit times; and calculate multiple cache hit rates of the cache server in the multiple unit times based on the number of mirrors that are not hit and the number of mirrors that are hit corresponding to the multiple unit times.

[0098] Optionally, the calculation module 420 is further configured to, upon detecting that a newly created container is created by pulling an image, determine whether the cache server contains the pulled image; and based on the determination result, update the number of images that are not hit by the cache server and the number of images that are hit by the cache server in the current unit time. If the determination result is yes, the number of images that are hit by the cache server in the current unit time is incremented by one; if the determination result is no, the number of images that are not hit by the cache server in the current unit time is incremented by one.

[0099] An image distribution module 430 is configured to move the first image whose scoring result satisfies the threshold score to the cache server as the second image;

[0100] When a new container is created, the second image corresponding to the container is obtained from the cache server first.

[0101] Furthermore, the image distribution module 430 is further configured to obtain a weight of the usage frequency of the first image in a plurality of unit times; and score the first image based on the weight and the usage frequency corresponding to the plurality of unit times to obtain a scoring result.

[0102] See also Figure 6 The present application provides an image update device 500, which includes:

[0103] The first image frequency acquisition module 510 is configured to acquire the usage frequency of the first image in the image storage area.

[0104] The first scoring result obtaining module 520 is configured to obtain a scoring result of the first image based on the usage frequency.

[0105] The second image frequency acquisition module 530 is configured to acquire the usage frequency of the second image in the cache server.

[0106] The second scoring result obtaining module 540 is configured to obtain a scoring result of the second image based on the usage frequency of the second image.

[0107] The threshold score determination module 550 is configured to determine the threshold score according to the scoring result of the second image.

[0108] The threshold score determination module 550 is further configured to use the score corresponding to the second image with the lowest score in the cache server as the threshold score.

[0109] The image update module 560 is used to move the first image whose scoring result meets the threshold score to the cache server as the second image; wherein, when a new container is created, the image corresponding to the newly created container is obtained from the cache server first.

[0110] Furthermore, the image update module 560 is also used to obtain the historical usage frequency of the image; based on the historical usage frequency of the image, it is determined whether the image is a hotspot image; if the image is a hotspot image, the hotspot image that meets the preset conditions is cached in the cache server as a second image.

[0111] Specifically, the image update acquisition module 560 is further used to obtain the scoring results of the hotspot images; sort the hotspot images according to the scoring results of the hotspot images; and cache the top-ranked hotspot images in the cache server as the second image.

[0112] Among them, caching the top-ranked hotspot mirror into the cache server as the second mirror includes: obtaining the available cache capacity of the cache server; if the available cache capacity does not meet the target threshold capacity, obtaining the target hotspot mirror among the top-ranked hotspot mirrors; caching the target hotspot mirror into the cache server as the second mirror.

[0113] It should be noted that the device embodiment in this application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0114] The following will be combined Figure 7 An electronic device provided by this application is described.

[0115] See also Figure 7 Based on the above-mentioned image update method and apparatus, the embodiments of the present application also provide another electronic device 200 that can execute the above-mentioned image update method. The electronic device 200 includes one or more (only one is shown in the figure) processors 102, a memory 104, and a network module 106 that are coupled to each other. The memory 104 stores a program that can execute the content of the above-mentioned embodiments, and the processor 102 can execute the program stored in the memory 104.

[0116] The processor 102 may include one or more processing cores. The processor 102 utilizes various interfaces and circuits to connect various components within the electronic device 200. It executes instructions, programs, code sets, or instruction sets stored in the memory 104, and accesses data stored in the memory 104 to perform various functions and process data within the electronic device 100. Optionally, the processor 102 may be implemented using at least one of the following hardware forms: a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 102 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 102 and may be implemented separately via a communication chip.

[0117] The memory 104 may include a random access memory (RAM) or a read-only memory (ROM). The memory 104 may be used to store instructions, programs, codes, code sets, or instruction sets. The memory 104 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data created by the terminal 100 during use (such as a phone book, audio and video data, chat history data), etc.

[0118] The network module 106 is used to receive and transmit electromagnetic waves, realize the mutual conversion between electromagnetic waves and electrical signals, and thus communicate with a communication network or other devices, such as communicating with an audio playback device. The network module 106 may include various existing circuit components for performing these functions, such as an antenna, a radio frequency transceiver, a digital signal processor, an encryption / decryption chip, a subscriber identity module (SIM) card, a memory, etc. The network module 106 can communicate with various networks such as the Internet, an enterprise intranet, a wireless network, or communicate with other devices via a wireless network. The above-mentioned wireless network may include a cellular telephone network, a wireless local area network, or a metropolitan area network. For example, the network module 106 can exchange information with a base station.

[0119] Please refer to Figure 8 , which shows a block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 800 stores program code, which can be called by a processor to execute the method described in the above method embodiment.

[0120] The computer-readable storage medium 800 can be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk, or a ROM. Alternatively, the computer-readable storage medium 800 includes a non-transitory computer-readable storage medium. The computer-readable storage medium 800 has storage space for program code 810 for executing any of the method steps described above. These program codes can be read from or written to one or more computer program products. The program code 810 can be compressed, for example, in a suitable form.

[0121] The present application provides a mirror update method, device, electronic device and storage medium, which obtains the usage frequency of the first image in the first storage area, obtains the scoring result of the first image based on the usage frequency, and if the scoring result meets the threshold score, moves the first image to the cache server as the second image, wherein, when a new container is created, the second image corresponding to the container is first obtained from the cache server. Through the above method, the first image whose scoring result meets the threshold score is cached in the cache server as the second image, so that the image with high usage frequency is stored in the cache server, so that when the corresponding image is pulled from the cache server first when creating a container, it can make the required image successfully pulled from the cache server with a greater probability, thereby improving the hit rate of pulling the image while also improving the efficiency of container creation.

[0122] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A mirror image update method, characterized in that: Applied to an image repository, the image repository includes an image storage area and a cache server, and the method includes: Obtaining a usage frequency of a first image in the image storage area; Based on the usage frequency, obtaining a scoring result of the first image; The obtaining, based on the usage frequency, a scoring result of the first image, includes: Obtaining weights of usage frequencies of the first image within multiple unit times, wherein the weights of the usage frequencies within the multiple unit times are determined based on a weight configuration method corresponding to a time period in which the weight configuration is to be performed, and each time period corresponds to a different weight configuration method. The different weight configuration methods are different weights corresponding to the same unit time configured based on different weight configuration methods; Scoring the first image based on the weight and the usage frequencies corresponding to the multiple unit times to obtain a scoring result; Obtaining multiple cache hit rates of the cache server within the multiple unit times; Fitting the multiple cache hit rates using a gradient descent algorithm, and using a weight corresponding to a highest cache hit rate among the multiple cache hit rates as the weights of the multiple unit times; Moving the first image corresponding to the scoring result that meets the threshold score to the cache server as the second image; When a new container is created, the image corresponding to the newly created container is obtained from the cache server first.

2. The method according to claim 1, characterized in that The method further comprises: A preset update time is obtained, and the weights of the multiple unit times are updated according to the update time.

3. The method according to claim 1, characterized in that The obtaining of multiple cache hit rates of the cache server within the multiple unit times includes: Obtaining the number of images that are not hit by the cache server corresponding to each of the multiple unit times; Obtaining the number of images hit by the cache server corresponding to each of the multiple unit times; Based on the number of images that are not hit and the number of images that are hit by the cache server corresponding to the multiple unit times, multiple cache hit rates of the cache server in the multiple unit times are calculated.

4. The method according to claim 1, wherein Before moving the first image corresponding to the scoring result that meets the threshold score to the cache server as the second image, the method further includes: Obtaining a usage frequency of the second image in the cache server; Obtaining a scoring result of the second image based on the usage frequency of the second image; The threshold score is determined according to the scoring result of the second image.

5. The method according to claim 4, characterized in that The step of determining the threshold score according to the scoring result of the second image includes: The score corresponding to the second image with the lowest score in the cache server is used as the threshold score.

6. The method according to claim 5, characterized in that The method further comprises: The second image with the lowest score in the cache server is deleted.

7. The method according to claim 6, characterized in that Deleting the second image with the lowest score in the cache server includes: If it is detected that the cache capacity of the cache server is insufficient, the second image with the lowest score in the cache server is deleted.

8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: When it is detected that a new container is created by pulling an image, it is determined whether the cache server contains the pulled image; According to the judgment result, the number of images that are not hit and the number of images that are hit by the cache server in the current unit time are updated.

9. The method according to claim 8, characterized in that The updating, based on the judgment result, of the number of images that are not hit by the cache server and the number of images that are hit by the cache server in the current unit time includes: When the judgment result is yes, the number of mirrors hit by the cache server in the current unit time is increased by one; When the judgment result is no, the number of images that the cache server does not hit in the current unit time is increased by one.

10. The method according to claim 4, characterized in that Before obtaining the usage frequency of the second image in the cache server, the method further includes: Get the historical usage frequency of the image; Based on the historical usage frequency of the image, determining whether the image is a hotspot image; If the image is a hotspot image, the hotspot image that meets the preset conditions is cached in the cache server as a second image.

11. The method according to claim 10, characterized in that The determining whether the image is a hotspot image based on the historical usage frequency of the image includes: A historical usage frequency of the image within a unit time is obtained, and if the historical usage frequency is greater than a preset threshold, the image is determined to be a hotspot image.

12. The method according to claim 11, characterized in that If the image is a hotspot image, caching the hotspot image that meets the preset conditions in the cache server as the second image includes: Obtaining a scoring result of the hotspot image; Sorting the hotspot images according to the scoring results of the hotspot images; The hotspot image with a high ranking is cached in the cache server as the second image.

13. The method according to claim 12, characterized in that The step of caching the top-ranked hotspot image in the cache server as the second image includes: Obtaining the available cache capacity of the cache server; If the available cache capacity does not meet the target threshold capacity, obtaining a target hotspot image from the top-ranked hotspot images; The target hotspot image is cached in the cache server as a second image.

14. A mirror image update device, characterized in that: The device comprises: A statistics module, configured to obtain a usage frequency of the first image in the image storage area; a calculation module, configured to obtain a scoring result of the first image based on the usage frequency; obtaining the scoring result of the first image based on the usage frequency includes: obtaining weights of the usage frequencies of the first image in multiple unit times, wherein the weights of the usage frequencies in the multiple unit times are determined based on a weight configuration method corresponding to a time period in which the weight configuration is to be performed, and each time period corresponds to a different weight configuration method, wherein the different weight configuration methods are different weights corresponding to the same unit time configured based on different weight configuration methods; scoring the first image based on the weight and the usage frequencies corresponding to the multiple unit times to obtain a scoring result; The calculation module is further configured to obtain multiple cache hit rates of the cache server within the multiple unit times; fit the multiple cache hit rates using a gradient descent algorithm, and use the weight corresponding to the highest cache hit rate among the multiple cache hit rates as the weight of the multiple unit times; An image distribution module is used to move the first image whose scoring result meets the threshold score to the cache server as the second image; When a new container is created, the second image corresponding to the container is obtained from the cache server first.

15. An electronic device, characterized in that: The method comprises one or more processors and a memory; one or more programs are stored in the memory and are configured to execute the method according to any one of claims 1 to 13 by the one or more processors.

16. A computer-readable storage medium, characterized in that The computer-readable storage medium stores program code, wherein when the program code is executed by a processor, the method according to any one of claims 1 to 13 is executed.

Citation Information

Patent Citations

  • Data caching method and apparatus for network disk client

    CN105988721A

  • Processing method and device and reading method and device for Docker image cache information

    CN106997392A