Data reading method, server and client

HK40078756BActive Publication Date: 2026-07-17TENCENT TECHNOLOGY (SHENZHEN) CO LTD

Patent Information

Authority / Receiving Office
HK · HK
Patent Type
Patents
Current Assignee / Owner
TENCENT TECHNOLOGY (SHENZHEN) CO LTD
Filing Date
2023-02-27
Publication Date
2026-07-17

AI Technical Summary

Technical Problem

In the Raft distributed system, reading data through the leader node can cause a bottleneck, resulting in low system throughput.

Method used

Adding read nodes to a Raft distributed system allows clients to read data from read nodes, reducing the workload of the leader node and increasing system throughput.

Benefits of technology

By introducing read nodes into the Raft distributed system, the pressure on the leader node is reduced, and the system's read throughput is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000_ABST
    Figure 00000000_0000_ABST
Patent Text Reader

Abstract

This application provides a data reading method, server, and client. The client determines the target node group containing the target data to be read, identifies the target read node from the nodes included in the target node group, and then sends a read request to the target read node to read the target data. After receiving the read request from the client, the target read node responds to the read request, obtains the target data, and sends the obtained target data back to the client. In other words, this application embodiment, by adding read nodes to a distributed system, enables the client to read data from the read nodes, thereby reducing the pressure on the leader node and improving system throughput. This solution is applicable to, but is not limited to, service platforms in social networking, e-commerce, multimedia, transportation (such as autonomous driving, maps, vehicle networking, etc.), healthcare, and education.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a data reading method, server, and client. Background Technology

[0002] With the advent of big data, distributed storage systems have emerged. Distributed storage systems typically maintain multiple replicas to achieve fault tolerance and improve system availability.

[0003] Raft is a type of distributed storage system and a distributed management system that supports the Raft protocol, a distributed consensus protocol. The Raft distributed data management system consists of a node group, which includes a leader node and multiple follower nodes.

[0004] Currently, the Raft distributed system reads data through the leader node, which can cause a bottleneck in the leader node and result in low system throughput. Summary of the Invention

[0005] This application provides a data reading method, server, and client. By adding read nodes, the client can read data from the read nodes, thereby improving system throughput.

[0006] Firstly, embodiments of this application provide a data reading method.

[0007] Applied to the target read node, the method includes:

[0008] Receive a read request sent by a client, wherein the read request is used to read target data, the target read node is a read node in a target node group where the target data is located, the target node group includes a leader node, at least one follower node and at least one read node, each follower node is connected to the leader node, and for each of the at least one read nodes, the read node is connected to the follower node or other read nodes;

[0009] Determine the type of the target data;

[0010] Obtain the target data according to the type of the target data;

[0011] The acquired target data is sent to the client.

[0012] In some embodiments, determining the first value based on the reciprocal of the node depth from the candidate point to the leader node includes:

[0013] The first value is determined by multiplying the reciprocal of the node depth from the candidate point to the leader node by the second value.

[0014] In some embodiments, the above method further includes:

[0015] After registering as a downstream node of the target upstream node, it receives heartbeat information sent by the target upstream node;

[0016] In response to the heartbeat information, a heartbeat response is sent to the upstream node of the target.

[0017] In some embodiments, the above method further includes:

[0018] If no heartbeat information is received from the target upstream node within a preset time period, a new target upstream node is determined from the N nodes of the target node group.

[0019] In some embodiments, the above method further includes:

[0020] After registering as a downstream node of the target upstream node, it receives the committed logs sent by the target upstream node, wherein the committed logs are the logs stored by the second number of nodes in the target node group;

[0021] Store the committed log.

[0022] In some embodiments, if the leader node in the target node group communicates with the leader node in the second node group, then the leader node in the target node group is the node among the nodes included in the target node group that is closest to the leader node of the second node group in terms of communication distance.

[0023] Secondly, embodiments of this application provide a data reading method applied to a client, the method comprising:

[0024] Determine the target node group where the target data to be read is located. The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read nodes, the read node is connected to the follower node or other read nodes.

[0025] From the nodes included in the target node group, determine the target read node;

[0026] Send a read request to the target read node, the read request being used to read the target data;

[0027] Receive the target data sent by the target read node.

[0028] In some embodiments, determining the target read node from the nodes included in the target node group includes:

[0029] Send a first request to each node in the target node group, the first request being used to request the node to send response information;

[0030] Receive the first response sent by the node in accordance with the first request;

[0031] The node that first sends the first response to the client in the target node group is identified as the target read node.

[0032] In some embodiments, if the type of the target data is non-real-time data, then the target data is obtained from the target reading point; if the type of the target data is real-time data, then the target data is obtained from the leader node.

[0033] In some embodiments, if the type of the target data is real-time data, then the target data is sent by the first node after the target read node sends the read request to the first node in the target node group, wherein the first node is a leader node or a follower node in the target node group, and if the first node is the leader node, then the target data is obtained by the first node from the first node, and if the first node is the follower node, then the target data is obtained by the first node from the leader node.

[0034] In some embodiments, the target read node is the read node among the at least one read nodes that responds to the client's request in the shortest time.

[0035] In some embodiments, the method further includes: if the client does not receive target data sent by the target read node within a preset time, or if the state of the target read node is unreadable, re-determining the target read node from the nodes included in the target node group.

[0036] Thirdly, embodiments of this application provide a server, including:

[0037] A receiving unit is configured to receive a read request sent by a client, wherein the read request is for reading target data, the target read node is a read node in a target node group where the target data is located, the target node group includes a leader node, at least one follower node and at least one read node, each follower node is connected to the leader node, and for each of the at least one read nodes, the read node is connected to the follower node or other read nodes;

[0038] A processing unit is configured to acquire the target data in response to the read request;

[0039] A sending unit is used to send the acquired target data to the client.

[0040] Fourthly, embodiments of this application provide a client, including:

[0041] The processing unit is configured to determine the target node group where the target data to be read is located, the target node group including a leader node, at least one follower node and at least one read node, each follower node being connected to the leader node, and for each of the at least one read nodes, the read node being connected to the follower node or other read nodes; and to determine the target read node from the nodes included in the target node group.

[0042] A sending unit is configured to send a read request to the target read node, the read request being used to read the target data;

[0043] A receiving unit is used to receive the target data sent by the target reading node.

