Management method, system, electronic device and storage medium of virtual cache server
By expanding the physical cache server through virtualization and using the consistent hash ring and ant colony algorithm, the problem of cache hit rate decrease when the server cluster is expanded is solved, and more efficient load balancing and cache hit rate are achieved.
Patent Information
- Application Number
- CN202011357481.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-11-27
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2040-11-27
AI Technical Summary
The existing server cluster expansion method will affect the cache hit rate when adding servers, and cannot effectively reduce the impact on the original servers.
Expand the physical cache server through virtualization, use the consistent hash ring and ant colony algorithm to calculate the hash value of the data to determine the target virtual cache server, store the data to be cached, and reduce the impact of the expanded server on the cache hit rate of the original server.
It reduces the impact on the cache hit rate when the server is expanded, and improves the load balancing of the expanded server and the hit rate of the distributed cache.
Smart Images

Figure CN112463379B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of data storage, and in particular to a management method and system for a virtual cache server, an electronic device and a storage medium. Background Art
[0002] When a large number of users visit a website at the same time, the web page may display a prompt message that the website service is unavailable or the web page service is busy. This is a manifestation of the website's poor scalability. The so-called "large" in large front-end can be understood as a large number of users and a large number of visits at the user level, and complex functions and many products at the functional level. At the technical level, it can be understood that the operation of the website requires a large number of servers.
[0003] In the process of website development, the most important means is to use server clusters. By continuously adding servers to the cluster to enhance the processing capacity of the cluster, this is the website's expansion strategy. There are currently two common expansion strategies: separate deployment of functions and deployment of the same function on multiple servers to provide services. The existing server cluster expansion method is to expand the cache server cluster when the website traffic is low, and then gradually preheat the cache by simulating requests to redistribute the data in the cache server. However, the above server expansion solution has requirements for business scenarios and cannot reduce the impact of the expansion server operation on the cache hit rate.
[0004] Therefore, how to reduce the impact of the extended server on the cache hit rate of the original server is a technical problem that those skilled in the art need to solve at present. Summary of the invention
[0005] The purpose of the present application is to provide a management method and system for a virtual cache server, an electronic device and a storage medium, which can reduce the impact of an extended server on the cache hit rate of an original server.
[0006] In order to solve the above technical problems, the present application provides a management method of a virtual cache server, and the management method of the virtual cache server includes:
[0007] Receive a server extension instruction, and virtualize an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers;
[0008] Selecting a server hash value bound to each of the extended virtual cache servers in the consistent hash ring to update hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one;
[0009] If a data cache instruction is received, the data hash value corresponding to the data to be cached is calculated according to the key value of the data to be cached;
[0010] Determine the target server hash value closest to the data hash value on the consistent hash ring according to the hash binding information, and set the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server;
[0011] The target virtual cache server is used to store the data to be cached.
[0012] Optionally, after setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, the method further includes:
[0013] Record the mapping relationship between the key value and the target server hash value, use the mapping relationship and the data to be cached as training samples, and input the training samples into an ant colony algorithm to obtain a mapping relationship table, so as to use the mapping relationship table to query the virtual cache server used to store data; wherein the mapping relationship table includes the mapping relationship between the key value of the data to be cached and the virtual cache server.
[0014] Optionally, after inputting the training sample into the ant colony algorithm to obtain a mapping relationship table, the method further includes:
[0015] If a new data cache instruction is received, the virtual cache server corresponding to the key value of the new data to be cached is queried according to the mapping relationship table, and the new data to be cached is stored using the virtual cache server corresponding to the key value of the new data to be cached.
[0016] Optionally, before receiving the server extension instruction, it also includes:
[0017] Determine an initial physical cache server, and virtualize the initial physical cache server into M initial virtual cache servers;
[0018] Constructing the consistent hash ring through a binary search tree, and selecting M hash values in the consistent hash ring as server hash values;
[0019] A binding relationship between each of the initial virtual cache servers and the server hash value is established, and the hash binding information is generated.
[0020] Optionally, after generating the hash binding information, the method further includes:
[0021] The mapping relationship between the key value of the data to be cached and the initial virtual cache server is determined based on the ant colony algorithm, and the data storage operation is performed using the mapping relationship between the key value of the data to be cached and the initial virtual cache server.
[0022] Optionally, selecting M hash values in the consistent hash ring as server hash values includes:
[0023] According to the constraint condition, M hash values are selected in the consistent hash ring as server hash values; wherein the constraint condition is that the interval distance between any two server hash values on the consistent hash ring is greater than a preset value.
[0024] Optionally, determining a target server hash value closest to the data hash value on the consistent hash ring according to the hash binding information includes:
[0025] According to the hash binding information, query the target server hash value closest to the data hash value in a clockwise or counterclockwise direction on the consistent hash ring.
[0026] The present application also provides a management system for a virtual cache server, the system comprising:
[0027] A server determination module, configured to receive a server extension instruction, and virtualize an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers;
[0028] A hash value binding module is used to select a server hash value bound to each of the extended virtual cache servers in a consistent hash ring so as to update hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one;
[0029] A data hash value calculation module, configured to calculate a data hash value corresponding to the data to be cached according to a key value of the data to be cached if a data cache instruction is received;
[0030] A server query module, configured to determine a target server hash value on the consistent hash ring that is closest to the data hash value according to the hash binding information, and set an extended virtual cache server or an initial virtual cache server corresponding to the target server hash value as a target virtual cache server;
[0031] The data storage module is used to use the target virtual cache server to store the data to be cached.
[0032] The present application also provides a storage medium on which a computer program is stored. When the computer program is executed, the steps of the management method of the virtual cache server are implemented.
[0033] The present application also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the virtual cache server management method when calling the computer program in the memory.
[0034] The present application provides a management method for a virtual cache server, comprising: receiving a server extension instruction, and virtualizing an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers; selecting a server hash value bound to each of the extended virtual cache servers in a consistent hash ring to update hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each initial virtual cache server and the server hash value, and the server hash value corresponds to the virtual cache server one-to-one; if a data cache instruction is received, calculating a data hash value corresponding to the data to be cached according to a key value of the data to be cached; determining a target server hash value on the consistent hash ring that is closest to the data hash value according to the hash binding information, and setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server; and using the target virtual cache server to store the data to be cached.
[0035] After receiving the server extension instruction, the present application virtualizes the extended physical cache server into N extended virtual cache servers, selects the server hash value bound to each of the extended virtual cache servers in the consistent hash ring, and then obtains the binding relationship between each extended virtual cache server and the initial virtual cache server and the server hash value. After receiving the data cache instruction, the present application calculates the data hash value corresponding to the data to be cached according to the key value of the data to be cached, and then selects the server hash value closest to the data hash value (that is, the absolute value of the hash difference is the smallest) in the consistent hash ring as the target server hash value, so as to use the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value to store the data to be cached. The above process selects the virtual cache server that stores the data to be cached according to the distance between the data hash value and the server hash value, which can reduce the impact of the extended server on the cache hit rate of the original server. The present application also provides a management system for a virtual cache server, an electronic device and a storage medium, which have the above-mentioned beneficial effects and are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0037] Figure 1 A flowchart of a method for managing a virtual cache server provided in an embodiment of the present application;
[0038] Figure 2 A flowchart of a cache server-based expansion method provided in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of the structure of a consistent hash ring provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of the structure of a management system of a virtual cache server provided in an embodiment of the present application. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0042] See below Figure 1 , Figure 1 A flowchart of a virtual cache server management method provided in an embodiment of the present application.
[0043] Specific steps may include:
[0044] S101: receiving a server extension instruction, and virtualizing an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers;
[0045] Among them, before receiving the server extension instruction, there may be any number of initial virtual cache servers in the cluster to perform data caching tasks. Specifically, the initial virtual cache server can perform data caching based on a consistent hash ring, and its implementation process is as follows: determine the initial physical cache server, and virtualize the initial physical cache server into M initial virtual cache servers; construct the consistent hash ring through a binary search tree, and select M hash values in the consistent hash ring as server hash values; establish a binding relationship between each of the initial virtual cache servers and the server hash value, and generate the hash binding information. If a data caching instruction is received, the data hash value corresponding to the data to be cached is calculated according to the key value of the data to be cached; determine the target server hash value on the consistent hash ring that is closest to the data hash value according to the hash binding information, and set the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, so that the target virtual cache server can be used to store the data to be cached. Furthermore, the mapping relationship between the key value and the server hash value determined within a preset time period (such as one hour) can be recorded, and the data hitting the cache server within this period can be provided as samples to the ant colony algorithm to obtain a mapping relationship table, so that the corresponding virtual cache server can be selected for data storage operations using the mapping relationship table.
[0046] After receiving the server expansion instruction, a new physical cache server needs to be added in the cluster. Specifically, the corresponding extended physical cache server can be determined according to the server expansion instruction, and the extended cache server can be virtualized into N extended virtual cache servers.
[0047] S102: Selecting a server hash value bound to each of the extended virtual cache servers in a consistent hash ring to update hash binding information;
[0048] The hash binding information includes the binding relationship between each of the extended virtual cache servers and the server hash value, and the binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one. Before this step, there may be an operation of binding the server hash value for the preset virtual cache server, so in this step, the hash value that has not been bound to the preset virtual cache server can be used as the server hash value to bind to the extended virtual cache server, so that each virtual cache server (including the extended virtual cache server and the preset virtual cache server) has its unique corresponding server hash value.
[0049] As a feasible implementation method, this step can select the server hash value bound to each of the extended virtual cache servers in the consistent hash ring according to the IP address of the extended virtual cache server. Specifically, the hash value corresponding to the IP address of the extended virtual cache server can be calculated, and the hash value closest to the hash corresponding to the IP address can be selected in the consistent hash ring as the server hash value.
[0050] Hash can map a set of keywords to a limited address range according to the set hash function H(key) and the conflict handling method, and use the image of the keyword in the address range as the storage location recorded in the table. This table is called a hash table or hash, and the resulting storage location is called a hash address or hash address. As a linear data structure, compared with tables and queues, hash tables have a faster search speed.
[0051] S103: If a data cache instruction is received, a data hash value corresponding to the data to be cached is calculated according to the key value of the data to be cached;
[0052] After receiving the data cache instruction, the data cache instruction can be parsed to determine the data to be cached, and then the key value of the data to be cached can be determined. For example, if the data to be cached is <'JINAN', DATA>, the key value is 'JINAN'. In this step, the key value of the data to be cached can be hashed to obtain the data hash value.
[0053] S104: determining a target server hash value on the consistent hash ring that is closest to the data hash value according to the hash binding information, and setting an extended virtual cache server or an initial virtual cache server corresponding to the target server hash value as a target virtual cache server;
[0054] This step is based on the fact that the data hash value corresponding to the data to be cached has been determined. The hash value closest to the data hash value on the consistent hash ring can be queried according to the hash binding information, and the hash value can be used as the target server hash value. Then, the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value can be set as the target virtual cache server.
[0055] As a feasible implementation, the target server hash value closest to the data hash value may be queried in the following manner: querying the target server hash value closest to the data hash value in a clockwise or counterclockwise direction on the consistent hash ring according to the hash binding information.
[0056] S105: Utilize the target virtual cache server to store the data to be cached.
[0057] The related operations of S103 to S105 may be executed whenever a new data cache instruction is received, and a corresponding virtual cache server is set for each data cache instruction.
[0058] After receiving the server expansion instruction, this embodiment virtualizes the expanded physical cache server into N extended virtual cache servers, selects the server hash value bound to each of the extended virtual cache servers in the consistent hash ring, and then obtains the binding relationship between each extended virtual cache server and the initial virtual cache server and the server hash value. After receiving the data cache instruction, this embodiment calculates the data hash value corresponding to the data to be cached according to the key value of the data to be cached, and then selects the server hash value closest to the data hash value (that is, the absolute value of the hash difference is the smallest) in the consistent hash ring as the target server hash value, so as to use the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value to store the data to be cached. The above process selects the virtual cache server that stores the data to be cached according to the distance between the data hash value and the server hash value, which can reduce the impact of the extended server on the cache hit rate of the original server.
[0059] As for Figure 1Further introduction to the corresponding embodiment, after setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, the mapping relationship between the key value and the target server hash value can also be recorded, the mapping relationship and the data to be cached are used as training samples, and the training samples are input into the ant colony algorithm to obtain a mapping relationship table, so as to use the mapping relationship table to query the virtual cache server for storing data; wherein, the mapping relationship table includes the mapping relationship between the key value of the data to be cached and the virtual cache server. After obtaining the mapping relationship table, if a new data cache request is received, the virtual cache server for storing data can be directly determined according to the mapping relationship table without using the consistent hash ring to find the virtual cache server. Specifically, after the training sample is input into the ant colony algorithm to obtain the mapping relationship table, if a new data cache instruction is received, the virtual cache server corresponding to the key value of the new data to be cached can be queried according to the mapping relationship table, and the new data to be cached can be stored using the virtual cache server corresponding to the key value of the new data to be cached.
[0060] As for Figure 1 Further introduction to the corresponding embodiment, before receiving the server extension instruction, it also includes the following operations: determining the initial physical cache server, and virtualizing the initial physical cache server into M initial virtual cache servers; constructing the consistent hash ring through a binary search tree, and selecting M hash values in the consistent hash ring as server hash values; establishing a binding relationship between each of the initial virtual cache servers and the server hash value, and generating the hash binding information.
[0061] Furthermore, after generating the hash binding information, the mapping relationship between the key value of the data to be cached and the initial virtual cache server can be determined based on the ant colony algorithm, and the data storage operation can be performed using the mapping relationship between the key value of the data to be cached and the initial virtual cache server.
[0062] Furthermore, the above embodiment can select M hash values from the consistent hash ring in the following manner: select M hash values in the consistent hash ring as server hash values according to a constraint condition; wherein the constraint condition is that the interval between any two server hash values on the consistent hash ring is greater than a preset value. As a feasible implementation method, M hash values evenly distributed in the consistent hash ring can be selected as server hash values.
[0063] The following is an example of an actual application to illustrate the process described in the above embodiment. Figure 2 , Figure 2 A flowchart of a cache server-based expansion method provided in an embodiment of the present application, Figure 2 The illustrated embodiment uses an ant colony algorithm and a consistent hash algorithm to achieve load balancing in the process of expanding servers and improve the hit rate of distributed cache in the process of expanding servers. The process of this embodiment may include: constructing a hash ring; placing virtual physical nodes in the hash ring; obtaining the shortest path for key access cache by using the ant colony algorithm; placing new virtual physical nodes in the hash ring, and recalculating the mapping relationship by using the ant colony algorithm.
[0064] Specifically, this embodiment implements a 2 32 The consistent hash ring connects the rightmost leaf node of the binary tree to the leftmost node. Virtualize 20 times the existing physical cache servers at a ratio of 1:20, and then assign a hash value to each virtual machine. Calculate the hash value of the data to be cached based on the key value, and search the virtual cache server node closest to the hash value clockwise on the hash ring. See Figure 3 , Figure 3 This is a schematic diagram of the structure of the consistent hash ring provided in the embodiment of the present application. Figure 3 The table includes the hash values corresponding to the four virtual cache servers node0, node1, node2 and node3. The virtual cache server node closest to this hash value in the clockwise direction is node1. The mapping relationship between the key value and the hash value is recorded within a preset time (such as one hour), and the data that hits the cache server during this period is provided as a sample to the ant colony algorithm to obtain a mapping relationship table. When a new node is added, the physical node is also virtualized as a ten-fold virtual cache server and placed in the hash ring. Ten virtual nodes placed in the ring can evenly affect ten adjacent virtual nodes. These virtual nodes correspond to ten physical servers, so that load balancing can be achieved. At the same time, after the new node is added, the ant colony algorithm is called again to iterate to form a new mapping relationship table to improve the hit rate of the shortest path of the key value. The ant colony algorithm is a probabilistic algorithm used to find optimized paths.
[0065] The above embodiment provides an expansion method based on a cache server. First, a hash ring is constructed. The cache server node is placed on the hash ring according to the hash value of the node name. Then, the hash value of the data to be cached is calculated according to the key value of the data to be cached. Then, the cache server node with the hash value of the key is searched clockwise on the hash ring to complete the hash mapping search from the key value to the server. The basic idea of this embodiment is as follows: virtualize each physical server into a group of virtual cache servers; construct an integer hash ring; put the hash value of the virtual server on the hash ring; when expansion is required, the newly added server is also virtualized into a group of servers and added to the hash ring; the key finds the virtual server node on the ring; the physical server information is obtained according to the virtual server node; based on the ant colony algorithm, the common key and the cached server are formed into a topological association relationship; when the new node is added, the updated topological relationship is formed based on the ant colony algorithm at regular intervals. The above embodiment improves the routing algorithm so that the newly added server does not affect the correct hit rate of most cache servers, and at the same time improves the hit rate of the server during the expansion process.
[0066] See also Figure 4 , Figure 4 A schematic diagram of the structure of a management system of a virtual cache server provided in an embodiment of the present application;
[0067] The system may include:
[0068] The server determination module 100 is used to receive a server extension instruction and virtualize the extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers;
[0069] The hash value binding module 200 is used to select a server hash value bound to each of the extended virtual cache servers in the consistent hash ring so as to update the hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one;
[0070] The data hash value calculation module 300 is used to calculate the data hash value corresponding to the data to be cached according to the key value of the data to be cached if a data cache instruction is received;
[0071] The server query module 400 is used to determine the target server hash value closest to the data hash value on the consistent hash ring according to the hash binding information, and set the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server;
[0072] The data storage module 500 is used to store the data to be cached by using the target virtual cache server.
[0073] After receiving the server expansion instruction, this embodiment virtualizes the expanded physical cache server into N extended virtual cache servers, selects the server hash value bound to each of the extended virtual cache servers in the consistent hash ring, and then obtains the binding relationship between each extended virtual cache server and the initial virtual cache server and the server hash value. After receiving the data cache instruction, this embodiment calculates the data hash value corresponding to the data to be cached according to the key value of the data to be cached, and then selects the server hash value closest to the data hash value (that is, the absolute value of the hash difference is the smallest) in the consistent hash ring as the target server hash value, so as to use the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value to store the data to be cached. The above process selects the virtual cache server that stores the data to be cached according to the distance between the data hash value and the server hash value, which can reduce the impact of the extended server on the cache hit rate of the original server.
[0074] Furthermore, it also includes:
[0075] A mapping relationship table generation module is used to record the mapping relationship between the key value and the target server hash value after setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, use the mapping relationship and the data to be cached as training samples, and input the training samples into an ant colony algorithm to obtain a mapping relationship table, so as to use the mapping relationship table to query the virtual cache server for storing data; wherein, the mapping relationship table includes the mapping relationship between the key value of the data to be cached and the virtual cache server.
[0076] Furthermore, it also includes:
[0077] The cache module is used to query the virtual cache server corresponding to the key value of the new data to be cached according to the mapping relationship table after the training sample is input into the ant colony algorithm to obtain the mapping relationship table, and use the virtual cache server corresponding to the key value of the new data to be cached to store the new data to be cached if a new data cache instruction is received.
[0078] Furthermore, it also includes:
[0079] The initial setting module is used to determine the initial physical cache server before receiving the server extension instruction, and virtualize the initial physical cache server into M initial virtual cache servers; it is also used to construct the consistent hash ring through a binary search tree, and select M hash values in the consistent hash ring as server hash values; it is also used to establish a binding relationship between each of the initial virtual cache servers and the server hash value, and generate the hash binding information.
[0080] Furthermore, it also includes:
[0081] The initial virtual cache server storage module is used to determine the mapping relationship between the key value of the data to be cached and the initial virtual cache server based on the ant colony algorithm after generating the hash binding information, and perform data storage operations using the mapping relationship between the key value of the data to be cached and the initial virtual cache server.
[0082] Furthermore, the process in which the initial setting module selects M hash values in the consistent hash ring as server hash values includes: selecting M hash values in the consistent hash ring as server hash values according to a constraint condition; wherein the constraint condition is that the interval distance between any two server hash values on the consistent hash ring is greater than a preset value.
[0083] Furthermore, the server query module includes:
[0084] The hash query unit is used to query the hash value of the target server closest to the data hash value in a clockwise or counterclockwise direction on the consistent hash ring according to the hash binding information.
[0085] Since the embodiments of the system part correspond to the embodiments of the method part, please refer to the description of the embodiments of the method part for the embodiments of the system part, which will not be repeated here.
[0086] The present application also provides a storage medium on which a computer program is stored, and when the computer program is executed, the steps provided in the above embodiment can be implemented. The storage medium may include: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0087] The present application also provides an electronic device, which may include a memory and a processor, wherein a computer program is stored in the memory, and when the processor calls the computer program in the memory, the steps provided in the above embodiment may be implemented. Of course, the electronic device may also include various network interfaces, power supplies and other components.
[0088] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the system disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description. It should be pointed out that for ordinary technicians in this technical field, without departing from the principles of this application, several improvements and modifications can be made to the present application, and these improvements and modifications also fall within the scope of protection of the claims of this application.
[0089] It should also be noted that, in this specification, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply 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 including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the statement "comprising a ..." does not exclude the presence of other identical elements in the process, method, article or device including the element.
Claims
1. A method for managing a virtual cache server, characterized in that: include: Receive a server extension instruction, and virtualize an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers; Selecting a server hash value bound to each of the extended virtual cache servers in the consistent hash ring to update hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one; If a data cache instruction is received, the data hash value corresponding to the data to be cached is calculated according to the key value of the data to be cached; Determine the target server hash value closest to the data hash value on the consistent hash ring according to the hash binding information, and set the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server; Using the target virtual cache server to store the data to be cached; After setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, the method further includes: Record the mapping relationship between the key value and the target server hash value, use the mapping relationship and the data to be cached as training samples, and input the training samples into an ant colony algorithm to obtain a mapping relationship table, so as to use the mapping relationship table to query the virtual cache server for storing data; wherein the mapping relationship table includes the mapping relationship between the key value of the data to be cached and the virtual cache server; Before receiving the server extension instruction, the following is also included: Determine an initial physical cache server, and virtualize the initial physical cache server into M initial virtual cache servers; Constructing the consistent hash ring through a binary search tree, and selecting M hash values in the consistent hash ring as server hash values; A binding relationship between each of the initial virtual cache servers and the server hash value is established, and the hash binding information is generated.
2. The method for managing a virtual cache server according to claim 1, characterized in that: After the training samples are input into the ant colony algorithm to obtain a mapping relationship table, the method further includes: If a new data cache instruction is received, the virtual cache server corresponding to the key value of the new data to be cached is queried according to the mapping relationship table, and the new data to be cached is stored using the virtual cache server corresponding to the key value of the new data to be cached.
3. The method for managing a virtual cache server according to claim 1, characterized in that: After generating the hash binding information, the following steps are also included: The mapping relationship between the key value of the data to be cached and the initial virtual cache server is determined based on the ant colony algorithm, and the data storage operation is performed using the mapping relationship between the key value of the data to be cached and the initial virtual cache server.
4. The method for managing a virtual cache server according to claim 1, characterized in that: Selecting M hash values in the consistent hash ring as server hash values includes: According to the constraint condition, M hash values are selected in the consistent hash ring as server hash values; wherein the constraint condition is that the interval distance between any two server hash values on the consistent hash ring is greater than a preset value.
5. The method for managing a virtual cache server according to any one of claims 1 to 4, characterized in that: Determining a target server hash value closest to the data hash value on the consistent hash ring according to the hash binding information includes: According to the hash binding information, query the target server hash value closest to the data hash value in a clockwise or counterclockwise direction on the consistent hash ring.
6. A management system for a virtual cache server, characterized in that: include: A server determination module, configured to receive a server extension instruction, and virtualize an extended physical cache server corresponding to the server extension instruction into N extended virtual cache servers; A hash value binding module is used to select a server hash value bound to each of the extended virtual cache servers in a consistent hash ring so as to update hash binding information; wherein the hash binding information includes a binding relationship between each of the extended virtual cache servers and the server hash value, and a binding relationship between each of the initial virtual cache servers and the server hash value, and the server hash value corresponds to the virtual cache server one by one; A data hash value calculation module, configured to calculate a data hash value corresponding to the data to be cached according to a key value of the data to be cached if a data cache instruction is received; A server query module, configured to determine a target server hash value on the consistent hash ring that is closest to the data hash value according to the hash binding information, and set an extended virtual cache server or an initial virtual cache server corresponding to the target server hash value as a target virtual cache server; A data storage module, used for storing the data to be cached by using the target virtual cache server; A mapping relationship table generation module is used to record the mapping relationship between the key value and the target server hash value after setting the extended virtual cache server or the initial virtual cache server corresponding to the target server hash value as the target virtual cache server, use the mapping relationship and the data to be cached as training samples, and input the training samples into the ant colony algorithm to obtain a mapping relationship table, so as to use the mapping relationship table to query the virtual cache server for storing data; wherein the mapping relationship table includes the mapping relationship between the key value of the data to be cached and the virtual cache server; The initial setting module is used to determine the initial physical cache server before receiving the server extension instruction, and virtualize the initial physical cache server into M initial virtual cache servers; it is also used to construct the consistent hash ring through a binary search tree, and select M hash values in the consistent hash ring as server hash values; it is also used to establish a binding relationship between each of the initial virtual cache servers and the server hash value, and generate the hash binding information.
7. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the virtual cache server management method according to any one of claims 1 to 5 when calling the computer program in the memory.
8. A storage medium, characterized in that: The storage medium stores computer executable instructions, and when the computer executable instructions are loaded and executed by the processor, the steps of the virtual cache server management method as described in any one of claims 1 to 5 are implemented.
