Data access method and device, electronic equipment and computer readable storage medium

By adopting affinity routing and shared memory communication technology in distributed cache systems, bypassing the kernel network protocol stack, the problem of high communication latency in cache systems is solved, and faster and more efficient data access is achieved, suitable for latency-sensitive applications.

CN120416342APending Publication Date: 2025-08-01JINAN INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510705690.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-28
Publication Date
2025-08-01

AI Technical Summary

Technical Problem

In the existing distributed cache system, the data communication latency between the cache client and the cache service process is high, especially in the same physical node, it still needs to be processed by the operating system network protocol stack, resulting in a bottleneck in latency-sensitive application performance.

Method used

Through affinity routing technology, determine whether the target node is a local node. If it is a local node, the access request will be directly sent through shared memory. If it is not a local node, it will be sent through standard network communication protocols. Combined with the unitized architecture of the cache service process and the shared memory communication technology, the kernel network protocol stack is bypassed.

Benefits of technology

It significantly reduces the communication delay between the cache client and the cached master replica of the same node, improves data access efficiency, especially in latency-sensitive scenarios, reducing long-tail latency and improving the system's concurrency processing capability and throughput.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120416342A_ABST
    Figure CN120416342A_ABST
Patent Text Reader

Abstract

The invention discloses a data access method and device, electronic equipment and a computer readable storage medium, the method is applied to a cache client, and the method comprises the following steps: determining an access object according to an access request, and determining a target node where the access object is located; if the target node is a local node, storing the access request to a shared memory, and sending a request processing notification to a cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to realize data access; and if the target node is not the local node, sending the access request to a cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to realize data access. By applying the technical scheme provided by the invention, quicker and more efficient data access can be realized in the distributed cache system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data communication technologies, and in particular, to a data access method, and also relates to a data access device, an electronic device, and a computer-readable storage medium. Background Art

[0002] Distributed cache systems are core components in modern large-scale computing and storage architectures. By caching hot data close to computing nodes, they significantly improve data access performance and relieve the pressure on the backend storage system. Such systems typically involve efficient interaction between cache clients (CacheClient) and cache service processes (CacheServer). However, existing distributed cache access methods generally face the following performance bottlenecks: high communication latency. Even if the client and the cache master copy where the target data is located are deployed on the same physical node, the data communication between them still needs to go through the operating system network protocol stack, and operations such as protocol stack processing, kernel context switching, and data copying involved therein will introduce non-negligible latency, which has a more significant impact on latency-sensitive applications.

[0003] Therefore, how to achieve faster and more efficient data access in distributed cache systems is an urgent problem for those skilled in the art to solve. Summary of the Invention

[0004] The purpose of this application is to provide a data access method that can achieve faster and more efficient data access in a distributed cache system; another purpose of this application is to provide a data access device, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above beneficial effects.

[0005] In a first aspect, this application provides a data access method applied to a cache client, including:

[0006] Determine an access object according to an access request, and determine a target node where the access object is located;

[0007] If the target node is a local node, save the access request to shared memory, and send a request processing notification to the cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to achieve data access;

[0008] If the target node is not the local node, send the access request to the cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to achieve data access.

[0009] Optionally, determining an access object according to an access request and determining a target node where the access object is located includes:

[0010] Parsing the access request to obtain identification information of the access object;

[0011] Determining a target cache partition where the access object is located according to the identification information;

[0012] Determining the target node to which the target cache partition belongs by querying cluster topology information.

[0013] Optionally, after determining an access object according to an access request and determining a target node where the access object is located, it further includes:

[0014] Obtaining a node identifier of the target node and a node identifier of the local node;

[0015] When the node identifier of the target node is the same as the node identifier of the local node, determining the target node as the local node;

[0016] When the node identifier of the target node is different from the node identifier of the local node, determining that the target node is not the local node.

[0017] In a second aspect, the present application provides another data access method, which is applied to a cache service process and includes:

[0018] Receiving a data access message sent by a cache client;

[0019] When the data access message is a request processing notification, obtaining an access request in shared memory according to the request processing notification for processing to implement data access; the access request is saved to the shared memory by the cache client when determining that the target node where the access object is located is the local node;

[0020] When the data access message is the access request, processing the access request to implement data access; the access request is sent to the cache service process by the cache client when determining that the target node where the access object is located is not the local node.

[0021] Optionally, the cache service process is divided into multiple processing units;

[0022] Correspondingly, processing the access request to implement data access includes:

[0023] Determining identification information of the access object according to the access request;

[0024] Determining a target processing unit in the cache service process according to the identification information of the access object;

[0025] Distribute the access request to the target processing unit for processing to achieve data access.

[0026] Optionally, the identification information of the access object is the object ID of the access object;

[0027] Accordingly, determining the target processing unit in the cache service process according to the identification information of the access object includes:

[0028] Perform a hash calculation on the object ID of the access object to obtain a hash value;