[0044] Fifthly, embodiments of this application provide an electronic device, including a processor and a memory;

[0045] The memory is used to store computer programs;

[0046] The processor is configured to execute the computer program to implement the methods described in the first and / or second aspects above.

[0047] In a sixth aspect, embodiments of this application provide a computer-readable storage medium including computer instructions that, when executed by a computer, cause the computer to perform the method as described in the first aspect and / or the second aspect.

[0048] In a seventh aspect, embodiments of this application provide a computer program product comprising a computer program stored in a readable storage medium, wherein at least one processor of a computer can read the computer program from the readable storage medium, and the at least one processor executes the computer program to cause the computer to perform the methods described in the first aspect and / or the second aspect.

[0049] Based on the technical solution provided in this application, the client determines the target node group where the target data to be read is located, identifies the target read node from the nodes included in the target node group, and then sends a read request to the target read node to read the target data. Upon receiving the read request from the client, the target read node responds by acquiring the target data and sends the acquired data back to the client. That is, in this embodiment of the application, by adding read nodes to the distributed system, the client reads data from the read nodes, thereby reducing the pressure on the leader node and improving the system throughput. Attached Figure Description

[0050] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0051] Figure 1 This is a schematic diagram of a distributed system according to an embodiment of this application;

[0052] Figure 2 This is a schematic diagram of another distributed system involved in an embodiment of this application;

[0053] Figure 3 This is a schematic diagram of the structure of the Raft distributed system involved in an embodiment of this application;

[0054] Figure 4 A schematic flowchart illustrating a data reading method provided in an embodiment of this application;

[0055] Figure 5 This is a schematic diagram of the structure of a distributed system according to an embodiment of this application;

[0056] Figure 6 A schematic flowchart illustrating a data reading method provided in an embodiment of this application;

[0057] Figure 7 This is a schematic diagram of a map navigation architecture according to an embodiment of this application;

[0058] Figure 8 A schematic diagram of the structure of a server provided in an embodiment of this application;

[0059] Figure 9 A schematic diagram of the structure of a client provided in an embodiment of this application;

[0060] Figure 10 This is a block diagram of an electronic device involved in an embodiment of this application. Detailed Implementation

[0061] The technical solutions in the embodiments of this application will now be described with reference to the accompanying drawings.

[0062] It should be understood that, in the embodiments of the present invention, "B corresponding to A" means that B is associated with A. In one implementation, B can be determined based on A. However, it should also be understood that determining B based on A does not mean determining B solely based on A; B can also be determined based on A and / or other information.

[0063] In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0064] Furthermore, to facilitate a clear description of the technical solutions in the embodiments of this application, the terms "first" and "second" are used in the embodiments of this application to distinguish identical or similar items with substantially the same function and effect. Those skilled in the art will understand that the terms "first" and "second" do not limit the quantity or execution order, and the terms "first" and "second" are not necessarily different.

[0065] Figure 1 This is a schematic diagram of a distributed system involved in an embodiment of this application, such as... Figure 1 As shown, the system is a distributed system formed by connecting clients and multiple nodes 101 (any form of computing device in the network, such as servers and user terminals) through network communication.

[0066] Taking a distributed system as an example, see blockchain system. Figure 2 Nodes form a peer-to-peer (P2P) network. The P2P protocol is an application layer protocol running on top of the Transmission Control Protocol (TCP). In the distributed system, any machine, such as a server or terminal, can join and become a node 200. Node 200 includes a hardware layer, a middleware layer, an operating system layer, and an application layer. In actual use, client 300 reads and writes data from the blockchain through node 200.

[0067] See Figure 2 The functions of each node 200 in the blockchain system shown include:

[0068] 1) Routing: A basic function of nodes used to support communication between nodes.

[0069] In addition to routing capabilities, nodes can also have the following functions:

[0070] 2) Applications are deployed in the blockchain to implement specific business needs. They record data related to the implementation of functions to form record data, carry digital signatures in the record data to indicate the source of the task data, and send the record data to other nodes in the blockchain system. When other nodes successfully verify the source and integrity of the record data, they add the record data to a temporary block.

[0071] For example, the business logic implemented by the application includes:

[0072] 2.1) A wallet is used to provide the function of conducting electronic currency transactions, including initiating transactions (i.e., sending the transaction record of the current transaction to other nodes in the blockchain system; after other nodes successfully verify the transaction, they store the transaction record data in the temporary block of the blockchain as a response to acknowledge the validity of the transaction; of course, the wallet also supports querying the remaining electronic currency in the electronic currency address;

[0073] 2.2) Shared ledger, used to provide functions such as storage, query and modification of ledger data. It sends the record data of the operation on the ledger data to other nodes in the blockchain system. After the other nodes verify the validity, as a response to acknowledge the validity of the ledger data, they store the record data in a temporary block. They can also send confirmation to the node that initiated the operation.

[0074] 2.3) Smart contracts are computerized protocols that can execute the terms of a contract. They are implemented through code deployed on a shared ledger that executes when certain conditions are met. Based on actual business needs, the code is used to complete automated transactions, such as querying the logistics status of goods purchased by a buyer and transferring the buyer's electronic money to the merchant's address after the buyer signs for the goods. Of course, smart contracts are not limited to executing contracts for transactions; they can also execute contracts for processing received information.

[0075] 3) A blockchain consists of a series of blocks that are sequentially generated. Once a new block is added to the blockchain, it will not be removed. The blocks contain the data submitted by the nodes in the blockchain system.

[0076] In some embodiments, the distributed system described above can be Raft. Raft aims to completely replicate logs across all servers in the cluster, and these replicated logs are used by state machines. Assuming a program or application is expected to execute reliably, one way to achieve this is to ensure that the state machines on all servers in the cluster execute commands in the same way; here, a state machine typically refers to an input / output program or application. Logs can ensure that state machines execute the same commands.

[0077] In the Raft distributed system, each node has one of the following three states:

[0078] Leader: In the Raft protocol, multiple nodes form a group, and each group has one leader. The leader handles all client interactions and log replication and synchronization; there can only be one leader at any given time.

[0079] Followers: In a group, everyone except the leader is a follower. Followers are in a passive state; they do not initiate RPC calls, but only respond to RPC calls initiated by other servers.

