Method for allocating data requests and related device
By selecting target nodes and allocating data read requests based on load information in a read-write separation storage system, the problem of uneven resource utilization between master and slave nodes is solved, achieving balanced utilization of system resources and improving the overall performance of the storage system.
Patent Information
- Application Number
- CN202210667300.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-13
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2042-06-13
AI Technical Summary
In existing read-write separation storage systems, the resource utilization rates of master nodes and slave nodes are uneven, resulting in low system resource utilization.
By selecting target nodes based on the load information of master and slave nodes, and allocating data read requests to target nodes, the read request allocation ratio is calculated using load information, and combined with random number generation to achieve balanced resource allocation.
This improved the resource utilization of both master and slave nodes, resulting in a more balanced system resource utilization and enhanced overall storage system performance.
Smart Images

Figure CN117270754B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of data storage technology, and in particular to a method for allocating data requests and related equipment. Background Technology
[0002] A storage system generally refers to a service or system that provides data storage services and data retrieval capabilities. To expand the read / write performance of storage services and improve system stability, some storage systems adopt a read / write separation deployment model to provide data storage services. However, the inventors of this disclosure have discovered that storage systems using this deployment model have low resource utilization. Summary of the Invention
[0003] In view of this, this disclosure proposes a data request allocation method and related equipment to solve or partially solve the above problems.
[0004] In a first aspect, this disclosure provides a method for allocating data requests, wherein the data requests are processed by a read-write separation storage system, the data requests include data read requests, and the read-write separation storage system includes a master node and slave nodes. The method includes:
[0005] Receive data read request;
[0006] In response to the data read request, a target node is selected from the master node and the slave node based on the load information of the master node and the slave node; and
[0007] The data read request is assigned to the target node.
[0008] A second aspect of this disclosure provides a data request allocation apparatus, wherein the data request is processed by a read-write separation storage system, the data request including a data read request, the read-write separation storage system including a master node and a slave node, and the apparatus comprising:
[0009] The receiving module is configured to receive data read requests;
[0010] The node selection module is configured to: in response to the data read request, select a target node from the master node and the slave node based on the load information of the master node and the slave node; and
[0011] The request allocation module is configured to allocate the data read request to the target node.
[0012] A third aspect of this disclosure provides a computer device including one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and executed by the one or more processors, the programs including instructions for performing the method according to the first aspect.
[0013] A fourth aspect of this disclosure provides a non-volatile computer-readable storage medium containing a computer program that, when executed by one or more processors, causes the processors to perform the method described in the first aspect.
[0014] A fifth aspect of this disclosure provides a computer program product including computer program instructions that, when executed on a computer, cause the computer to perform the method described in the first aspect.
[0015] The method and related equipment for allocating data requests in a read-write separation storage system disclosed herein select a target node from the master node and slave node based on the load information of the master node and slave node, and then allocate data read requests to the target node, so that the resource utilization of the master node and slave node is more balanced and the system resource utilization is improved. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in this disclosure or related technologies, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only embodiments of this disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1A A schematic diagram of an exemplary system is shown.
[0018] Figure 1B It shows Figure 1A A diagram illustrating how the system allocates data requests.
[0019] Figure 2A A schematic diagram of an exemplary system provided by an embodiment of this disclosure is shown.
[0020] Figure 2B A flowchart illustrating an exemplary method according to an embodiment of this disclosure is shown.
[0021] Figure 3 A schematic diagram of the hardware structure of a more specific computer device provided in this embodiment is shown.
[0022] Figure 4 A flowchart illustrating an exemplary method provided in an embodiment of this disclosure is shown.
[0023] Figure 5 A schematic diagram of an exemplary apparatus provided in an embodiment of this disclosure is shown. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this disclosure clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.
[0025] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this disclosure should have the ordinary meaning understood by one of ordinary skill in the art to which this disclosure pertains. The terms "first," "second," and similar words used in the embodiments of this disclosure do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects. Terms such as "connected" or "linked" are not limited to physical or mechanical connections, but can include electrical connections, whether direct or indirect. Terms such as "upper," "lower," "left," and "right" are used only to indicate relative positional relationships; when the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0026] Figure 1A A schematic diagram of an exemplary system 100 is shown.
[0027] like Figure 1A As shown, system 100 includes client 102 and storage system 104. Client 102 can use the data storage services provided by storage system 104 and can send data read / write requests to storage system 104 to perform data read / write operations. Storage system 104 can adopt a read / write separation deployment mode, such as the deployment mode used by databases like MySQL and Redis.
[0028] like Figure 1A As shown, the storage system 104 may further include a master node 1042 and multiple slave nodes, for example, such as Figure 1AAs shown, storage system 104 may include slave nodes 1044 and 1046. The master node 1042 may include a server or a server cluster, primarily responsible for handling write requests and providing CRUD (Create, Read, Update, Delete) services. Slave nodes 1044 and 1046 may include a server or a server cluster and primarily perform read operations. In read-write separation mode, if the master node 1042 modifies data, the modified data will be synchronized to slave nodes 1044 and 1046 accordingly. Slave nodes 1044 and 1046 can only provide read data services and cannot be written to by client 102. Thus, slave nodes 1044 and 1046 achieve data backup while also optimizing database performance and improving server security.
[0029] Figure 1B It shows Figure 1A A schematic diagram illustrating how system 100 allocates data requests.
[0030] like Figure 1B As shown, in a typical read / write separation deployment architecture, write requests can only be completed by the master node 1042. Read requests are different. Since the master node 1042 also has the ability to handle read requests, it can obtain data either by accessing the slave nodes 1044 and 1046 or by accessing the master node 1042.
[0031] In most read / write separation deployment architectures, the master node 1042 either does not handle any read requests at all, or shares the read requests with the slave nodes 1044 and 1046. The problem with this deployment method is that it is difficult to maintain a balance in the resource utilization of the master and slave nodes.
[0032] For example, in a write-heavy, read-light scenario, the write pressure on master node 1042 is very high. If master node 1042 needs to handle too many read requests, it will become overloaded. Therefore, in this scenario, master node 1042 should ideally provide only a small amount of read service or no read service at all.
[0033] For example, in a scenario with few writes and many reads, the write pressure on master node 1042 is very small. In order to improve resource utilization, master node 1042 can take on more read requests.
[0034] In view of this, the present disclosure provides a method and related device for allocating data requests in a read-write separation storage system. Based on the load information of the master node and slave node, a target node is selected from the master node and slave node, and then the data read request is allocated to the target node, so that the resource utilization of the master node and slave node is more balanced and the system resource utilization is improved.
[0035] Figure 2AA schematic diagram of an exemplary system 200 provided in an embodiment of this disclosure is shown.
[0036] like Figure 2A As shown, the system 200 may include a client 202 and a storage system 204. The client 202 can use the data storage services provided by the storage system 204 and can send data read and write requests to the storage system 204 to perform data read and write operations. The storage system 204 may adopt a read-write separation deployment mode.
[0037] like Figure 2A As shown, the storage system 204 may further include a master node 2042 and multiple slave nodes, for example, such as Figure 2A As shown, storage system 204 may include slave nodes 2044 and 2046. The master node 2042 may include a server or a server cluster and is responsible for handling write requests, providing CRUD (Create, Read, Update, Delete) services. Slave nodes 2044 and 2046 may include a server or a server cluster and can perform read operations. In read-write separation mode, if the master node 2042 modifies data, the modified data will be synchronized to slave nodes 2044 and 2046. Slave nodes 2044 and 2046 can only provide read data services and cannot be written to by client 202. Thus, slave nodes 2044 and 2046 achieve data backup while also optimizing database performance and improving server security.
[0038] In some embodiments, the master node 2042 and slave nodes 2044 and 2046 jointly handle data read requests. For example... Figure 2A As shown, system 200 may include a request allocation module 2062 for allocating data read requests between master node 2042 and slave nodes 2044 and 2046. In some embodiments, the request allocation module 2062 may be implemented as a software development kit (SDK) and may be deployed on a server, for example, in a scheduling node 206. The scheduling node 206 may include a server or a server cluster and may be used to execute the data request allocation method proposed in the embodiments of this disclosure. It is understood that the SDK may also be deployed on client 202 to achieve the same functionality.
[0039] In one scenario, client 202 can initiate a data read request. Request allocation module 2062 can receive this data read request and, in response, select a target node from the master node and slave node based on their load information. Then, it allocates the data read request to the target node. This allows the data read request to be allocated based on the load information of the master node and slave node, resulting in a more balanced resource utilization between the master node and slave node and improving system resource utilization.
[0040] In some embodiments, the request allocation module 2062 can determine the read request allocation ratio of the master node 2042, and then select a target node from the master node 2042 and slave nodes 2044 and 2046 according to the read request allocation ratio. The read request allocation ratio of the master node can be calculated based on the load information of the master node 2042 and slave nodes 2044 and 2046. This ratio indicates whether the master node 2042 can be allocated read requests (e.g., a value of 0 indicates that read requests cannot be allocated to the master node 2042), and can be compared with a random number during read request allocation to further determine whether to allocate read requests to the master node 2042. Thus, allocating data read requests based on this read request allocation ratio can result in a more balanced resource utilization between the master node and slave nodes.
[0041] In some embodiments, such as Figure 2A As shown, system 200 may include a load receiving module 2064, used to receive load information from master node 2042 and slave nodes 2044 and 2046, and calculate the read request allocation ratio of master node 2042 based on the load information of master node 2042 and slave nodes 2044 and 2046. In this way, the read request allocation ratio calculated based on the load information can make the resource utilization of master node and slave nodes more balanced.
[0042] The load receiving module 2064 can periodically receive load information from the master node 2042 and the slave nodes 2044 and 2046. The receiving interval of the load receiving module 2064 can be, for example, every 10 minutes, 1 hour, 3 hours, 8 hours, 12 hours, 24 hours, etc. Load information can be actively reported to the load receiving module 2064 by the master node 2042 and the slave nodes 2044 and 2046, or it can be obtained by the load receiving module 2064 actively requesting the load information from the master node 2042 and the slave nodes 2044 and 2046. This load information can reflect the resource usage of the nodes; therefore, it can be any type of load information. In some embodiments, the load information can be the CPU load information of the nodes, thus better reflecting the resource usage of the nodes.
[0043] In some embodiments, after receiving the load information of the master node 2042 and the load information of the slave nodes 2044 and 2046, the load receiving module 2064 can further calculate the read request allocation ratio of the master node 2042 based on this load information. Figure 2B A flowchart illustrating an exemplary method 208 according to an embodiment of this disclosure is shown. Figure 2B As shown, the method 208 for calculating the read request allocation ratio of the master node 2042 based on this load information may specifically include the following steps.
[0044] In step 2082, the average load information of the multiple slave nodes is calculated based on their load information. For example, there are a total of N (N>0) slave nodes, numbered 1-N, and the CPU utilization of the x-th slave node is s. x Then the average CPU utilization of N slave nodes is S = avg(s1, s2...s). N Here, it is assumed that the CPU utilization range is [0, 100%], where 0 represents no load and 100% represents the load reaching its limit.
[0045] In step 2084, the first read request allocation ratio is obtained by subtracting the load information of the master node from the average load information and dividing by the total number of master and slave nodes. For example, assuming that the CPU utilization of master node 2042 is M, then the first read request allocation ratio K1 = (SM) / (N+1).
[0046] In step 2086, the second read request allocation ratio K2 is set to 0.
[0047] In step 2088, the larger one of the first read request allocation ratio and the second read request allocation ratio is selected as the read request allocation ratio K of the primary node 2042. That is, K=max(K1,K2). Correspondingly, the read request allocation ratio Y of all secondary nodes is (100-K).
[0048] It can be seen from the formula K=max(K1,K2) that if M<S, that is, the CPU usage rate of the primary node 2042 is lower than that of the secondary node (that is, K1=(S-M) / (N+1)>0), K=max(K1,K2)=K1>0, and the primary node 2042 can share part of the read requests; if M>S, the CPU usage rate of the primary node 2042 is higher than that of the secondary node (that is, K1=(S-M) / (N+1)<0), K=max(K1,K2)=K2=0, and the primary node 2042 will not be allocated read requests. In this way, a more reasonable request allocation is achieved by using this calculation method, and the resource usage rates of the primary node and the secondary node can be more balanced.
[0049] After periodically receiving the load information of the primary node 2042 and the load information of the secondary nodes 2044 and 2046, the load receiving module 2064 calculates the read request allocation ratio K accordingly, so that the request allocation module 2062 can retrieve the read request allocation ratio K from the load receiving module 2064 at any time to allocate the received data read request among the primary node 2042 and the secondary nodes 2044 and 2046. In this way, the request allocation module 2062 only needs to retrieve the read request allocation ratio K from the load receiving module 2064 for subsequent processing, instead of receiving load information to calculate the read request allocation ratio K, so that the operation efficiency of the request allocation module 2062 can be improved. It can be understood that in some scenarios, the request allocation module 2062 may also receive load information and calculate the read request allocation ratio K, and the present disclosure is not limited to using only the load receiving module 2064 to receive load information and calculate the read request allocation ratio K.
[0050] It should be noted that the foregoing embodiments calculate the read request allocation ratio K based on the load information as the allocation basis of the read requests. It can be understood that there may actually be other ways of allocating read requests according to the load information. The present disclosure does not limit the allocation basis to the specific implementation of the read request allocation ratio K, and any extended embodiments made on this basis fall within the protection scope of the present disclosure.
[0051] In some embodiments, the request allocation module 2062 selects a target node among the primary node and the secondary nodes according to the read request allocation ratio K, which may be specifically implemented by the following steps.
[0052] First, a random number is generated using a random function, with the value ranging from [0,1]. Then, this random number is compared with the read request allocation ratio K. If the random number is less than the read request allocation ratio K, the request allocation module 2062 can select the master node 2042 as the target node; if the random number is greater than or equal to the read request allocation ratio K, the request allocation module 2062 can select either the slave node 2044 or 2046 as the target node.
[0053] In this way, by comparing a random number with the read request allocation ratio K, and referring to the previous embodiment, we know that when K = 0, it means that the CPU utilization of the master node 2042 is higher than that of the slave node, and the master node 2042 will not be allocated read requests, thus ensuring that the master node 2042 can handle write requests. When K > 0, it means that the CPU utilization of the master node 2042 is lower than that of the slave node, and the master node 2042 can be allocated read requests. However, because a random number needs to be generated for comparison with the read request allocation ratio K, read requests are not exclusively allocated to the master node or the slave node, but the probability of allocation to the master node or the slave node has a certain degree of randomness, thus making the resource utilization of the master node and the slave node more balanced. At the same time, since the master node also needs to undertake the task of writing data, this random allocation method ensures that the remaining load capacity of the master node is not entirely used to process read requests, leaving some space for write requests, thereby ensuring the normal operation of the entire storage system.
[0054] Furthermore, it can be understood that when there are multiple slave nodes and read requests need to be assigned to slave nodes, a slave node needs to be selected from among the multiple slave nodes to handle the read request.
[0055] In some embodiments, the request allocation module 2062 may randomly select one slave node from multiple slave nodes as the target node, thereby making the allocation pattern of read requests among slave nodes random and avoiding the problem of uneven resource utilization caused by allocating read requests to a single slave node.
[0056] In other embodiments, the request allocation module 2062 may select the slave node with the lowest load among multiple slave nodes as the target node, thereby further improving the balance of resource utilization.
[0057] In some embodiments, in order to ensure the read-write separation deployment architecture of the storage system 204, after the request allocation module 2062 receives a data write request, it can directly allocate the data write request to the master node 2042, and the master node 2042 can perform CRUD operations based on the data write request.
[0058] As can be seen from the above embodiments, the system 200 provided in this disclosure compares the load of the master node and the slave node, and allocates appropriate read traffic to the master node, making full use of the master node's resources and thus improving the overall resource utilization of the cluster. Furthermore, the load receiving module 2064 itself is only responsible for load receiving and generating read / write ratio configurations, requiring only minimal resources.
[0059] Based on the same inventive concept, this disclosure also provides a computer device.
[0060] Figure 3 A schematic diagram of the hardware structure of a more specific computer device 300 provided in this embodiment is shown. This computer device 300 can be used to implement... Figure 2A The scheduling node 206. In some embodiments, the computer device 300 can also be used to implement Figure 2A The client 202, storage system 204, master node 2042, slave nodes 2044 and 2046. For example... Figure 3 As shown, the computer device 300 may include: a processor 302, a memory 304, a network interface 306, a peripheral interface 308, and a bus 310. The processor 302, memory 304, network interface 306, and peripheral interface 308 are interconnected within the electronic device via the bus 310.
[0061] Processor 302 may be a Central Processing Unit (CPU), a graphics processor, a neural network processor (NPU), a microcontroller (MCU), a programmable logic device, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), or one or more integrated circuits. Processor 302 can be used to perform functions related to the technology described in this application. In some embodiments, processor 302 may also include multiple processors integrated into a single logic component. Figure 3 As shown, processor 302 may include multiple processors 302a, 302b and 302c.
[0062] Memory 304 can be configured to store data (e.g., instruction sets, computer code, intermediate data, etc.). For example... Figure 3As shown, the data stored in the memory may include program instructions and data to be processed. The processor 302 may also access the program instructions and data stored in the memory and execute the program instructions to operate on the data to be processed. The memory 304 may include a volatile storage device or a non-volatile storage device. In some embodiments, the memory 304 may include random access memory (RAM), read-only memory (ROM), optical disk, magnetic disk, hard disk, solid-state drive (SSD), flash memory, memory stick, etc.
[0063] Network interface 306 can be configured to provide communication with other external devices to computer device 300 via a network. This network can be any wired or wireless network capable of transmitting and receiving data. For example, the network can be a wired network, a local wireless network (e.g., Bluetooth, WiFi, Near Field Communication (NFC), etc.), a cellular network, the Internet, or a combination thereof. It is understood that the type of network is not limited to the specific examples described above. In some embodiments, network interface 306 may include any combination of any number of network interface controllers (NICs), radio frequency modules, transceivers, modems, routers, gateways, adapters, cellular network chips, etc.
[0064] Peripheral interface 308 can be configured to connect computer device 300 to one or more peripheral devices to enable information input and output. For example, peripheral devices may include input devices such as keyboard, mouse, touchpad, touch screen, microphone, and various sensors, as well as output devices such as monitor, speaker, vibrator, and indicator lights.
[0065] Bus 310 can be configured to transfer information between various components of computer device 300 (e.g., processor 302, memory 304, network interface 306, and peripheral interface 308), such as internal buses (e.g., processor-memory bus), external buses (USB port, PCI-E bus), etc.
[0066] It should be noted that although the above host architecture only shows processor 302, memory 304, network interface 306, peripheral interface 308, and bus 310, in specific implementations, the architecture of the computer device 300 may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the architecture of the above computer device 300 may only include the components necessary for implementing the embodiments of this application, and does not necessarily include all the components shown in the figures.
[0067] Based on the same inventive concept, this disclosure also provides a method for allocating data requests.
[0068] Figure 4A flowchart illustrating an exemplary method 400 provided in an embodiment of this disclosure is shown. Method 400 can be... Figure 3 The computer device 300 is used to implement this, and may further include the following steps.
[0069] In step 402, a data read request is received.
[0070] In step 404, in response to the data read request, a target node is selected from the master node and the slave node based on the load information of the master node and the slave node.
[0071] In some embodiments, selecting a target node from the master node and the slave node based on the load information of the master node and the slave node includes: determining the master node (e.g., Figure 2A The read request allocation ratio of the master node (2042) is based on the ratio of read requests allocated to the master node and the slave nodes (e.g., ...). Figure 2A The load information of the master node and the slave node is calculated; and the target node is selected from the master node and the slave node according to the read request allocation ratio.
[0072] In some embodiments, method 400 further includes: receiving load information (e.g., CPU utilization) of the master node and load information of the slave node; and calculating the read request allocation ratio of the master node based on the load information of the master node and the load information of the slave node. Thus, the read request allocation ratio calculated based on the load information can make the resource utilization of the master node and slave node more balanced.
[0073] In some embodiments, there are multiple slave nodes. Calculating the read request allocation ratio for the master node based on the load information of the master node and the load information of the slave nodes includes: calculating the average load information of the multiple slave nodes based on their load information; subtracting the master node's load information from the average load information and dividing by the sum of the number of master nodes and slave nodes to obtain a first read request allocation ratio; setting a second read request allocation ratio to 0; and selecting the larger of the first and second read request allocation ratios as the read request allocation ratio for the master node. This calculation method achieves a more reasonable request allocation, resulting in a more balanced resource utilization between the master node and slave nodes.
[0074] In some embodiments, selecting a target node from the master node and the slave node according to the read request allocation ratio includes: generating a random number using a random function, wherein the random number has a value range of [0,1); selecting the master node as the target node in response to determining that the random number is less than the read request allocation ratio of the master node; or selecting the slave node as the target node in response to determining that the random number is greater than or equal to the read request allocation ratio of the master node.
[0075] In this way, by comparing the random number with the read request allocation ratio, read requests are not simply allocated to the master node or the slave node, but the probability of allocation to the master node or the slave node has a certain degree of randomness, thereby making the resource utilization of the master node and the slave node more balanced.
[0076] In some embodiments, the number of slave nodes is multiple, and selecting a slave node as the target node includes: randomly selecting a slave node from the multiple slave nodes as the target node, so that the distribution pattern of read requests among the slave nodes is random, avoiding the problem of uneven resource utilization caused by allocating read requests to a single slave node.
[0077] In some embodiments, the number of slave nodes is multiple, and selecting a slave node as the target node includes: selecting the slave node with the lowest load among the multiple slave nodes as the target node, which can further improve the balance of resource utilization.
[0078] In step 406, the data read request is assigned to the target node.
[0079] In some embodiments, in order to ensure the read-write separation deployment architecture of the storage system 204, method 400 further includes: receiving a data write request; and allocating the data write request to the master node.
[0080] It should be noted that the method of this disclosure embodiment can be executed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario, where multiple devices cooperate to complete the task. In such a distributed scenario, one of these devices may execute only one or more steps of the method of this disclosure embodiment, and the multiple devices will interact with each other to complete the method described.
[0081] It should be noted that the above description describes some embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in a different order than that shown in the above embodiments and still achieve the desired result. Furthermore, the processes depicted in the drawings do not necessarily require a specific or sequential order to achieve the desired result. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0082] Based on the same inventive concept, corresponding to any of the above-described embodiments, this disclosure also provides a data request allocation device for a read-write separation storage system. Figure 5 A schematic diagram of an exemplary apparatus 500 provided in an embodiment of this disclosure is shown.
[0083] refer to Figure 5 The device 500 includes:
[0084] The receiving module 502 is configured to receive data read requests;
[0085] Node selection module 504 is configured to: in response to the data read request, select a target node from the master node and the slave node based on the load information of the master node and the slave node; and
[0086] The request allocation module 506 is configured to allocate the data read request to the target node.
[0087] In some embodiments, the node selection module 504 is configured to: determine the read request allocation ratio of the master node, the read request allocation ratio being calculated based on the load information of the master node and the slave node; and select a target node from the master node and the slave node based on the read request allocation ratio.
[0088] In some embodiments, the node selection module 504 is configured to: generate a random number using a random function, the random number having a value range of [0,1); select the master node as the target node in response to determining that the random number is less than the read request allocation ratio of the master node; or select the slave node as the target node in response to determining that the random number is greater than or equal to the read request allocation ratio of the master node.
[0089] In some embodiments, the apparatus 500 further includes a load receiving module 508, configured to: receive load information of the master node and load information of the slave node; and calculate the read request allocation ratio of the master node based on the load information of the master node and the load information of the slave node.
[0090] In some embodiments, the load receiving module 508 is configured to: calculate the average load information of the multiple slave nodes based on the load information of the multiple slave nodes; subtract the load information of the master node from the average load information and divide by the sum of the number of master nodes and slave nodes to obtain a first read request allocation ratio; set the second read request allocation ratio to 0; and select the larger of the first read request allocation ratio and the second read request allocation ratio as the read request allocation ratio of the master node.
[0091] In some embodiments, the number of slave nodes is multiple, and the node selection module 504 is configured to randomly select one slave node from the multiple slave nodes as the target node.
[0092] In some embodiments, the node selection module 504 is configured to select the slave node with the lowest load among the plurality of slave nodes as the target node.
[0093] In some embodiments, the receiving module 502 is configured to receive a data write request; and the request allocation module 506 is configured to allocate the data write request to the master node.
[0094] For ease of description, the above apparatus is described in terms of its functions, divided into various modules. Of course, in implementing this disclosure, the functions of each module can be implemented in one or more software and / or hardware.
[0095] The apparatus of the above embodiments is used to implement the corresponding method 400 in any of the foregoing embodiments and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0096] Based on the same inventive concept, corresponding to the methods of any of the above embodiments, this disclosure also provides a non-transitory computer-readable storage medium storing computer instructions for causing the computer to perform the method 400 as described in any of the above embodiments.
[0097] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.
[0098] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to perform the method 400 as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0099] Based on the same inventive concept, corresponding to the method 400 of any of the above embodiments, this disclosure also provides a computer program product, which includes a computer program. In some embodiments, the computer program is executable by one or more processors to cause the processors to perform the method 400. Corresponding to the execution entity for each step in each embodiment of method 400, the processor executing the corresponding step may belong to the corresponding execution entity.
[0100] The computer program product of the above embodiments is used to cause the processor to execute the method 400 as described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0101] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this disclosure (including the claims) is limited to these examples; within the framework of this disclosure, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this disclosure as described above, which are not provided in detail for the sake of brevity.
[0102] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this disclosure, the well-known power / ground connections to the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this disclosure, and this also takes into account the fact that the details of implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this disclosure will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of this disclosure, it will be apparent to those skilled in the art that the embodiments of this disclosure may be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.
[0103] Although this disclosure has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.
[0104] This disclosure is intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.
Claims
1. A method for allocating data requests, wherein, The data request is processed by a read-write separation storage system, the data request includes a data read request, the read-write separation storage system includes a master node and a slave node, and the method includes: Receive data read request; In response to the data read request, a target node is selected from the master node and the slave node based on the load information of the master node and the slave node; and The data read request is assigned to the target node; The process of selecting a target node from the master node and the slave node based on their load information includes: The read request allocation ratio of the master node is determined, and the read request allocation ratio is calculated based on the load information of the master node and the slave node; and Based on the read request allocation ratio, a target node is selected from the master node and the slave node; The selection of a target node from the master node and the slave node based on the read request allocation ratio includes: Use a random function to generate a random number, the value of which is in the range [0,1); In response to determining that the random number is less than the read request allocation ratio of the master node, the master node is selected as the target node; or In response to determining that the random number is greater than or equal to the read request allocation ratio of the master node, the slave node is selected as the target node; The method further includes: (The number of slave nodes is multiple) Calculate the average load information of the multiple slave nodes based on their load information; The first read request allocation ratio is obtained by subtracting the load information of the master node from the average load information and dividing by the sum of the number of master nodes and slave nodes. Assume the allocation ratio for the second read request is 0; and The larger of the first read request allocation ratio and the second read request allocation ratio is selected as the read request allocation ratio of the master node.
2. The method as described in claim 1, wherein, The number of slave nodes is multiple, and selecting a slave node as the target node includes: Randomly select one of the multiple slave nodes as the target node.
3. The method as described in claim 1, wherein, The number of slave nodes is multiple, and selecting a slave node as the target node includes: The target node is selected as the slave node with the lowest load among the multiple slave nodes.
4. The method according to any one of claims 1-3, wherein the data request further includes a data write request, and the method further includes: Receive data write request; as well as The data write request is assigned to the master node.
5. A data request allocation device, wherein, The data request is processed by the read-write separation storage system, and the data request includes a data read request. The read-write separation storage system includes a master node and a slave node. The device includes: The receiving module is configured to receive data read requests; The node selection module is configured to: in response to the data read request, select a target node from the master node and the slave node based on the load information of the master node and the slave node; and The request allocation module is configured to allocate the data read request to the target node. The process of selecting a target node from the master node and the slave node based on their load information includes: The read request allocation ratio of the master node is determined, and the read request allocation ratio is calculated based on the load information of the master node and the slave node; and Based on the read request allocation ratio, a target node is selected from the master node and the slave node; The selection of a target node from the master node and the slave node based on the read request allocation ratio includes: Use a random function to generate a random number, the value of which is in the range [0,1); In response to determining that the random number is less than the read request allocation ratio of the master node, the master node is selected as the target node; or In response to determining that the random number is greater than or equal to the read request allocation ratio of the master node, the slave node is selected as the target node; The data request distribution device further includes a load receiving module, configured to: Calculate the average load information of the multiple slave nodes based on their load information; The first read request allocation ratio is obtained by subtracting the load information of the master node from the average load information and dividing by the sum of the number of master nodes and slave nodes. Assume the allocation ratio for the second read request is 0; and The larger of the first read request allocation ratio and the second read request allocation ratio is selected as the read request allocation ratio of the master node.
6. A computer device comprising one or more processors, a memory; and one or more programs, wherein the one or more programs are stored in the memory and executed by the one or more processors, the programs comprising instructions for performing the method according to any one of claims 1-4.
7. A non-volatile computer-readable storage medium comprising a computer program, which, when executed by one or more processors, causes the processors to perform the method of any one of claims 1-4.
8. A computer program product comprising computer program instructions that, when executed on a computer, cause the computer to perform the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Method and device for processing download request
CN107395708A