[0029] Use the hash value to perform a modulo operation on the total number of processing units in the cache service process to obtain a target modulo value;

[0030] Take the processing unit whose processing unit identifier hits the target modulo value as the target processing unit.

[0031] In a third aspect, the present application also discloses a data access device, which is applied to a cache client and includes:

[0032] A determination module, configured to determine an access object according to an access request and determine a target node where the access object is located;

[0033] A first access module, configured to, if the target node is a local node, save the access request to a shared memory and send a request processing notification to the cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to achieve data access;

[0034] A second access module, configured to, if the target node is not the local node, send the access request to the cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to achieve data access.

[0035] In a fourth aspect, the present application also discloses another data access device, which is applied to a cache service process and includes:

[0036] A receiving module, configured to receive a data access message sent by a cache client;

[0037] A first processing module, configured to, when the data access message is a request processing notification, obtain an access request in the shared memory according to the request processing notification for processing to achieve data access; the access request is saved to the shared memory by the cache client when determining that the target node where the access object is located is a local node;

[0038] A second processing module, configured to process the access request to implement data access when the data access message is the access request; the access request is sent by the cache client to the cache service process when it determines that the target node where the access object is located is not the local node.

[0039] In a fifth aspect, the present application also discloses an electronic device, including:

[0040] A memory, configured to store a computer program;

[0041] A processor, configured to implement the steps of any of the above data access methods when executing the computer program.

[0042] In a sixth aspect, the present application also discloses a computer-readable storage medium, on which a computer program is stored, and the computer program, when executed by a processor, implements the steps of any of the above data access methods.

[0043] In a seventh aspect, the present invention also discloses a computer program product, including computer programs / instructions, and the computer programs / instructions, when executed by a processor, implement the steps of any of the above data access methods.

[0044] The present application provides a data access method, applied to a cache client, including: determining an access object according to an access request, and determining a target node where the access object is located; if the target node is the local node, saving the access request to a shared memory, and sending a request processing notification to the cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to implement data access; if the target node is not the local node, sending the access request to the cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to implement data access.

[0045] Applying the technical solution provided by this application, in a distributed cache system architecture including a cache client and a cache service process, for an access request to be sent to the cache service process, the cache client first performs an affinity determination on it, that is, determines whether the target node where the current access object is located is the local node. If it is the local node, the access request can be sent to the cache service process through shared memory to achieve data access. This path bypasses the kernel network protocol stack and can minimize the local access latency. If the target node is not the local node, the access request can be sent to the cache service process through the standard network communication protocol to achieve data access. It can be seen that through the affinity routing technology and shared memory communication technology, this technical solution effectively bypasses the kernel network protocol stack, greatly reduces the communication latency between the cache client and the cache master replica on the same node, and helps to achieve faster and more efficient data access in the distributed cache system.

[0046] In an embodiment of this application, the internal units of the cache service process are unitized, that is, the cache service process is divided into multiple parallel processing units with independent resources. Each processing unit has its own isolated key resource replicas or views to ensure that the resource access between processing units does not interfere with each other. Based on this, the cache service process can determine the target processing unit corresponding to the current access request according to the identification information of the access object and distribute the current access request to the target processing unit for processing. Thus, it can be ensured that all access requests for the same target object will be processed by the same processing unit, effectively ensuring the consistency of state processing. It can be seen that the unitized architecture inside the cache service process can disperse the processing load to multiple parallel processing units, thereby effectively reducing the lock waiting time, making the processing time of access requests more stable and predictable, and further improving the distribution of response latency, especially reducing the long-tail latency.

[0047] The data access device, electronic device, computer-readable storage medium, and computer program product provided by this application also have the above technical effects, which will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0048] To more clearly illustrate the technical solutions in the prior art and the embodiments of this application, the drawings required for the description of the prior art and the embodiments of this application will be briefly introduced below. Of course, the following drawings related to the embodiments of this application only show a part of the embodiments of this application. For those of ordinary skill in the art, without creative efforts, other drawings can be obtained according to the provided drawings, and the other obtained drawings also fall within the protection scope of this application.

[0049] Figure 1 It is a schematic structural diagram of a data access system provided by this application;

[0050] Figure 2 Schematic flowchart of a data access method provided by this application;

[0051] Figure 3 Schematic flowchart of another data access method provided by this application;

[0052] Figure 4 Schematic flowchart of yet another data access method provided by this application;

[0053] Figure 5 Schematic diagram of internal resource isolation principle of a cache service process provided by this application;

[0054] Figure 6 Schematic diagram of the structure of a data access device provided by this application;

[0055] Figure 7 Schematic diagram of the structure of another data access device provided by this application;

[0056] Figure 8 Schematic diagram of the structure of an electronic device provided by this application. Detailed implementation manners

[0057] The core of this application is to provide a data access method, which can achieve faster and more efficient data access in a distributed cache system; another core of this application is to provide a data access device, an electronic device, a computer-readable storage medium, and a computer program product, all of which have the above beneficial effects.