[0080] Candidate: This is a state between leader and follower. It only appears temporarily during the election of a new leader. In the normal state of the system, there will only be one leader, and the other servers are followers.

[0081] Each server, whether leader or follower, maintains its own copy of the log. The log itself is divided into multiple entries, each uniquely identified by its index. Each entry contains two main pieces of information: First, each entry includes a command for the state machine to execute; the command format can be agreed upon by the client and the state. Second, each entry includes a term number, which represents the leader's term at the time the record was created. This term number monotonically increases as the number of log entries grows. Each server must ensure the log can be recovered after a crash, so the log itself is typically stored on disk or other stable storage media. Regardless of the server's updates, it must write the content to disk before receiving responses from other servers. If a record is stored on a majority of servers, such as entry 7, then the record is said to be committed. This is a crucial property of the Raft protocol. If a record is committed, it can be safely delivered to the state machine for execution; Raft guarantees the record's durability. Record 7 is committed, and all records preceding record 7 are also committed.

[0082] In practical applications, the client sends a command to the leader. The leader first writes the command to its own log and then sends remote calls to all other followers, appending entries. Typically, these calls are sent simultaneously to all servers for parallel execution, while the leaders wait for responses. Once the leader receives enough responses, it considers the command committed on a majority of servers and executes it. The leader then sends the command to its state machine, and after execution, returns the result to the client. Furthermore, once a server knows a record is committed, it informs other servers via subsequent append-entries remote calls. Therefore, eventually, each follower knows the record is committed and sends the command to its local state machine for execution. If a follower crashes or is in a slow-responding state, the leader repeatedly retryes the call until the follower recovers, at which point the leader can successfully retry. However, the leader doesn't need to wait for responses from every follower; it only needs a sufficient number of responses to ensure the record is stored on a majority of servers. This generally results in significant performance improvements. In other words, under normal circumstances, the leader can execute commands and return results to the client immediately once it receives responses from most of the fastest servers. For example, if a server is slow, this does not affect the speed at which the client receives a response, because the leader does not need to wait for that server indefinitely.

[0083] Figure 3 This is a schematic diagram of the structure of the Raft distributed system involved in an embodiment of this application, such as... Figure 3 As shown, the Raft distributed system consists of one leader node and at least one follower node.

[0084] In some embodiments, to ensure high availability of stateful services, Raft threads can be embedded within the services for tasks such as leader election and log synchronization. At least three services need to be started, each with one Raft thread. These three Raft nodes form a Raft group, which elects a leader, with the remaining two nodes acting as followers. Clients send write requests to the leader, which then synchronizes data to the two followers. A write operation is considered successful only if at least two of the three nodes successfully complete the write. Data is read directly from the leader.

[0085] However, this solution has a problem: both reading and writing are done through the leader, which limits the read throughput, resulting in low overall system throughput and low data reading efficiency.

[0086] To address the aforementioned technical issues, some implementations improve throughput by reading data from followers. However, the number of followers cannot be too large, otherwise it will affect cluster write performance. Furthermore, tests showed that adding two followers reduced write throughput by approximately 9%, for two reasons: first, the leader's load increased as it needed to synchronize logs with four followers; second, after five nodes, a successful commit from three nodes is required for the operation to be considered complete.

[0087] In another embodiment of this application, by adding read nodes, the leader and follower provide write services, and the reader provides read services, thereby reducing the workload of the leader and increasing the system's read throughput.

[0088] This solution can be applied to service platforms in areas including but not limited to social networking, e-commerce, multimedia, transportation (such as autonomous driving, mapping, vehicle networking, etc.), healthcare, and education.

[0089] The technical solutions of the embodiments of this application will be described in detail below through some examples. The following embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0090] First, combine Figure 4 This section introduces the process of adding read nodes to the system. Adding a read node to the system can be understood as the registration process of the read node.

[0091] Figure 4 This is a schematic flowchart of a data reading method provided in an embodiment of this application, as shown below. Figure 4 As shown, it includes:

[0092] S401. The target read node determines the target upstream node from the N nodes of the target node group.

[0093] Where N is a positive integer greater than 2, and the N nodes are the nodes in the target node group other than the target read node.

[0094] Figure 5 This is a schematic diagram of the structure of a distributed system according to an embodiment of this application, as shown below. Figure 5As shown, the distributed system includes a target node group, which comprises a leader node and at least one follower node, such as two follower nodes, follower1 and follower2. Each follower node is followed by at least one read node, and each read node may be followed by another read node. For example, follower1 includes two downstream read nodes, reader1 and reader2. Reader1 includes two downstream read nodes, reader5 and reader6, and reader2 includes two downstream read nodes, reader7 and reader8. Follower2 includes two downstream read nodes, reader3 and reader4. Reader3 includes two downstream read nodes, reader9 and reader10, and reader4 includes two downstream read nodes, reader11 and reader12.

[0095] Figure 5 Each node in the process can be understood as a server.

[0096] The above Figure 5 The target node group shown can be understood as a Raft distributed system.

[0097] It should be noted that the above Figure 5 This is merely an example; the structure of the distributed system involved in the embodiments of this application includes, but is not limited to, [other aspects]. Figure 5 As shown, for example, including more Figure 5 More or fewer follow nodes and / or read nodes.

[0098] The read nodes that follow the aforementioned follower node or read node can be understood as downstream nodes registered on the follower node or read node. For example, reader2 is a downstream node registered on follower1, and reader7 is a downstream node registered on reader2.

[0099] The registration process for each read node is the same. This embodiment of the application uses the registration process of one read node as an example for illustration. For ease of description, this read node is referred to as the target read node.

[0100] When adding a target read node to a target node group, the target read node first determines its target upstream node from the N nodes included in the target node group, that is, determines which upstream node among the N nodes the target read node should register on.

[0101] It should be noted that the target node group includes N nodes, including one leader node and at least one follower node. Optionally, it may also include at least one read node.

[0102] In some embodiments, in order to facilitate the selection of a leader node, the number of nodes participating in the leader election in the target node group is an odd number greater than 1. For example, if only the leader node and follower nodes participate in the leader election in the target node group, then the target node group includes at least two follower nodes.

[0103] In this embodiment of the application, the methods by which the target read node determines the target upstream node from the N nodes of the target node group include, but are not limited to, the following:

[0104] Method 1: Randomly select one node from N nodes as the target upstream node of the target read node.

