Disclosure of Invention
In view of this, embodiments of the present specification provide a data distribution method and an access method based on cache cluster routing. One or more embodiments of the present disclosure also relate to a data distribution apparatus, an access apparatus, a computing device, and a computer-readable storage medium based on cache cluster routing, so as to solve technical deficiencies in the prior art.
According to a first aspect of the embodiments of the present specification, there is provided a data distribution method based on cache cluster routing, which is applied to a distribution server, where the cache cluster is divided into multiple groups of cache clusters according to usage scenarios, and the distribution server establishes, in advance for each group of cache clusters, a hash ring based on IP addresses of cache machines in the cache clusters by using a routing tool according to a hash consistency algorithm, and the method includes: when data is updated, determining a cache cluster group identifier corresponding to the target unique identifier of the data; inquiring a hash ring of a corresponding cache cluster according to a cache cluster group identification corresponding to the target unique identification of the data; calculating the IP address mapped by the target unique identifier of the data in the hash ring according to the hash consistency algorithm by using the routing tool; and distributing the data to the IP address mapped by the target unique identification of the data for caching.
Optionally, the method further comprises: receiving heartbeat messages sent by each cache machine, wherein the heartbeat messages are sent by each cache machine according to the IP address of the distribution server acquired from a registration center; obtaining the IP addresses of the cache machines from the heartbeat message; and when the corresponding cache machine is determined to be offline or online according to the heartbeat message, reestablishing the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located by using a routing tool according to a hash consistency algorithm.
Optionally, the method further comprises: and synchronizing the hash ring to a registration center so that the data request end can determine the IP address of the cache machine where the data to be requested is located according to the hash ring acquired from the registration center.
According to a second aspect of the embodiments of the present specification, there is provided a data distribution apparatus based on cache cluster routing, configured in a distribution server, where the cache cluster is divided into multiple groups of cache clusters according to usage scenarios, and the distribution server establishes, in advance for each group of cache cluster, a hash ring based on IP addresses of cache machines in the cache cluster according to a hash consistency algorithm by using a routing tool, respectively, where the apparatus includes: the group determination module is configured to determine a cache cluster group identifier corresponding to the target unique identifier of the data when the data is updated. And the ring query module is configured to query the hash ring of the corresponding cache cluster according to the cache cluster group identifier corresponding to the target unique identifier of the data. A distribution calculation module configured to calculate, using the routing tool, an IP address to which the target unique identifier of the data is mapped in the hash ring according to the hash consistency algorithm. A data distribution module configured to distribute the data to an IP address to which the target unique identifier of the data is mapped for caching.
Optionally, the method further comprises: and the heartbeat receiving module is configured to receive heartbeat messages sent by the cache machines, wherein the heartbeat messages are sent by the cache machines according to the IP addresses of the distribution servers acquired from the registration center. An IP obtaining module configured to obtain the IP addresses of the cache machines from the heartbeat message. And the ring updating module is configured to reestablish the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located according to the hash consistency algorithm by using a routing tool when the corresponding cache machine is determined to be offline or online according to the heartbeat message.
Optionally, the method further comprises: and the ring synchronization module is configured to synchronize the hash ring to a registration center so that the data request end determines the IP address of the cache machine where the data to be requested is located according to the hash ring acquired from the registration center.
According to a third aspect of the embodiments of the present specification, there is provided a data access method based on cache cluster routing, which is applied to a data request end, where the cache cluster is divided into multiple groups of cache clusters according to usage scenarios, and a distribution server establishes, in advance for each group of cache clusters, a hash ring based on IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool, respectively, where the method includes: acquiring a hash ring of a corresponding cache cluster according to a cache cluster group identifier corresponding to the target unique identifier of the data to be requested; calculating the IP address mapped by the target unique identifier of the data to be requested in the hash ring by using a routing tool according to the hash consistency algorithm; and sending access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested.
Optionally, the obtaining, according to the cache cluster group identifier corresponding to the target unique identifier of the data to be requested, the hash ring of the corresponding cache cluster includes: and obtaining the hash ring corresponding to the cache set group identification corresponding to the target unique identification of the data to be requested from the registration center.
According to a fourth aspect of the embodiments of the present specification, there is provided a data access apparatus based on cache cluster routing, configured at a data request end, where the cache cluster is divided into multiple groups of cache clusters according to usage scenarios, and a distribution server establishes, in advance for each group of cache clusters, a hash ring based on IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool, respectively, where the apparatus includes: and the ring acquisition module is configured to acquire the hash ring of the corresponding cache cluster according to the cache cluster group identifier corresponding to the target unique identifier of the data to be requested. And the mapping calculation module is configured to calculate the IP address mapped to the target unique identifier of the data to be requested in the hash ring according to the hash consistency algorithm by using a routing tool. And the data access module is configured to send out the access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested.
Optionally, the ring obtaining module is configured to obtain, from a registry, a hash ring corresponding to a cache set group identifier corresponding to the target unique identifier of the data to be requested, where the hash ring is synchronized to the registry by the distribution server.
According to a fifth aspect of embodiments herein, there is provided a computing device comprising: a memory and a processor; the memory is to store computer-executable instructions, and the processor is to execute the computer-executable instructions to: when data is updated, determining a cache cluster group identifier corresponding to the target unique identifier of the data; inquiring a hash ring of a corresponding cache cluster according to a cache cluster group identification corresponding to the target unique identification of the data; calculating the IP address mapped by the target unique identifier of the data in the hash ring according to the hash consistency algorithm by using the routing tool; distributing the data to an IP address mapped by the target unique identifier of the data for caching; the distribution server establishes a hash ring based on the IP addresses of the cache machines in the cache cluster according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance.
According to a sixth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, implement the steps of any one of the cache cluster routing-based data distribution methods.
According to a seventh aspect of embodiments herein, there is provided a computing device comprising: a memory and a processor; the memory is to store computer-executable instructions, and the processor is to execute the computer-executable instructions to: acquiring a hash ring of a corresponding cache cluster according to a cache cluster group identifier corresponding to the target unique identifier of the data to be requested; calculating the IP address mapped by the target unique identifier of the data to be requested in the hash ring by using a routing tool according to the hash consistency algorithm; sending access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested; the distribution server establishes a hash ring based on the IP addresses of the cache machines in the cache cluster according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance.
According to an eighth aspect of embodiments herein, there is provided a computer-readable storage medium storing computer-executable instructions that, when executed by a processor, perform any one of the steps of the cache cluster routing-based data access method.
In one aspect of the present specification, a data distribution method based on cache cluster routing is implemented, which is applied to a distribution server, and since updated data may be of various types, data labels are different, and corresponding usage scenarios are different, the cache cluster is divided into a plurality of groups of cache clusters according to usage scenarios, and the number and resources of cache machines in each group are configured according to resources required by the scenarios, so that resource utilization rate can be improved, and the distribution server establishes hash rings based on IP addresses of cache machines in the cache clusters in advance for each group of cache clusters by using a routing tool according to a hash consistency algorithm, determines a cache cluster group identifier corresponding to a target unique identifier of the data when the data is updated, queries the hash ring of the corresponding cache cluster according to the cache cluster group identifier, and uses the routing tool according to the hash consistency algorithm, the IP address mapped by the target unique identifier of the data in the hash ring is calculated, and the data is equivalently sent to a fixedly corresponding cache machine according to the target use scene, so that the data redundancy is low, the utilization rate of cache resources is further improved, and the aim of enhancing the capacity capability is fulfilled;
in another aspect of the present specification, a data access method based on cache cluster routing is implemented, where the data access method is applied to a data request end, and a hash ring of a corresponding cache cluster is obtained according to a cache cluster group identifier corresponding to a target unique identifier of data to be requested, and a routing tool is used to calculate, according to a hash consistency algorithm, an IP address to which the target unique identifier of the data to be requested is mapped in the hash ring, and send an access to the data to be requested to a cache machine of the IP address to which the target unique identifier of the data to be requested is mapped, so that the data can be quickly mapped to a fixed IP address by the hash consistency algorithm based on the target unique identifier, and thus, based on mapping rapidity and mapping consistency, rapidity and correctness of routing can be ensured, and access capability is high.
Detailed Description
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present description. This description may be embodied in many different forms and should not be construed as limited to the embodiments set forth herein, as those skilled in the art will be able to make and use the present disclosure without departing from the spirit and scope of the present disclosure.
The terminology used in the description of the one or more embodiments is for the purpose of describing the particular embodiments only and is not intended to be limiting of the description of the one or more embodiments. As used in one or more embodiments of the present specification and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used in one or more embodiments of the present specification refers to and encompasses any and all possible combinations of one or more of the associated listed items.
It will be understood that, although the terms first, second, etc. may be used herein in one or more embodiments to describe various information, these information should not be limited by these terms. These terms are only used to distinguish one type of information from another. For example, a first can also be referred to as a second and, similarly, a second can also be referred to as a first without departing from the scope of one or more embodiments of the present description. The word "if" as used herein may be interpreted as "at … …" or "when … …" or "in response to a determination", depending on the context.
First, the noun terms to which one or more embodiments of the present specification relate are explained.
The target is as follows: are objects to which rights and obligations of both parties of the contracting party are commonly directed, e.g. investment targets such as: stocks, funds, bonds, foreign exchanges, etc.
Caching the cluster: is a cluster of computers that provides caching services externally.
Hash consistency algorithm: is a distributed hash implementation algorithm proposed by the institute of technology and technology of the Massachusetts in 1997. The value returned by the hash function may be represented as a hash ring.
In order to make the embodiments of the present specification easier to understand, a system architecture of a cache cluster related to one or more embodiments of the present specification is exemplarily described below with reference to fig. 1. Fig. 1 is a schematic diagram of a system architecture of a cache cluster according to one or more embodiments of the present description. As shown in fig. 1, the system may include: the system comprises a data request terminal 110, a distribution server 120, a registration center 130 and a plurality of groups of cache clusters 140, wherein each group of cache clusters comprises a plurality of cache machines 150.
The data request end 110 may be configured to issue an access to the cache machine 150 by applying the cache cluster routing-based data distribution method according to one or more embodiments of the present specification.
The distribution server 120 may be configured to distribute the data to the cache machine 150 when the data is updated by applying the data distribution method based on cache cluster routing according to one or more embodiments of the present specification.
The registry 130 may be configured to store the IP addresses of the distribution servers, and provide the IP addresses of the distribution servers to the caching machine 150 according to a request of the caching machine 150.
The caching machine 150 may be configured to receive data to be cached from the distribution server 120, cache the data to be cached, and send a heartbeat message to the distribution server 120 according to the IP address of the distribution server 120.
In the present specification, a data distribution method and an access method based on cache cluster routing are provided, and the present specification relates to a data distribution apparatus and a data access apparatus based on cache cluster routing, a computing device, and a computer readable storage medium, which are described in detail in the following embodiments one by one.
Fig. 2 is a flowchart illustrating a data distribution method based on cache cluster routing according to an embodiment of the present disclosure. The method is applied to a distribution server, the cache clusters are divided into a plurality of groups of cache clusters according to use scenes, and the distribution server establishes a hash ring based on the IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance. The method includes steps 202 through 208.
Step 202: and when the data is updated, determining the cache cluster group identification corresponding to the target unique identification of the data.
For example, index data indicating the magnitude of fluctuation of an object such as a stock, fund, bond, foreign exchange, etc., a time series curve for predicting the magnitude of fluctuation, etc. When data is updated, a corresponding cache set group may be determined. For example, in one implementation, the cache clusters are divided into index data groups and time series curve groups. The target unique identification of the data belonging to the index data class corresponds to the index data group identification, and the target unique identification of the data belonging to the time series curve class corresponds to the time series curve group identification.
Step 204: and inquiring the hash ring of the corresponding cache cluster according to the cache cluster group identification corresponding to the target unique identification of the data.
Step 206: and calculating the IP address mapped by the target unique identifier of the data in the hash ring according to the hash consistency algorithm by using the routing tool.
Step 208: and distributing the data to the IP address mapped by the target unique identification of the data for caching.
It can be seen that, since the updated data may be of various types, such as index type data, time series curve type data, etc., and the usage scenarios corresponding to different targets are different, the cache clusters are divided into multiple groups of cache clusters according to the usage scenarios, the number and resource configuration of the cache machines in each group are performed according to the resources required by the scenarios, so as to improve the resource utilization rate, and the distribution server establishes hash rings based on the IP addresses of the cache machines in the cache clusters respectively by using a routing tool in advance for each group of cache clusters, determines the cache cluster group identification corresponding to the target unique identification of the data when the data is updated, queries the hash ring of the corresponding cache cluster according to the cache cluster group identification, calculates the IP address mapped to by the target unique identification of the data in the hash ring according to the hash consistency algorithm by using the routing tool, the data is sent to the corresponding cache machine according to the target use scene, the data redundancy is low, the utilization rate of cache resources is further improved, and therefore the purpose of capacity enhancement is achieved.
In order to ensure the validity of the IP address in the hash ring, one or more embodiments of the present specification may further receive heartbeat messages sent by the respective caching machines, where the heartbeat messages are sent by the respective caching machines according to the IP address of the distribution server obtained from the registration center; obtaining the IP addresses of the cache machines from the heartbeat message; and when the corresponding cache machine is determined to be offline or online according to the heartbeat message, reestablishing the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located by using a routing tool according to a hash consistency algorithm. Because the hash ring is maintained by the way that the cache machine sends heartbeat to the distribution server, the hash ring can be distributed to an effective cache machine during distribution, and the timeliness and effectiveness of the distribution are ensured.
In order to reduce the pressure of the distribution server, the distribution server can synchronize the hash ring to the registration center, so that the data request end determines the IP address of the cache machine where the data to be requested is located according to the hash ring acquired from the registration center. Because the registration center provides the hash ring to the data request end, the global routing sharing based on the hash ring is realized, the distribution server does not need to provide the hash ring to the data request end, the pressure of the distribution server is reduced, and the efficiency of data distribution and data access is ensured.
Corresponding to the foregoing method embodiment, this specification further provides an embodiment of a data distribution apparatus based on cache cluster routing, and fig. 3 shows a schematic structural diagram of the data distribution apparatus based on cache cluster routing provided in an embodiment of this specification. The device is configured on a distribution server, the cache clusters are divided into a plurality of groups of cache clusters according to use scenes, and the distribution server establishes a hash ring based on the IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance. As shown in fig. 3, the apparatus includes: a group determination module 302, a ring query module 304, a distribution calculation module 306, and a data distribution module 308.
The group determination module 302 may be configured to determine a cache cluster group identifier corresponding to the target unique identifier of the data when the data is updated.
The ring query module 304 may be configured to query the hash ring of the corresponding cache cluster according to the cache cluster group identifier corresponding to the target unique identifier of the data.
The distribution calculation module 306 may be configured to calculate, using the routing tool, an IP address to which the target unique identifier of the data is mapped in the hash ring according to the hash consistency algorithm.
The data distribution module 308 may be configured to distribute the data to an IP address to which the target unique identifier of the data is mapped for caching.
Fig. 4 shows a schematic structural diagram of a data distribution apparatus based on cache cluster routing according to another embodiment of the present specification. The apparatus may further include: a heartbeat receiving module 310, which may be configured to receive heartbeat messages sent by the respective caching machines, where the heartbeat messages are sent by the respective caching machines according to the IP addresses of the distribution servers acquired from the registration center. An IP obtaining module 312 may be configured to obtain the respective cached machine IP addresses from the heartbeat message. The ring updating module 314 may be configured to, when it is determined that the corresponding cache machine is offline or online according to the heartbeat message, reestablish, by using a routing tool, the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located according to a hash consistency algorithm. Because the hash ring is maintained by the way that the cache machine sends heartbeat to the distribution server, the hash ring can be distributed to an effective cache machine during distribution, and the timeliness and effectiveness of the distribution are ensured.
Optionally, as shown in fig. 4, the apparatus may further include: the ring synchronization module 316 may be configured to synchronize the hash ring to the registry, so that the data request end determines the IP address of the cache machine where the data to be requested is located according to the hash ring obtained from the registry. Because the registration center provides the hash ring to the data request end, the global routing sharing based on the hash ring is realized, the distribution server does not need to provide the hash ring to the data request end, the pressure of the distribution server is reduced, and the efficiency of data distribution and data access is ensured.
The foregoing is an exemplary scheme of a data distribution apparatus based on cache cluster routing in this embodiment. It should be noted that the technical solution of the data distribution apparatus based on the cache cluster routing and the technical solution of the data distribution method based on the cache cluster routing belong to the same concept, and details of the technical solution of the data distribution apparatus based on the cache cluster routing, which are not described in detail, can be referred to the description of the technical solution of the data distribution method based on the cache cluster routing.
Fig. 5 is a flowchart illustrating a data access method based on cache cluster routing according to an embodiment of the present disclosure. The method is applied to a data request end, the cache clusters are divided into a plurality of groups of cache clusters according to use scenes, and a distribution server establishes a hash ring based on IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance. The method includes steps 502 through 506.
Step 502: and acquiring the hash ring of the corresponding cache cluster according to the cache cluster group identification corresponding to the target unique identification of the data to be requested.
Optionally, the hash ring corresponding to the cache set group identifier corresponding to the target unique identifier of the data to be requested may be obtained from the registry. The hash ring is obtained through the registration center, so that the global routing sharing based on the hash ring is realized, the distribution server does not need to provide the hash ring for the data request end, the pressure of the distribution server is reduced, and the efficiency of data distribution and data access is ensured.
Step 504: and calculating the IP address mapped by the target unique identifier of the data to be requested in the hash ring by using a routing tool according to the hash consistency algorithm.
Step 506: and sending access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested.
It can be seen that, in the embodiment of the present specification, a hash ring of a corresponding cache cluster is obtained according to a cache cluster group identifier corresponding to a target unique identifier of data to be requested, a routing tool is used to calculate an IP address mapped to the hash ring by the target unique identifier of the data to be requested according to the hash consistency algorithm, and an access to the data to be requested is sent to a cache machine of the IP address mapped to the target unique identifier of the data to be requested.
Corresponding to the above method embodiment, this specification further provides an embodiment of a data access apparatus based on cache cluster routing, and fig. 6 shows a schematic structural diagram of the data access apparatus based on cache cluster routing provided in an embodiment of this specification. The device is configured at a data request end, the cache clusters are divided into a plurality of groups of cache clusters according to use scenes, and a distribution server establishes a hash ring based on the IP addresses of cache machines in the cache clusters according to a hash consistency algorithm by using a routing tool aiming at each group of cache clusters in advance. As shown in fig. 6, the apparatus includes: a ring acquisition module 602, a mapping calculation module 604, and a data access module 606.
The ring obtaining module 602 may be configured to obtain a hash ring of a corresponding cache cluster according to a cache cluster group identifier corresponding to a target unique identifier of data to be requested.
Optionally, the ring obtaining module 602 may be configured to obtain, from a registry, a hash ring corresponding to a cache set group identifier corresponding to the target unique identifier of the data to be requested, where the hash ring is synchronized to the registry by the distribution server. The hash ring is obtained through the registration center, so that the global routing sharing based on the hash ring is realized, the distribution server does not need to provide the hash ring for the data request end, the pressure of the distribution server is reduced, and the efficiency of data distribution and data access is ensured.
The mapping calculation module 604 may be configured to calculate, according to the hash consistency algorithm, an IP address to which the target unique identifier of the data to be requested is mapped in the hash ring by using a routing tool.
The data access module 606 may be configured to issue an access to the data to be requested to a caching machine of an IP address to which the target unique identifier of the data to be requested is mapped.
It can be seen that, in the embodiment of the present specification, a hash ring of a corresponding cache cluster is obtained according to a cache cluster group identifier corresponding to a target unique identifier of data to be requested, a routing tool is used to calculate an IP address mapped to the hash ring by the target unique identifier of the data to be requested according to the hash consistency algorithm, and an access to the data to be requested is sent to a cache machine of the IP address mapped to the target unique identifier of the data to be requested.
The foregoing is an exemplary scheme of a data access apparatus based on cache cluster routing according to this embodiment. It should be noted that the technical solution of the data access apparatus based on the cache cluster routing and the technical solution of the data access method based on the cache cluster routing belong to the same concept, and details of the technical solution of the data access apparatus based on the cache cluster routing, which are not described in detail, can be referred to the description of the technical solution of the data access method based on the cache cluster routing.
FIG. 7 illustrates a block diagram of a computing device 700 provided in accordance with one embodiment of the present description. The components of the computing device 700 include, but are not limited to, memory 710 and a processor 720. Processor 720 is coupled to memory 710 via bus 730, and database 750 is used to store data.
Computing device 700 also includes access device 740, access device 740 enabling computing device 700 to communicate via one or more networks 760. Examples of such networks include the Public Switched Telephone Network (PSTN), a Local Area Network (LAN), a Wide Area Network (WAN), a Personal Area Network (PAN), or a combination of communication networks such as the internet. Access device 740 may include one or more of any type of network interface, e.g., a Network Interface Card (NIC), wired or wireless, such as an IEEE802.11 Wireless Local Area Network (WLAN) wireless interface, a worldwide interoperability for microwave access (Wi-MAX) interface, an ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a bluetooth interface, a Near Field Communication (NFC) interface, and so forth.
In one embodiment of the present description, the above-described components of computing device 700, as well as other components not shown in FIG. 7, may also be connected to each other, such as by a bus. It should be understood that the block diagram of the computing device architecture shown in FIG. 7 is for purposes of example only and is not limiting as to the scope of the present description. Those skilled in the art may add or replace other components as desired.
Computing device 700 may be any type of stationary or mobile computing device, including a mobile computer or mobile computing device (e.g., tablet, personal digital assistant, laptop, notebook, netbook, etc.), mobile phone (e.g., smartphone), wearable computing device (e.g., smartwatch, smartglasses, etc.), or other type of mobile device, or a stationary computing device such as a desktop computer or PC. Computing device 700 may also be a mobile or stationary server.
Among other things, in one aspect, processor 720 may be configured to execute the following computer-executable instructions:
when data is updated, determining a cache cluster group identifier corresponding to the target unique identifier of the data;
inquiring a hash ring of a corresponding cache cluster according to a cache cluster group identification corresponding to the target unique identification of the data;
calculating the IP address mapped by the target unique identifier of the data in the hash ring according to the hash consistency algorithm by using the routing tool;
and distributing the data to the IP address mapped by the target unique identification of the data for caching.
Optionally, the method further comprises:
receiving heartbeat messages sent by each cache machine, wherein the heartbeat messages are sent by each cache machine according to the IP address of the distribution server acquired from a registration center;
obtaining the IP addresses of the cache machines from the heartbeat message;
and when the corresponding cache machine is determined to be offline or online according to the heartbeat message, reestablishing the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located by using a routing tool according to a hash consistency algorithm.
Optionally, the method further comprises:
and synchronizing the hash ring to a registration center so that the data request end can determine the IP address of the cache machine where the data to be requested is located according to the hash ring acquired from the registration center.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the data distribution method based on the cache cluster routing belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the data distribution method based on the cache cluster routing.
In another aspect, processor 720 may be configured to execute the following computer-executable instructions:
acquiring a hash ring of a corresponding cache cluster according to a cache cluster group identifier corresponding to the target unique identifier of the data to be requested;
calculating the IP address mapped by the target unique identifier of the data to be requested in the hash ring by using a routing tool according to the hash consistency algorithm;
and sending access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested.
Optionally, the obtaining, according to the cache cluster group identifier corresponding to the target unique identifier of the data to be requested, the hash ring of the corresponding cache cluster includes:
and obtaining the hash ring corresponding to the cache set group identification corresponding to the target unique identification of the data to be requested from the registration center.
The above is an illustrative scheme of a computing device of the present embodiment. It should be noted that the technical solution of the computing device and the technical solution of the data access method based on the cache cluster routing belong to the same concept, and details that are not described in detail in the technical solution of the computing device can be referred to the description of the technical solution of the data access method based on the cache cluster routing.
An embodiment of the present specification also provides a computer readable storage medium storing computer instructions that, when executed by a processor, are operable to:
when data is updated, determining a cache cluster group identifier corresponding to the target unique identifier of the data;
inquiring a hash ring of a corresponding cache cluster according to a cache cluster group identification corresponding to the target unique identification of the data;
calculating the IP address mapped by the target unique identifier of the data in the hash ring according to the hash consistency algorithm by using the routing tool;
and distributing the data to the IP address mapped by the target unique identification of the data for caching.
Optionally, the method further comprises:
receiving heartbeat messages sent by each cache machine, wherein the heartbeat messages are sent by each cache machine according to the IP address of the distribution server acquired from a registration center;
obtaining the IP addresses of the cache machines from the heartbeat message;
and when the corresponding cache machine is determined to be offline or online according to the heartbeat message, reestablishing the hash ring of the cache cluster where the cache machine based on the offline or online cache machine is located by using a routing tool according to a hash consistency algorithm.
Optionally, the method further comprises:
and synchronizing the hash ring to a registration center so that the data request end can determine the IP address of the cache machine where the data to be requested is located according to the hash ring acquired from the registration center.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the data distribution method based on the cache cluster routing, and details that are not described in detail in the technical solution of the storage medium can be referred to the description of the technical solution of the data distribution method based on the cache cluster routing.
Another embodiment of the present specification also provides a computer readable storage medium storing computer instructions that, when executed by a processor, are to:
acquiring a hash ring of a corresponding cache cluster according to a cache cluster group identifier corresponding to the target unique identifier of the data to be requested;
calculating the IP address mapped by the target unique identifier of the data to be requested in the hash ring by using a routing tool according to the hash consistency algorithm;
and sending access to the data to be requested to a cache machine of the IP address mapped by the target unique identifier of the data to be requested.
Optionally, the obtaining, according to the cache cluster group identifier corresponding to the target unique identifier of the data to be requested, the hash ring of the corresponding cache cluster includes:
and obtaining the hash ring corresponding to the cache set group identification corresponding to the target unique identification of the data to be requested from the registration center.
The above is an illustrative scheme of a computer-readable storage medium of the present embodiment. It should be noted that the technical solution of the storage medium belongs to the same concept as the technical solution of the data access method based on the cache cluster routing, and details of the technical solution of the storage medium, which are not described in detail, can be referred to the description of the technical solution of the data access method based on the cache cluster routing.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The computer instructions comprise computer program code which may be in the form of source code, object code, an executable file or some intermediate form, or the like. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
It should be noted that, for the sake of simplicity, the foregoing method embodiments are described as a series of acts, but those skilled in the art should understand that the present embodiment is not limited by the described acts, because some steps may be performed in other sequences or simultaneously according to the present embodiment. Further, those skilled in the art should also appreciate that the embodiments described in this specification are preferred embodiments and that acts and modules referred to are not necessarily required for an embodiment of the specification.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
The preferred embodiments of the present specification disclosed above are intended only to aid in the description of the specification. Alternative embodiments are not exhaustive and do not limit the invention to the precise embodiments described. Obviously, many modifications and variations are possible in light of the above teaching. The embodiments were chosen and described in order to best explain the principles of the embodiments and the practical application, to thereby enable others skilled in the art to best understand and utilize the embodiments. The specification is limited only by the claims and their full scope and equivalents.