[0058] In order to describe the technical solutions in the embodiments of this application more clearly and completely, the following will introduce the technical solutions in the embodiments of this application in conjunction with the accompanying drawings in the embodiments of this application. Obviously, the described embodiments are only a part of the embodiments of this application, rather than all the embodiments. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

[0059] Please refer to Figure 1 , Figure 1A schematic structural diagram of a data access system provided by this application. The data access system is based on a distributed cache system architecture and mainly includes a cache client 100 and a cache service process 200. The two can be deployed on the same physical node or on different physical nodes. It can be understood that the data access method provided by this application is implemented by applying to this data access system. It should be noted that based on the different deployment methods of the cache client 100 and the cache service process 200, different data communication methods can be adopted between the two to achieve data access, and the specific implementation process can refer to the following embodiments.

[0060] An embodiment of this application provides a data access method.

[0061] Please refer to Figure 2 , Figure 2 A schematic flowchart of a data access method provided by this application. This data access method is applied to Figure 1 the cache client shown in the figure and may include the following S101 to S103.

[0062] S101: Determine the access object according to the access request and determine the target node where the access object is located.

[0063] This step aims to determine the access object and the target node where it is located. Specifically, for the access request initiated by the user, the cache client can first parse it to determine the access object, that is, the current access target, and further determine the target node where the access object is located. This target node is essentially a physical node. It can be understood that if the access object is exactly stored on the local node (the physical node where the cache client is deployed), the target node of the access object is the local node; if the access object is not stored on the local node, the target node of the access object is other physical nodes. Among them, determining whether the target node is the local node can be achieved by the cache client's affinity judgment.

[0064] In an embodiment of this application, determining the access object according to the access request and determining the target node where the access object is located may include: parsing the access request to obtain the identification information of the access object; determining the target cache partition where the access object is located according to the identification information; querying the cluster topology information to determine the target node to which the target cache partition belongs.

[0065] The embodiment of the present application provides an implementation method for determining the target node where the access object is located, that is, it can be determined by querying the cluster topology information. Specifically, the cluster topology information is used to characterize the connection method and organizational structure of each cache node (physical cache node, virtual cache node, etc.) in the distributed cache system. Based on this, the identification information of the access object can be obtained through the node access request, and then the target cache partition where the access object is located can be determined. Then, the target node to which the target cache partition belongs can be determined by querying the cluster topology information, and thus the target node where the access object is located can be obtained. In a possible implementation manner, the identification information of the access object can specifically be the object ID.

[0066] Furthermore, after determining the access object according to the access request and determining the target node where the access object is located as described above, it may further include: obtaining the node identifier of the target node and the node identifier of the local node; when the node identifier of the target node is the same as the node identifier of the local node, determining that the target node is the local node; when the node identifier of the target node is different from the node identifier of the local node, determining that the target node is not the local node.

[0067] The embodiment of the present application provides an implementation method for determining whether the target node is the local node. As described above, determining whether the target node is the local node can be implemented by the cache client for affinity judgment, and this affinity judgment process can be implemented by comparing the node identifiers. That is, when the node identifier of the target node is the same as the node identifier of the local node, the target node is the local node; when the node identifier of the target node is different from the node identifier of the local node, the target node is not the local node. In a possible implementation manner, the node identifier can specifically be the node IP address or the node hostname, as long as it is unique.

[0068] It should be noted that the affinity judgment can be triggered conditionally. Specifically, before obtaining the node identifier for affinity judgment, the specific value of the affinity identifier can be determined first. If the value is true, the node identifier is obtained for affinity judgment; if the value is false, there is no need to obtain the node identifier for affinity judgment. At this time, the conventional data access method based on the kernel protocol stack can be directly adopted. The conditions for setting the affinity identifier to true can include: the current access request is in the scenario of writing logs to the metadata server or in the scenario of the client writing small files for the first time, that is, small IO scenarios, latency-sensitive scenarios, etc.

[0069] S102: If the target node is the local node, save the access request to the shared memory, and send a request processing notification to the cache service process of the local node, so that the cache service process can obtain the access request in the shared memory for processing to implement data access.

[0070] This step aims to achieve data access in the scenario where the cache client and the cache service process are deployed on the same physical node. Specifically, since the cache client and the cache service process are deployed on the same physical node, if the implementation method of directly sending access requests is adopted, it will inevitably pass through the kernel network protocol stack, thus causing local access latency. Based on this, a shared memory can be pre-created, and the access requests can be saved in this shared memory. Then, a request processing notification can be directly sent to the cache service process of the local node through a low-overhead cross-process synchronization mechanism (such as semaphore, eventfd (a file descriptor used to notify events), named pipe, etc.). Thus, the cache service process can respond to this request processing notification and read the access requests from the shared memory for processing, thereby achieving data access. Therefore, this solution sends the access requests to the cache service process through the shared memory to achieve data access. This access path bypasses the kernel network protocol stack and can minimize local access latency.