[0105] Method 2: From the N nodes, excluding the leader node, arbitrarily select one node as the target upstream node of the target read node.

[0106] Method 3: Select the node with the fewest downstream nodes from the N-1 nodes (excluding the leader node) as the target upstream node of the target read node.

[0107] Method 4: The target read node determines the target upstream node according to the methods shown in S401-A1 to S401-A4 below:

[0108] S401-A1: For each of the N nodes, the target read node obtains the feature information of that node.

[0109] The node's characteristic information includes at least one of the following: the node's role information, the number of read nodes connected to the node, the node depth from the leader node, and the node's committed log index.

[0110] The role information of a node can be understood as whether the node is a leader node, a follower node, or a reader node.

[0111] The number of read nodes connected to a node can be understood as the number of read nodes directly connected to that node, for example... Figure 5 The read nodes connected after follow node 2 are read node 3 and read node 4, which means that the number of read nodes connected after follow node 2 is 2.

[0112] This application does not limit the method by which the target read node obtains the feature information of the node. For example, the target read node sends a request to the leader node in the target node group to obtain the feature information of each node, and the leader node sends the feature information of each node in the target node group to the target read node.

[0113] The node depth from the leader node is `depth`. Node depth represents the number of nodes traversed from the leader to that node. For example, above... Figure 5 The node depth of leader is 0, the node depth of follower2 is 1, and the node depth of reader4 is 2.

[0114] The committed logs of a node can be understood as how many nodes in the target node group have saved the logs that the node sent to other nodes in the target node group.

[0115] S401-A2: The target read node selects M candidate nodes from N nodes based on the node's feature information, where M is a positive integer.

[0116] In one possible implementation, if the node's feature information includes the node's role information, in order to reduce the workload of the leader node, the leader node cannot be connected to the read node after it is set. Therefore, the leader node is removed from the N nodes, and the remaining N-1 nodes are used as candidate nodes for the target upstream node.

[0117] In one possible implementation, if the node's characteristic information includes the node's role information and the number of read nodes connected to the node, then based on the node's role information and the number of read nodes connected to the node, non-leader nodes among the N nodes, and nodes whose number of read nodes connected to the node is less than a first number, are identified as candidate nodes. In other words, leader nodes and nodes whose number of read nodes connected to the node is greater than or equal to a first number are removed from the N nodes, and the remaining nodes are identified as candidate nodes for the target upstream node.

[0118] S401-A3. For each of the M candidate nodes, the target read node determines the weight of the candidate node based on its feature information.

[0119] This application does not limit the specific method for determining the weight of a candidate node based on its feature information.

[0120] In some embodiments, determining the weight of a candidate node based on its characteristic information in S401-A3 includes: determining the weight of the candidate node based on the node depth from the candidate node to the leader node and the log index of the candidate node that has been submitted.

[0121] In one possible implementation, determining the weight of a candidate node based on the node depth from the candidate node to the leader node and the log index of the candidate node's commits includes: determining a first value based on the reciprocal of the node depth from the candidate node to the leader node; and determining the weight of the candidate node based on the sum of the log index of the candidate node's commits and the first value.

[0122] This embodiment does not limit the method of determining the first value based on the reciprocal of the node depth from the candidate point to the leader node. In one example, the first value is determined by multiplying the reciprocal of the node depth from the candidate point to the leader node by the second value.

[0123] In one possible implementation, the weight of the candidate node is determined according to the following formula (1):

[0124] commit Index+(1 / depth)*c(1)

[0125] Where commit Index is the log index of the candidate point that has been committed, depth is the node depth from the candidate point to the leader node, (1 / depth) is the reciprocal of the node depth from the candidate point to the leader node, c is the second value, and (1 / depth)*c is the first value.

[0126] This embodiment does not limit the specific value of c, for example, c is 30.

[0127] As can be seen from (1) above, the larger the commit index, the faster the upstream node log synchronization and the greater the weight; the larger the depth, the deeper the node and the smaller the weight.

[0128] S401-A4: The target read node determines the candidate node with the largest weight among the M candidate nodes as the target upstream node of the target read node.

[0129] Based on the above steps, the target read node determines the weight of each of the M candidate nodes, and the candidate node with the largest weight is determined as the target upstream node of the target read node.

[0130] After determining the target upstream node using the above method, execute the following S401.

[0131] S402. The target read node sends a registration request to the target upstream node.

[0132] The registration request is used to request that the target upstream node be registered as a downstream node of the target upstream node.

[0133] S403. The upstream node of the target node registers the target read node as a downstream node.

[0134] In some embodiments, after successful registration, this application further includes:

[0135] S404. The upstream node of the target sends a heartbeat message to the target read node.

[0136] S405. In response to the heartbeat information, the target read node sends a heartbeat response to the target upstream node.

[0137] After registration, the target upstream node sends heartbeat information to the target read node to maintain the connection.

[0138] In some embodiments, if the upstream node sends a heartbeat message to the target read node but does not receive a heartbeat response from the target read node in a timely manner, the upstream node removes the target read node. After removal, the upstream node will not synchronize logs or send heartbeats to the target read node.

[0139] In some embodiments, if the target read node does not receive heartbeat information from the target upstream node within a preset time period, a new target upstream node is determined from the N nodes in the target node group. If the target read node cannot find a target upstream node, it will be directly set to an unhealthy state, at which point it will be unreadable.

[0140] In some embodiments, if the target upstream node changes its role from follower to leader, the target read node will also be removed.

[0141] In some embodiments, after successful registration, this application further includes:

[0142] S406. The upstream node of the target sends committed logs to the target read node. The committed logs are the logs stored by the second number of nodes in the target node group. The second number of nodes is the majority of nodes in the target node group. In this embodiment, the specific value of the second number is not limited.

[0143] S407, The target read node stores committed logs.

[0144] Specifically, the target upstream node starts a log synchronization thread for the target read node. This thread only synchronizes committed logs to the target read node. This differs from the Raft algorithm's log synchronization, where the logs synchronized by the leader to the followers are not committed logs, but logs generated by the leader. If the target upstream node were to synchronize uncommitted logs to the target read node, these uncommitted logs might roll back under certain circumstances, and the target read node would be unable to handle such complex situations. For example, if node 1 is currently the leader, generates log1, but crashes, and log1 has not yet been synchronized to the followers and is therefore uncommitted, and then node 2 is elected as the new leader, and node 1 restarts and becomes a follower, if reader1 is attached to node 1 and synchronizes the uncommitted log1 with node 1, inconsistencies will occur if reader1 applies this uncommitted log1, because log1 has not been written to the cluster, but clients can read it from reader1. Therefore, in this embodiment, the target upstream node only synchronizes committed logs to the target read node. Once the target read node receives the committed log, it applies the committed log and updates the database state; that is, the target read node saves the received committed log.

[0145] In this embodiment of the application, by adding read nodes, the leader and follower provide write services, and the reader provides read services. Theoretically, an unlimited number of readers can be added, so the throughput can be infinitely large.

[0146] In some embodiments, the reader is used to provide read services and does not participate in other operations of the Raftgroup consisting of the leader and followers, such as committing logs and elections.

[0147] The above text describes the registration process for read nodes.

[0148] In some embodiments, this application also utilizes priority configuration to bring the leader position closer together, thereby improving system throughput.

[0149] In some embodiments, if the leader node in the target node group communicates with the leader node in the second node group, then the leader node in the target node group is the node among all the nodes included in the target node group that is closest to the leader node of the second node group in terms of communication distance.

[0150] Specifically, in situations where two leaders need to communicate, such as the leaders of services 1 and 2 needing to communicate, and each service 1 and 2 has three nodes, typically distributed across different racks, if the leaders of services 1 and 2 are on different racks, the communication distance is large, resulting in high latency. To reduce communication latency, the leaders of services 1 and 2 can be distributed as close as possible, which requires controlling the leader's position. Specifically, the node in the target node group that is closest in communication distance to the leader node of the second node group is given the highest priority. Nodes with higher priority will become leaders first. Specifically, priority is included as a Raft configuration item. When selecting a leader, if a node has the highest priority and the most up-to-date logs, this node will not vote for other nodes, but other nodes will vote for it, thus electing it as the leader.

[0151] If a node elected as leader fails, another node will be elected as the new leader. If this node restarts and needs to reclaim the leader role, it cannot become the leader immediately after restarting because its logs are outdated. If it becomes the leader, it will cause data rollback and loss. Therefore, the solution is for the node to periodically check if its logs are up-to-date with the leader's. If they are, the node can then proactively initiate an election to reclaim the leader role.

[0152] In addition, priorities need to support dynamic updates. For example, if the leader node is found to be unstable or overloaded and unsuitable to be the leader, other nodes need to be set to higher priorities by modifying the Raft Configuration to update the priorities.

[0153] In this embodiment, a priority scheme is adopted, in which high-priority nodes are more likely to become leaders. This allows the two leaders to be distributed closer together. Tests have shown that if the two leaders are on the same rack or in the same data center, the throughput is increased by 14% compared to if they are on different racks or in different data centers.

[0154] The above steps can be understood as the construction process of a Raft-based distributed system. The registration process of each read node in the distributed system is the same as the registration process of the target read node. This allows any number of read nodes to be added as needed, thereby infinitely increasing the system's read throughput.

[0155] In this embodiment, during node registration, the target read node determines a target upstream node from N nodes in the target node group and sends a registration request to that upstream node to register. After successful registration, the upstream node sends a committed log to the target read node, enabling distributed consistency between the target read node and other nodes in the target node group. This allows clients to read data from the target read node, reducing the workload of the leader node and increasing system throughput.

[0156] The registration process for read nodes has been described above. The data reading process will now be described in conjunction with specific examples.

[0157] Figure 6 This is a schematic flowchart of a data reading method provided in an embodiment of this application, as shown below. Figure 6 As shown, the embodiments of this application include:

[0158] S601, The client determines the target node group where the target data to be read is located.

[0159] The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read nodes, the read node is connected to the follower node or other read nodes.

[0160] For example, the target node group is as described above. Figure 5 As shown in the figure, the specific details are described in the above embodiments and will not be repeated here.

[0161] S602. The client determines the target read node from the nodes included in the target node group.

[0162] In this embodiment, the methods by which the client determines the target read node include, but are not limited to, the following:

[0163] Method 1: The client randomly selects a read node from the nodes included in the target node group and determines it as the target read node.

[0164] Method 2, the above S602 includes the following steps S602-A1 to S602-A3:

[0165] S602-A1: The client sends a first request to each node in the target node group. This first request is used to request the node to send response information.

[0166] Optionally, the first request mentioned above is an empty request.

[0167] S602-A2, The client receiving node sends the first response based on the first request.

[0168] S602-A3: The client identifies the node in the target node group that first sends the first response to the client as the target read node.

[0169] As can be seen from the above, the target read node is the read node with the shortest response time to client requests among at least one read node included in the target node group.

[0170] According to the above method, after the client determines the target read node, it executes the following S603.

[0171] S603. The client sends a read request to the target read node, which is used to read the target data.

[0172] S604. The target read node responds to the read request and obtains the target data.

[0173] Depending on the application scenario, some clients need to read real-time data, while others do not, such as in log reading scenarios. Therefore, the methods for the target read node to obtain target data in S604 above include:

[0174] S604-A1, The target read node determines the type of target data.

[0175] For example, the target data type includes non-real-time data or real-time data.

[0176] S604-A2, The target read node obtains the target data according to the type of the target data.

[0177] Method 1: If the target read node determines that the target data is non-real-time data, then the target data is obtained from the target read point.

[0178] In this method, if the type of target data to be read is non-real-time data, the target reading node reads the target data from itself.

[0179] In some embodiments, if the client does not receive the target data sent by the target read node within a preset time, or if the target read node is in an unreadable state, the target read node is re-determined from the nodes included in the target node group.

[0180] For example, if the target read node is in an unhealthy state, then the target read node is unreadable. In this case, the client switches to another read node and reads the target data from the other read node.

[0181] For example, if a client times out while reading from the target read node, it means that the target read node may be down, and the client will switch to another read node to read the target data from the other read node.

[0182] Method 2: If the target read node determines that the type of the target data is real-time data, then it obtains the target data from the leader node.

[0183] In one specific implementation of Method 2, if the target data type is determined to be real-time data, obtaining the target data from the leader node includes the following steps 1 and 2:

[0184] Step 1: When the target data is determined to be real-time data, the target read node sends a read request to the first node in the target node group, where the first node is either the leader node or a follower node in the target node group.

[0185] Step 2: The target read node receives the target data sent by the first node. If the first node is the leader node, the target data is obtained from the first node. If the first node is the follower node, the target data is obtained from the leader node.

[0186] For scenarios requiring real-time data reading, the client sends a read request to the target read node. Upon receiving the read request, the target read node queries the leader for the latest committed log. It's important to note that while the target read node doesn't know who the leader is, it has the latest Raft configuration through log synchronization, thus knowing which nodes are in the target node group. It then randomly selects one of these nodes to query for the latest committed log.

[0187] If the randomly selected node is the leader, the leader will directly reply to the target read node with the information that the log has been committed.

[0188] If the randomly selected node is a follower, the follower will forward the read request to the leader, which will then send the target data to the follower, and the follower will then send the target data to the target read node.

[0189] S605, the target read node sends the acquired target data to the client.

[0190] After obtaining the target data according to the above steps, the target read node sends the obtained target data to the client, thereby realizing the reading of the target data.

[0191] In this embodiment of the application, when reading data, the client reads data from the read node instead of from the leader node, thereby reducing the workload of the leader node and improving the read throughput of the distributed storage system.

[0192] In some embodiments, S605 includes: if the target data is real-time data, the target read node saves the acquired target data and sends the target data to the client after the target data is successfully saved.

[0193] To further illustrate the technical solutions of the embodiments of this application, the solutions of the embodiments of this application are described below in conjunction with specific application scenarios.

[0194] For example, taking a map navigation application as an example, map navigation applications include business scenarios that are sensitive to real-time data reading, such as traffic guidance announcements, and business scenarios that are not sensitive to real-time data reading, such as traffic conditions and estimated time of arrival (ETA). This map navigation architecture adopts a microservice architecture, such as... Figure 7 As shown, it includes an access layer, a service layer, and a persistence layer. The access layer is used for clients to access the map navigation application, the service layer displays the services that the map navigation application can provide, and the persistence layer stores information such as... Figure 5 In the distributed system shown, to make microservices stateless, session-related data and request context data need to be placed in the persistence layer.

[0195] In practical applications, most navigation route-related data needs to be acquired in real time. For example, route data generated by the route sorting service can be obtained by the navigation guidance service based on the route ID. Scenarios with lower real-time requirements include traffic conditions and ETA calculation results. If the latest data is not available, the previous results can be displayed. For such scenarios, the read / write separation scheme in this application embodiment can achieve significant performance gains.

[0196] The data reading method provided in this application involves the client determining the target node group containing the target data to be read, identifying the target read node from the nodes included in the target node group, and then sending a read request to the target read node to read the target data. Upon receiving the read request from the client, the target read node responds by acquiring the target data and sends the acquired data back to the client. In other words, this application embodiment, by adding read nodes to the distributed system, enables the client to read data from the read nodes, thereby reducing the pressure on the leader node and improving the system throughput.

[0197] The preferred embodiments of this application have been described in detail above with reference to the accompanying drawings. However, this application is not limited to the specific details of the above embodiments. Within the scope of the technical concept of this application, various simple modifications can be made to the technical solutions of this application, and these simple modifications all fall within the protection scope of this application. For example, the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, this application will not describe the various possible combinations separately. Furthermore, various different embodiments of this application can also be arbitrarily combined, as long as they do not violate the spirit of this application, they should also be considered as the content disclosed in this application.

[0198] It should also be understood that, in the various method embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0199] The above text combined Figures 4 to 7 The method embodiments of this application are described in detail below, in conjunction with... Figures 8 to 10 The following describes in detail the device embodiments of this application.

[0200] Figure 8 This is a schematic diagram of a server provided in an embodiment of this application. The server can be understood as a target read node.

[0201] like Figure 8 As shown, server 30 includes:

[0202] The receiving unit 31 is used to receive a read request sent by the client, wherein the read request is used to read target data, the target read node is a read node in the target node group where the target data is located, the target node group includes a leader node, at least one follower node and at least one read node, each follower node is connected to the leader node, and for each of the at least one read nodes, the read node is connected to the follower node or other read nodes;

[0203] Processing unit 32 is configured to acquire the target data in response to the read request;

[0204] The sending unit 33 is used to send the acquired target data to the client.

[0205] In some embodiments, the processing unit 32 is specifically configured to determine the type of the target data; and to obtain the target data according to the type of the target data.

[0206] In some embodiments, the processing unit 32 is specifically configured to, if it is determined that the type of the target data is non-real-time data, obtain the target data from the target reading point; and if it is determined that the type of the target data is real-time data, obtain the target data from the leader node.

[0207] In some embodiments, the sending unit 33 is specifically used to send the read request to a first node in the target node group when it is determined that the target data is real-time data. The first node is a leader node or a follower node in the target node group.

[0208] The receiving unit 31 is specifically used to receive the target data sent by the first node, wherein if the first node is the leader node, the target data is obtained from the first node; if the first node is the follower node, the target data is obtained from the leader node.

[0209] In some embodiments, the sending unit 33 is specifically used to save the acquired target data if the target data is real-time data, and to send the target data to the client after the target data is successfully saved.

[0210] In some embodiments, the target read node is the read node among the read nodes included in the target node group that responds to the client's request in the shortest time.

[0211] In some embodiments, the processing unit 32 is further configured to determine the target upstream node of the target read node from the N nodes of the target node group, where N is a positive integer greater than 2, and the N nodes are the nodes other than the target read node among the nodes included in the target node group.

[0212] The aforementioned sending unit 33 is further configured to send a registration request to the target upstream node, the registration request being used to request the target upstream node to register as a downstream node of the target upstream node.

[0213] In some embodiments, the processing unit 32 is specifically configured to: obtain feature information of each of the N nodes, wherein the feature information includes at least one of the following: the node's role information, the number of read nodes connected to the node, the node depth from the node to the leader node, and the log index of the node's committed logs; select M candidate nodes from the N nodes based on the feature information, wherein M is a positive integer; determine the weight of each of the M candidate nodes based on the feature information of the candidate node; and determine the candidate node with the largest weight among the M candidate nodes as the target upstream node of the target read node.