[0071] S103: If the target node is not the local node, send the access request to the cache service process of the target node through the standard network communication protocol, so that the cache service process processes the access request to achieve data access.

[0072] This step aims to achieve data access in the scenario where the cache client and the cache service process are deployed on different physical nodes. Specifically, if the cache client and the cache service process are deployed on different physical nodes, the access request can be directly sent to the cache service process of the target node through the standard network communication protocol for processing to achieve data access. In a possible implementation, the standard network communication protocol can specifically be the RDMA (Remote Direct Memory Access) protocol or the TCP / IP (Transmission Control Protocol / Internet Protocol) protocol.

[0073] It can be seen that in the distributed cache system architecture including a cache client and a cache service process, for the access request to be sent to the cache service process, the cache client first performs an affinity judgment on it, that is, judges whether the target node where the current access object is located is the local node. If it is the local node, the access request can be sent to the cache service process through the shared memory to achieve data access. This path bypasses the kernel network protocol stack and can minimize the local access latency. If the target node is not the local node, the access request can be sent to the cache service process through the standard network communication protocol to achieve data access. Thus, it can be seen that through the affinity routing technology and the shared memory communication technology, this technical solution effectively bypasses the kernel network protocol stack, greatly reduces the communication latency between the cache client and the cache main replica on the same node, and helps to achieve faster and more efficient data access in the distributed cache system.

[0074] The embodiment of the present application provides another data access method.

[0075] Please refer to Figure 3 , Figure 3 which is a schematic flowchart of another data access method provided by the present application. This data access method is applied to Figure 1 the cache service process shown in the figure and may include the following S201 to S203.

[0076] S201: Receive the data access message sent by the cache client.

[0077] This step aims to receive the data access message, which is sent by the cache client to the cache service process. Specifically, the data access message can be a request processing notification for notifying the cache service process to actively obtain the access request for processing to achieve data access; the data access message can also be an access request for directly sending to the cache service process for processing to achieve data access. It should be noted that when the data access message is a request processing notification, the cache client and the cache service process are deployed on the same physical node; when the data access message is an access request, the cache client and the cache service process are deployed on different physical nodes.

[0078] S202: When the data access message is a request processing notification, obtain the access request from the shared memory according to the request processing notification for processing to achieve data access; the access request is saved to the shared memory by the cache client when it determines that the target node where the access object is located is the local node.

[0079] This step aims to achieve data access when the data access message is a request processing notification. As mentioned above, when the data access message is a request processing notification, the cache client and the cache service process are deployed on the same physical node. Specifically, since the cache client and the cache service process are deployed on the same physical node, if the implementation method of directly sending an access request is adopted, it is inevitable to go through the kernel network protocol stack, which will cause local access latency. Based on this, a shared memory can be created in advance, and the access request can be saved in this shared memory. Then, a request processing notification can be directly sent to the cache service process of the local node through a low-overhead cross-process synchronization mechanism (such as semaphore, eventfd (a file descriptor used to notify events), named pipe, etc.). Thus, the cache service process can respond to this request processing notification and read the access request from the shared memory for processing, thereby achieving data access. Therefore, this solution sends the access request to the cache service process through the shared memory to achieve data access. This access path bypasses the kernel network protocol stack and can minimize local access latency.

[0080] S203: When the data access message is an access request, process the access request to achieve data access; the access request is sent by the cache client to the cache service process when it determines that the target node where the access object is located is not the local node.

[0081] This step aims to achieve data access when the data access message is an access request. As mentioned above, when the data access message is an access request, the cache client and the cache service process are deployed on different physical nodes. At this time, the cache client can directly send the access request to the cache service process of the target node through the standard network communication protocol for processing to achieve data access.

[0082] In an embodiment of the present application, the cache service process is divided into multiple processing units;

[0083] Correspondingly, processing the access request to achieve data access may include: determining the identification information of the access object according to the access request; determining the target processing unit in the cache service process according to the identification information of the access object; and distributing the access request to the target processing unit for processing to achieve data access.

[0084] It can be understood that in a high-concurrency scenario, in order to process high-concurrency requests, the cache service process needs to manage shared resources internally. To ensure data consistency, a lock mechanism is usually used for concurrent control. However, lock contention will become a serious bottleneck, restricting the throughput and response speed of the cache service, and may cause long-tail latency problems.

[0085] Based on this, the embodiments of the present application unitize the internal units of the cache service process, that is, divide the cache service process into multiple parallel processing units with independent resources. Each processing unit has its own isolated copy or view of the critical resources, ensuring that the resource access between processing units does not interfere with each other. Thus, the cache service process can determine the target processing unit corresponding to the current access request according to the identification information of the access object, and distribute this current access request to the target processing unit for processing, thereby ensuring that all access requests for the same target object will be processed by the same processing unit, further ensuring the consistency of state processing.