[0214] In some embodiments, the processing unit 32 is specifically used to determine non-leader nodes among the N nodes and nodes whose number of connected read nodes is less than a first number, based on the role information of the node and the number of read nodes connected to the node.

[0215] In some embodiments, the processing unit 32 is specifically used to determine the weight of the candidate node based on the node depth from the candidate node to the leader node and the log index of the candidate node that has been submitted.

[0216] In some embodiments, the processing unit 32 is specifically configured to determine a first value based on the reciprocal of the node depth from the candidate point to the leader node; and to determine the weight of the candidate node based on the sum of the log index submitted by the candidate point and the first value.

[0217] In some embodiments, the processing unit 32 is specifically configured to determine the first value based on the product of the reciprocal of the node depth from the candidate point to the leader node and a second value.

[0218] In some embodiments, the receiving unit 31 is further configured to receive heartbeat information sent by the target upstream node after registering as a downstream node of the target upstream node;

[0219] The sending unit 33 is also used to send a heartbeat response to the target upstream node in response to the heartbeat information.

[0220] In some embodiments, the processing unit 32 is further configured to determine a new target upstream node from the N nodes of the target node group if it does not receive heartbeat information sent by the target upstream node within a preset time period.

[0221] In some embodiments, the receiving unit 31 is further configured to receive committed logs sent by the target upstream node after registering as a downstream node of the target upstream node, wherein the committed logs are logs stored by a second number of nodes in the target node group;

[0222] The processing unit 32 is also used to store the submitted logs.

[0223] In some embodiments, if the leader node in the target node group communicates with the leader node in the second node group, then the leader node in the target node group is the node among the nodes included in the target node group that is closest to the leader node of the second node group in terms of communication distance.

[0224] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be found in the method embodiments. To avoid repetition, further details are omitted here. Specifically, Figure 8 The server shown can correspond to the corresponding entity in executing the method of the embodiments of this application, and the foregoing and other operations and / or functions of each module in the server are respectively for implementing Figure 4 For the sake of brevity, the corresponding processes in each method are not described in detail here.

[0225] Figure 9 This is a schematic diagram of a client provided in an embodiment of this application.

[0226] like Figure 9 As shown, client 40 includes:

[0227] Processing unit 41 is used to determine the target node group where the target data to be read is located. The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read node, the read node is connected to the follower node or other read nodes. The processing unit 41 is used to determine the target read node from the nodes included in the target node group.

[0228] Sending unit 42 is used to send a read request to the target read node, the read request being used to read the target data;

[0229] The receiving unit 43 is used to receive the target data sent by the target reading node.

[0230] In some embodiments, the sending unit 42 is further configured to send a first request to each node in the target node group, the first request being used to request the node to send response information;

[0231] The receiving unit 43 is also configured to receive the first response sent by the node in accordance with the first request;

[0232] The processing unit 44 is specifically used to determine the node that first sends the first response to the client in the target node group as the target read node.

[0233] In some embodiments, if the type of the target data is non-real-time data, then the target data is obtained from the target reading point; if the type of the target data is real-time data, then the target data is obtained from the leader node.

[0234] In some embodiments, if the type of the target data is real-time data, then the target data is sent by the first node after the target read node sends the read request to the first node in the target node group, wherein the first node is a leader node or a follower node in the target node group, and if the first node is the leader node, then the target data is obtained from the first node, and if the first node is the follower node, then the target data is obtained from the leader node.

[0235] In some embodiments, the target read node is the read node among the at least one read nodes that responds to the client's request in the shortest time.

[0236] In some embodiments, the processing unit 41 is further configured to re-determine the target read node from the nodes included in the target node group if the client does not receive the target data sent by the target read node within a preset time, or if the state of the target read node is unreadable.

[0237] It should be understood that the device embodiments and method embodiments can correspond to each other, and similar descriptions can be found in the method embodiments. To avoid repetition, further details are omitted here. Specifically, Figure 9 The client shown can correspond to the corresponding subject in executing the method of the embodiments of this application, and the foregoing and other operations and / or functions of each module in the client 40 are respectively for implementing Figure 6 For the sake of brevity, the corresponding processes in each method are not described in detail here.

[0238] The apparatus of this application embodiment has been described above from the perspective of functional modules in conjunction with the accompanying drawings. It should be understood that this functional module can be implemented in hardware, in software instructions, or in a combination of hardware and software modules. Specifically, the steps of the method embodiments in this application can be completed by integrated logic circuits in the processor's hardware and / or by software instructions. The steps of the method disclosed in this application embodiment can be directly embodied as being executed by the hardware processor, or executed by a combination of hardware and software modules in the processor. Optionally, the software module can be located in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, etc. This storage medium is located in memory, and the processor reads information from the memory and, in conjunction with its hardware, completes the steps in the above method embodiments.

[0239] Figure 10 This is a block diagram of an electronic device involved in an embodiment of this application. The device may be a server or a client device.

[0240] Figure 10The illustrated electronic device 50 includes a memory 51, a processor 52, and a communication interface 53. The memory 51, processor 52, and communication interface 53 are communicatively connected to each other. For example, the memory 51, processor 52, and communication interface 53 can be connected via a network. Alternatively, the electronic device 50 may also include a bus 54. The memory 51, processor 52, and communication interface 53 are communicatively connected to each other via the bus 54. Figure 10 It is an electronic device 50 in which the memory 51, processor 52, and communication interface 53 are connected to each other via bus 54.

[0241] The memory 51 can be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 51 can store programs, and when the program stored in the memory 51 is executed by the processor 52, the processor 52 and the communication interface 53 are used to execute the above methods.

[0242] The processor 52 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), a graphics processing unit (GPU), or one or more integrated circuits.

[0243] Processor 52 can also be an integrated circuit chip with signal processing capabilities. In implementation, the method of this application can be completed through integrated logic circuits in the hardware of processor 52 or through software instructions. The processor 52 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. The software module can reside in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. This storage medium is located in memory 51, and processor 52 reads information from memory 51 and, in conjunction with its hardware, completes the method of this application embodiment.

[0244] Communication interface 53 uses transceiver modules, such as, but not limited to, transceivers, to enable communication between electronic device 50 and other devices or communication networks. For example, data sets can be acquired through communication interface 53.

[0245] When the aforementioned electronic device 50 includes a bus 54, the bus 54 may include a path for transmitting information between various components of the electronic device 50 (e.g., memory 51, processor 52, communication interface 53).