[0086] It can be seen that the unitized architecture inside the cache service process can disperse the processing load to multiple parallel processing units, thereby effectively reducing the lock waiting time, making the processing time of access requests more stable and predictable, and further effectively improving the distribution of response latency, especially reducing the long-tail latency.

[0087] Furthermore, the identification information of the access object can be the object ID of the access object;

[0088] Correspondingly, determining the target processing unit in the cache service process according to the identification information of the access object may include: performing a hash calculation on the object ID of the access object to obtain a hash value; performing a modulo operation on the hash value by the total number of processing units in the cache service process to obtain a target modulo value; and using the processing unit whose identification hits the target modulo value as the target processing unit.

[0089] The embodiments of the present application provide an implementation method for determining the target processing unit in the cache service process according to the identification information of the access object. Specifically, the identification information of the access object can be the object ID of the access object. Thus, a hash operation can be performed on it using a preset hash function (such as CRC32) to obtain a hash value, and then the hash value is subjected to a modulo operation by the total number of processing units in the cache service process. At this time, the obtained target modulo value is the identification of the target processing unit, thereby realizing the determination of the target processing unit. That is, target_unit_index = hash(object_id) %num_cache_units, where target_unit_index is the identification of the target processing unit, object_id is the object ID of the access object, and num_cache_units is the total number of processing units in the cache service process.

[0090] It can be understood that in a high-concurrency scenario, the number of access requests received by each processing unit is not unique. To ensure the orderly processing of access requests, a message queue can be created for each processing unit to temporarily store each access request in the order of receipt, ensuring that each access request is processed in the order of receipt. Based on this, distributing the access request to the target processing unit for processing to implement data access can include: distributing the access request to the message queue of the target processing unit so that the target processing unit can obtain the access request from the message queue for processing to implement data access; where the message queue follows the first-in, first-out principle.

[0091] In addition, for each processing unit, during the process of processing access requests, if it needs to access other isolated resources (resources of other processing units), lock-free or lock-optimized technologies can be used for concurrent control. It can be understood that the lock-free or lock-optimized processing inside the processing unit significantly reduces the lock contention for critical shared resources, thereby greatly improving the request processing ability and overall throughput of a single cache service process in a high-concurrency scenario.

[0092] It can be seen that in the distributed cache system architecture including a cache client and a cache service process, for the access request that the cache client is about to send to the cache service process, the cache client first makes an affinity judgment on it, that is, judges whether the target node where the current access object is located is the local node. If it is the local node, the access request can be sent to the cache service process through shared memory to implement data access. This path bypasses the kernel network protocol stack and can minimize the local access latency; if the target node is not the local node, the access request can be sent to the cache service process through the standard network communication protocol to implement data access. Thus, it can be seen that through the affinity routing technology and the shared memory communication technology, this technical solution effectively bypasses the kernel network protocol stack, greatly reducing the communication latency between the cache client and the cache master replica of the same node, which helps to achieve faster and more efficient data access in the distributed cache system.

[0093] Based on the above embodiments, the embodiments of the present application provide another data access method.

[0094] Please refer to Figure 4 , Figure 4 which is a schematic flowchart of another data access method provided by the present application, and its implementation process is as follows:

[0095] 1. On the cache client side:

[0096] (1)Determine the target cache partition and the location of the primary replica: When the cache client (CacheClient) needs to access an object, it first determines the target cache partition to which the object belongs based on the object ID. Then, by querying the metadata service or the cluster topology information in the local cache, it obtains the physical node identifier (such as an IP address or a hostname) where the current primary replica of the target cache partition is located.

[0097] (2)Perform affinity judgment: CacheClient compares the node identifier where the target primary replica is located with its own node identifier. If the two are the same, it is determined as "Affinity Hit"; if they are different, it is determined as "Affinity Miss". Among them, the affinity judgment can be triggered in specific IO scenarios. For example, in small IO and latency-sensitive scenarios such as when the metadata server writes logs or the client writes small files for the first time, the affinity flag can be set to true.

[0098] (3)Select a communication channel:

[0099] Affinity Hit: CacheClient selects to use shared memory to communicate with the local cache service process (CacheServer). CacheClient writes the access request into the pre-mapped shared memory area and notifies CacheServer to process the access request through a low-overhead cross-process synchronization mechanism. This path bypasses the kernel network protocol stack and aims to minimize local access latency.

[0100] Affinity Miss: CacheClient selects to use the standard network communication protocol to send the access request to the CacheServer on the node where the target primary replica is located.

[0101] 2. On the cache service process side:

[0102] (1)Internal unitization: CacheServer is internally divided into multiple logically independent "processing units" (CacheUnit), and the number of processing units can be configured, usually set according to the number of CPU cores of the server.

[0103] (2)Resource isolation: Each CacheUnit has its own isolated copy or view of the key resources to ensure that the resource access between different processing units does not interfere with each other. As Figure 5 shown, Figure 5This is a schematic diagram of internal resource isolation for a cache service process provided by this application. These isolated resources at least include: independent message receiving endpoints / queues (Messenger), independent write request status record structures (writeMap), independently managed partition metadata information (ptInfo), etc. In addition, it may further include independent execution threads / coroutine pools, independent CPU cores, independent NUMA (Non Uniform Memory Access) cores, etc.

[0104] (3) Request distribution: When the CacheClient needs to send an access request, it extracts the object ID or other identifiers in the request. Then, it calculates its hash value using a deterministic hash function (such as CRC32) and routes the access request to the message queue of a uniquely determined CacheUnit for processing by taking the modulus of the total number of CacheUnits. This means that all access requests for the same target object will be processed by the same CacheUnit, ensuring the consistency of state processing. Among them, the CacheClient can directly establish a connection with the Messenger in the target processing unit and interact with messages.

[0105] (4) Concurrency control strategy: Inside each CacheUnit, when processing the access requests distributed to its message queue and accessing its isolated resources, lock-free or lock-optimized techniques can be used for concurrency control. Specifically, the lock-free technique means that inside the CacheUnit, atomic instructions provided by the CPU can be used to directly operate on shared data structures, or specifically designed lock-free data structures (such as lock-free queues, lock-free hash tables, etc.) can be used, or mechanisms such as read-write locks and optimistic locks can be used to reduce the probability and holding time of lock conflicts, aiming to significantly reduce or even eliminate the lock waiting overhead when accessing high-frequency shared resources inside the CacheUnit, thereby improving the processing capacity of a single CacheUnit and the concurrent throughput of the entire CacheServer.

[0106] 3. Response return:

[0107] After the access request is processed inside the corresponding CacheUnit (which may involve data reading and writing, status updating, etc.), the CacheServer returns the processing result or response to the corresponding CacheClient through the same communication channel (shared memory path or network path) as when the access request came.

[0108] It can be seen that the data access method provided by the embodiments of this application has the following technical advantages:

[0109] (1) Significantly reduce local access latency: Through affinity routing and shared memory communication, effectively bypass the kernel network protocol stack, greatly reducing the communication latency between the cache client and the cache master replica on the same node, especially suitable for latency-sensitive scenarios such as metadata server writing logs and first-time writing of small files.

[0110] (2) Greatly improve concurrent processing ability and throughput: The unitized architecture inside the cache service process distributes the processing load to multiple parallel units, and the lock-free or lock optimization processing inside the unit significantly reduces the lock contention for critical shared resources, thus greatly enhancing the request processing ability and overall throughput of a single cache service process in high-concurrency scenarios.

[0111] (3) Improve the response latency distribution (reduce long-tail latency): Reducing the lock waiting time helps to make the access request processing time more stable and predictable, thus improving the distribution of response latency, especially reducing long-tail latency.

[0112] (4) Improve system resource utilization: Reducing the network protocol stack overhead of local access can save CPU resources; reducing lock contention can avoid wasting CPU in spin waiting or busy waiting.

[0113] (5) Collaborative optimization: Combining client communication optimization and server internal concurrency optimization provides an end-to-end performance improvement solution, especially suitable for distributed cache application scenarios that need to meet both low-latency and high-concurrency requirements simultaneously.

[0114] The embodiment of the present application provides a data access device.

[0115] Please refer to Figure 6 , Figure 6 , which is a schematic structural diagram of a data access device provided by the present application. This data access device can be applied to the Figure 1 shown cache client, including:

[0116] Determination module 1, configured to determine the access object according to the access request and determine the target node where the access object is located;

[0117] First access module 2, configured to, if the target node is the local node, save the access request to the shared memory and send a request processing notification to the cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to implement data access;

[0118] Second access module 3, configured to, if the target node is not the local node, send the access request to the cache service process of the target node through the standard network communication protocol, so that the cache service process processes the access request to implement data access.

[0119] It can be seen that for the data access device provided in the embodiments of the present application, in a distributed cache system architecture including a cache client and a cache service process, the cache client first performs an affinity determination on the access request to be sent to the cache service process, that is, determines whether the target node where the current access object is located is the local node. If it is the local node, the access request can be sent to the cache service process through shared memory to achieve data access. This path bypasses the kernel network protocol stack and can minimize the local access latency. If the target node is not the local node, the access request can be sent to the cache service process through the standard network communication protocol to achieve data access. Thus, it can be seen that through the affinity routing technology and shared memory communication technology, this technical solution effectively bypasses the kernel network protocol stack, greatly reducing the communication latency between the cache client and the cache master replica on the same node, which helps to achieve faster and more efficient data access in the distributed cache system.

[0120] In an embodiment of the present application, the above determination module 1 may specifically be used to parse the access request to obtain the identification information of the access object; determine the target cache partition where the access object is located according to the identification information; and determine the target node to which the target cache partition belongs by querying the cluster topology information.