[0246] According to this application, a computer storage medium is also provided, on which a computer program is stored, which, when executed by a computer, enables the computer to perform the methods of the above-described method embodiments. Alternatively, embodiments of this application also provide a computer program product containing instructions, which, when executed by a computer, cause the computer to perform the methods of the above-described method embodiments.

[0247] According to this application, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the method described in the above-described method embodiments.

[0248] In other words, when implemented using software, it can be implemented wholly or partially in the form of a computer program product. This computer program product includes one or more computer instructions. When these computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. 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 one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0249] Those skilled in the art will recognize that the modules and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software 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 beyond the scope of this application.

[0250] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple modules or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or modules may be electrical, mechanical, or other forms.

[0251] The modules described as separate components may or may not be physically separate. The components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. For example, the functional modules in the various embodiments of this application may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.

[0252] Those skilled in the art will readily understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here. Furthermore, reference can be made between the various method embodiments and between the various device embodiments; identical or corresponding content in different embodiments can be mutually referenced, without further elaboration.

Claims

1. A data reading method, characterized in that, Applied to the target read node, the method includes: The system receives a read request from a client, wherein the read request is for reading target data. The target read node is a read node in a target node group where the target data is located. The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read nodes, the read node is connected to the follower node or other read nodes. The leader node and the follower node provide write services, and the read node provides read services. The target read node is the read node in the target node group that responds to the client's request in the shortest time. In response to the read request, the type of the target data is determined. If the type of the target data is determined to be non-real-time data, the target data is obtained from the target read node. If the type of the target data is determined to be real-time data, the target data is obtained from the leader node. The acquired target data is sent to the client.

2. The method according to claim 1, characterized in that, If the target data is determined to be real-time data, then obtaining the target data from the leader node includes: When the target data is determined to be real-time data, the read request is sent to the first node in the target node group, where the first node is either the leader node or a follower node in the target node group. The system receives the target data sent by the first node, wherein if the first node is the leader node, the target data is obtained from the first node; if the first node is the follower node, the target data is obtained from the leader node.

3. The method according to claim 1, characterized in that, Sending the acquired target data to the client includes: If the target data is real-time data, the acquired target data is saved, and after the target data is successfully saved, the target data is sent to the client.

4. The method according to any one of claims 1-3, characterized in that, The method further includes: From the N nodes of the target node group, determine the target upstream node of the target read node, where N is a positive integer greater than 2, and the N nodes are the nodes in the target node group other than the target read node; A registration request is sent to the target upstream node, the registration request being used to request the target read node to register as a downstream node of the target upstream node.

5. The method according to claim 4, characterized in that, Determining the target upstream node of the target read node from the N nodes of the target node group includes: For each of the N nodes, obtain the node's feature information, which includes at least one of the following: the node's role information, the number of read nodes connected to the node, the node depth from the node to the leader node, and the log index of the node's committed logs. Based on the feature information of the nodes, M candidate nodes are selected from the N nodes, where M is a positive integer; For each of the M candidate nodes, the weight of the candidate node is determined based on the feature information of the candidate node; The candidate node with the highest weight among the M candidate nodes is determined as the target upstream node of the target read node.

6. The method according to claim 5, characterized in that, The node's feature information includes the node's role information and the number of read nodes connected to the node. The step of selecting M candidate nodes from the N nodes based on the node's feature information includes: Based on the role information of the node and the number of read nodes connected to the node, non-leader nodes among the N nodes that have fewer than a first number of read nodes connected to them are identified as candidate nodes.

7. The method according to claim 5, characterized in that, Determining the weight of the candidate node based on its feature information includes: The weight of a candidate node is determined based on the node depth from the candidate node to the leader node and the log index of the candidate node that has been committed.

8. The method according to claim 7, characterized in that, The step of determining the weight of a candidate node based on the node depth from the candidate node to the leader node and the log index of the candidate node's commits includes: The first value is determined based on the reciprocal of the node depth from the candidate node to the leader node; The weight of the candidate node is determined by the sum of the log index submitted by the candidate node and the first value.

9. A data reading method, characterized in that, Applied to a client, the method includes: The target node group containing the target data to be read is determined. The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read nodes, the read node is connected to the follower node or other read nodes. The leader node and the follower node provide write services, and the read node provides read services. From the nodes included in the target node group, determine the target read node, which is the read node with the shortest response time to the client's request among the read nodes included in the target node group; Send a read request to the target read node, the read request being used to read the target data; The system receives the target data sent by the target read node. If the type of the target data is non-real-time data, then the target data is obtained from the target read node. If the type of the target data is real-time data, then the target data is obtained from the leader node.

10. A server, characterized in that, include: A receiving unit is configured to receive a read request sent by a client, wherein the read request is for reading target data, the target read node is a read node in a target node group where the target data is located, the target node group includes a leader node, at least one follower node and at least one read node, each follower node is connected to the leader node, for each of the at least one read node, the read node is connected to the follower node or other read nodes, the leader node and the follower node provide write services, the read node provides read services, and the target read node is the read node in the target node group that responds to the client's request in the shortest time. A processing unit is configured to respond to the read request, determine the type of the target data, and if the type of the target data is determined to be non-real-time data, obtain the target data from the target read node; if the type of the target data is determined to be real-time data, obtain the target data from the leader node. A sending unit is used to send the acquired target data to the client.

11. A client, characterized in that, include: The processing unit is used to determine the target node group where the target data to be read is located. The target node group includes a leader node, at least one follower node, and at least one read node. Each follower node is connected to the leader node. For each of the at least one read nodes, the read node is connected to the follower node or other read nodes. The leader node and the follower node provide write services, and the read node provides read services. And from the nodes included in the target node group, determine the target read node, which is the read node with the shortest response time to the client's request among the read nodes included in the target node group; A sending unit is configured to send a read request to the target read node, the read request being used to read the target data; The receiving unit is configured to receive the target data sent by the target read node. If the type of the target data is non-real-time data, then the target data is obtained from the target read node. If the type of the target data is real-time data, then the target data is obtained from the leader node.

12. An electronic device, characterized in that, include: Processor and memory; The memory is used to store computer programs; The processor is configured to execute the computer program to implement the method as described in any one of claims 1 to 8 or 9.