[0121] In an embodiment of the present application, the data access device may further include an identification module, which is used to, after determining the access object according to the access request and determining the target node where the access object is located, obtain the node identification of the target node and the node identification of the local node; when the node identification of the target node is the same as the node identification of the local node, determine that the target node is the local node; and when the node identification of the target node is different from the node identification of the local node, determine that the target node is not the local node.

[0122] For the introduction of the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate here.

[0123] The embodiments of the present application provide a data access device.

[0124] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of a data access device provided by the present application. This data access device can be applied to Figure 1 the cache service process shown, and includes:

[0125] A receiving module 4, which is used to receive the data access message sent by the cache client;

[0126] The first processing module 5 is configured to, when the data access message is a request processing notification, obtain an access request from the shared memory according to the request processing notification for processing to implement data access; the access request is saved to the shared memory by the cache client when it determines that the target node where the access object is located is the local node;

[0127] The second processing module 6 is configured to, when the data access message is an access request, process the access request to implement data access; the access request is sent by the cache client to the cache service process when it determines that the target node where the access object is located is not the local node.

[0128] It can be seen that for the data access device provided by the embodiments of the present application, in a distributed cache system architecture including a cache client and a cache service process, the cache client first performs an affinity judgment on the access request to be sent to the cache service process, that is, judges whether the target node where the current access object is located is the local node. If it is the local node, the access request can be sent to the cache service process through the shared memory to implement data access. This path bypasses the kernel network protocol stack and can minimize the local access latency; if the target node is not the local node, the access request can be sent to the cache service process through the standard network communication protocol to implement data access. Thus, it can be seen that this technical solution effectively bypasses the kernel network protocol stack through the affinity routing technology and the shared memory communication technology, greatly reducing the communication latency between the cache client and the cache master replica on the same node, and helping to achieve faster and more efficient data access in the distributed cache system.

[0129] In an embodiment of the present application, the cache service process is divided into multiple processing units; correspondingly, the above-mentioned second processing module 6 may include:

[0130] The first determination unit is configured to determine the identification information of the access object according to the access request;

[0131] The second determination unit is configured to determine the target processing unit in the cache service process according to the identification information of the access object;

[0132] The distribution unit is configured to distribute the access request to the target processing unit for processing to implement data access.

[0133] In an embodiment of the present application, the identification information of the access object is the object ID of the access object; correspondingly, the above-mentioned second determination unit may specifically be configured to perform a hash calculation on the object ID of the access object to obtain a hash value; perform a modulo operation on the total number of processing units of the cache service process using the hash value to obtain a target modulo value; and use the processing unit whose identifier hits the target modulo value as the target processing unit.

[0134] For the introduction of the device provided in the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate here.

[0135] Embodiments of the present application provide an electronic device.

[0136] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of an electronic device provided by the present application. The electronic device may include:

[0137] A memory 11 for storing computer programs;

[0138] A processor 10, when executing the computer program, can implement the steps of any of the above data access methods.

[0139] As Figure 8 shown, it is a schematic diagram of the composition structure of the electronic device. The electronic device may include: a processor 10, a memory 11, a communication interface 12, and a communication bus 13. The processor 10, the memory 11, and the communication interface 12 all complete their mutual communication through the communication bus 13.

[0140] In the embodiments of the present application, the processor 10 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array, or other programmable logic devices, etc. The processor 10 can call the program stored in the memory 11. Specifically, the processor 10 can execute the operations in the embodiments of the data access method.

[0141] The memory 11 is used to store one or more programs. The program may include program code, and the program code includes computer operation instructions. In the embodiments of the present application, the memory 11 stores at least programs for implementing the following functions:

[0142] Determine the access object according to the access request and determine the target node where the access object is located; if the target node is the local node, save the access request to the shared memory and send a request processing notification to the cache service process of the local node, so that the cache service process can obtain the access request in the shared memory for processing to implement data access; if the target node is not the local node, send the access request to the cache service process of the target node through the standard network communication protocol, so that the cache service process can process the access request to implement data access;

[0143] Or,

[0144] Receive the data access message sent by the cache client; when the data access message is a request processing notification, obtain the access request from the shared memory according to the request processing notification and process it to implement data access; the access request is saved to the shared memory by the cache client when it determines that the target node where the access object is located is the local node; when the data access message is an access request, process the access request to implement data access; the access request is sent to the cache service process by the cache client when it determines that the target node where the access object is located is not the local node.

[0145] In a possible implementation, the memory 11 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system and application programs required for at least one function, etc.; the data storage area may store the data created during use.

[0146] In addition, the memory 11 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device or other volatile solid-state storage devices.

[0147] The communication interface 12 may be an interface of the communication module for connecting to other devices or systems.

[0148] Of course, it should be noted that Figure 8 the structure shown does not constitute a limitation on the electronic device in the embodiments of the present application. In practical applications, the electronic device may include more or fewer components than Figure 8 those shown, or combine some components.

[0149] The embodiments of the present application provide a computer-readable storage medium.

[0150] The computer program stored on the computer-readable storage medium provided by the embodiments of the present application, when executed by a processor, can implement the steps of any of the above data access methods.

[0151] Among them, the computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or a data center that integrates one or more available media. For example, it may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape, etc.), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc., which can store computer program code.

[0152] For the introduction of the computer-readable storage medium provided by the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate here.

[0153] The embodiments of the present application provide a computer program product.

[0154] The computer program product provided by the embodiments of the present application includes computer programs / instructions. When the computer programs / instructions are executed by a processor, the steps of any of the above data access methods can be implemented.

[0155] Specifically, in the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product.

[0156] Among them, the computer program product may include one or more computer programs / instructions. When the computer program / instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application can be generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line, etc.) or a wireless manner (such as infrared, wireless, microwave, etc.).

[0157] For the introduction of the computer program product provided by the embodiments of the present application, please refer to the above method embodiments, and the present application will not elaborate here.

[0158] The various embodiments in the specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The same or similar parts among the various embodiments can be referred to each other. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the method part.

[0159] Those skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been generally described according to their functions in the above description. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0160] The steps of the methods or algorithms described in connection with the embodiments disclosed herein may be implemented directly in hardware, in software modules executed by a processor, or in a combination thereof. The software modules may be located in random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium well-known in the art.

[0161] The technical solutions provided in this application have been introduced in detail above. Specific examples are used herein to illustrate the principles and implementation manners of this application. The description of the above embodiments is only used to help understand the method and its core idea of this application. It should be noted that for those of ordinary skill in the art, without departing from the principle of this application, several improvements and modifications can be made to this application, and these improvements and modifications also fall within the protection scope of this application.

Claims

1. A data access method, characterized in that, Applied to a cache client, including: Determine an access object according to an access request, and determine a target node where the access object is located; If the target node is a local node, save the access request to the shared memory, and send a request processing notification to the cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to implement data access; If the target node is not the local node, send the access request to the cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to implement data access.

2. The data access method according to claim 1, wherein Determine an access object according to an access request, and determine a target node where the access object is located, including: Parse the access request to obtain identification information of the access object; Determine a target cache partition where the access object is located according to the identification information; Determine the target node to which the target cache partition belongs by querying the cluster topology information.

3. The data access method according to claim 1, wherein After determining an access object according to an access request and determining a target node where the access object is located, further include: Obtain the node identifier of the target node and the node identifier of the local node; When the node identifier of the target node is the same as the node identifier of the local node, determine that the target node is the local node; When the node identifier of the target node is different from the node identifier of the local node, determine that the target node is not the local node.

4. A data access method, characterized in that, Applied to a cache service process, including: Receive a data access message sent by a cache client; When the data access message is a request processing notification, obtain an access request in the shared memory according to the request processing notification for processing to implement data access; the access request is saved to the shared memory by the cache client when determining that the target node where the access object is located is a local node; When the data access message is the access request, process the access request to implement data access; the access request is sent to the cache service process by the cache client when determining that the target node where the access object is located is not a local node.

5. The data access method according to claim 4, wherein The cache service process is divided into multiple processing units; Correspondingly, processing the access request to implement data access includes: Determine the identification information of the access object according to the access request; Determine a target processing unit in the cache service process according to the identification information of the access object; Distribute the access request to the target processing unit for processing to implement data access.

6. The data access method according to claim 5, wherein The identification information of the access object is the object ID of the access object; Correspondingly, determining a target processing unit in the cache service process according to the identification information of the access object includes: Perform a hash calculation on the object ID of the access object to obtain a hash value; Perform a modulo operation on the total number of processing units of the cache service process using the hash value to obtain a target modulo value; Use the processing unit whose identification hits the target modulo value as the target processing unit.

7. A data access device, characterized in that, Applied to a cache client, including: A determination module, configured to determine an access object according to an access request and determine a target node where the access object is located; A first access module, configured to, if the target node is a local node, save the access request to a shared memory and send a request processing notification to a cache service process of the local node, so that the cache service process obtains the access request in the shared memory for processing to implement data access; A second access module, configured to, if the target node is not the local node, send the access request to a cache service process of the target node through a standard network communication protocol, so that the cache service process processes the access request to implement data access.

8. A data access device, characterized in that, Applied to a cache service process, including: A receiving module, configured to receive a data access message sent by a cache client; A first processing module, configured to, when the data access message is a request processing notification, obtain an access request in the shared memory according to the request processing notification for processing to implement data access; the access request is saved to the shared memory by the cache client when determining that the target node where the access object is located is a local node; A second processing module, configured to, when the data access message is the access request, process the access request to implement data access; the access request is sent to the cache service process by the cache client when determining that the target node where the access object is located is not a local node.

9. An electronic device, characterized in that, Including: A memory, configured to store a computer program; A processor, configured to implement the steps of the data access method according to any one of claims 1 to 6 when executing the computer program.

10. A computer-readable storage medium, characterized in that, A computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the data access method according to any one of claims 1 to 6 are implemented.