Request processing method and apparatus, and device cluster, program product and storage medium
By using load balancing mechanisms and mapping relationships to handle requests in the proxy cluster, the problems of uneven load on proxy nodes and global message ordering are solved, improving resource utilization and message order consistency. This approach is suitable for cloud services and software platforms.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
- Filing Date
- 2025-08-19
- Publication Date
- 2026-06-25
AI Technical Summary
In the field of data processing, uneven request traffic in a single partition leads to uneven load on proxy nodes, with some nodes being overloaded while others are underloaded, resulting in low resource utilization. Furthermore, existing methods for migrating or adding partitions cannot effectively guarantee the global ordering of messages.
By using the load balancing mechanism in the proxy cluster, the proxy nodes that meet the load balancing conditions are determined to handle the requests. The message data is mapped between the logical storage unit and the physical storage unit through the mapping relationship to ensure that the order of message data in the logical storage unit is consistent with the order of publication, thereby achieving global ordering.
It improves the resource utilization of proxy nodes, ensures the global orderliness of message data, and avoids load imbalance and message order disruption caused by partition migration and the addition of methods. It is suitable for cloud services and software platforms.
Smart Images

Figure CN2025115643_25062026_PF_FP_ABST
Abstract
Description
Methods, apparatus, equipment clusters, program products, and storage media for processing requests
[0001] This application claims priority to Chinese Patent Application No. 202411884289.8, filed on December 19, 2024, entitled "Method, Apparatus, Cluster of Devices, Program Product and Storage Medium for Processing Requests", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of data processing, and in particular to methods, apparatus, equipment clusters, program products, and storage media for processing requests. Background Technology
[0003] In the field of data processing, message queues are used to handle communication and asynchronous collaboration between applications. The queue model of a message queue includes a publish / subscribe model, where the sender of a message is called the publisher or producer, the receiver of a message is called the subscriber or consumer, and the container on the server that stores messages is called a topic. Publishers publish messages to a topic on the server through write requests, and at least one subscriber to that topic pulls messages from the topic on the server through read requests. A topic can include one or more partitions, each containing an ordered sequence of messages; partitions can also be called queues. Publishing a message to a topic means publishing a message to any partition within that topic.
[0004] In related technologies, write and read requests for a single partition are handled by the same broker node to ensure message ordering within that partition. If the request traffic is uneven across multiple partitions, resulting in traffic skew, the broker node corresponding to the partition with higher traffic will be overloaded, while the broker node corresponding to the partition with lower traffic will be idle, leading to low resource utilization of the broker nodes. Summary of the Invention
[0005] This application provides a method, apparatus, device cluster, program product, and storage medium for processing requests, which improves the resource utilization of proxy nodes during the request processing process.
[0006] Firstly, a method for processing requests is provided, applied to a service device. The service device provides request processing services through a proxy cluster, which includes multiple proxy nodes for processing requests, and these proxy nodes share a physical storage unit. The method includes: obtaining a first request from a logical storage unit; determining a first proxy node in the proxy cluster, wherein the first proxy node is a proxy node in the proxy cluster that meets load balancing conditions, the load balancing conditions including that the load difference between any two proxy nodes in the proxy cluster is less than a difference threshold; and processing the first request through the first proxy node, wherein the first request is a write request or a read request. The logical storage unit is used to manage message data based on a mapping relationship. The message data is stored in the physical storage unit, and the mapping relationship indicates the relationship between at least one of the message data's location or publication time in the physical storage unit and the message data's location in the logical storage unit. The order of the message data's location in the logical storage unit is consistent with the order of the message data's publication.
[0007] This method processes requests for logical storage units by using proxy nodes in the proxy cluster that meet load balancing conditions, rather than binding requests for logical storage units to a single proxy node. Therefore, load balancing distributes requests for the same logical storage unit across different proxy nodes in the cluster, resulting in a relatively balanced load across the proxy nodes and improving resource utilization. Furthermore, by mapping message data between logical and physical storage units, and ensuring that the order of message data within the logical storage unit matches the order in which it was published, this method guarantees the global order of message data within the same logical storage unit.
[0008] In one possible implementation, the first request is a write request, which includes first message data. The write request is processed by the first proxy node by: writing the first message data to a first physical storage unit via the first proxy node; and obtaining a first mapping relationship for the first message data, which is used by any proxy node in the proxy cluster to read the first message data. While writing the first message data to the first physical storage unit, the mapping relationship for the first message data is obtained in real time to ensure the timeliness and accuracy of the mapping relationship acquisition. This allows the first message data to be read at any time through the mapping relationship, ensuring the timely reading of the first message data.
[0009] In one possible implementation, the write request further includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit. By carrying the first sequence identifier in the write request, the location of the first message data in the logical storage unit can be obtained based on the sequence identifier, thereby ensuring that the order of the message data in the logical storage unit is consistent with the publication order of the message data.
[0010] In one possible implementation, the method for obtaining the first mapping relationship of the first message data includes: writing a first processing record of the first message data into the log module of the logical storage unit, the first processing record including a first sequence identifier, an identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data, the log module being written with processing records of message data for the logical storage unit by any proxy node; sequentially scanning each processing record in the log module, and when the first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, determining the position of the first message data in the logical storage unit based on the current arrangement position of the logical storage unit and the length of the first message data, obtaining the first mapping relationship based on the position of the first message data in the logical storage unit and the first processing record, the second processing record including a sequence identifier of the processing record before the first sequence identifier.
[0011] Therefore, a log module is used to store the processing records of each message data in the logical storage unit. Then, each processing record in the log module is scanned sequentially to obtain the mapping relationship of each message data. Since different message data may be processed by different proxy nodes, and the processing speeds of different proxy nodes vary, the order of the processing records of each message data stored in the log module may differ from the publication order of the message data. Therefore, during the scanning process, the processing records of each message data are rearranged according to the sequence identifier, which indicates the publication order of the message data. This ensures that the position order of each message data in the logical storage unit is consistent with the publication order of the message data, satisfying the global ordering of the logical storage unit.
[0012] In one possible implementation, the method further includes: upon obtaining the mapping relationship of any message data in the logical storage unit, writing the mapping relationship of any message data into the metadata module of the logical storage unit, wherein the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data. Since the order in which the mapping relationships of any message data are obtained is consistent with the sequence identifier, writing each obtained mapping relationship into the metadata module ensures that the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data, making it more convenient to read the mapping relationships in the metadata module.
[0013] In one possible implementation, the method of sequentially scanning each processing record in the log module includes: sequentially scanning each processing record in the log module based on checkpoints, where checkpoints are used to mark the scan position for the log module, and the value of the checkpoint remains unchanged in the case of restart or fault recovery. Therefore, by marking the scan position using checkpoints and scanning according to the scan position marked by the checkpoints, duplicate scanning of each processing record in the log module can be avoided, and in the case of restart or fault recovery, scanning can continue from the last scan position based on the checkpoints, without having to re-scan from the beginning.
[0014] In one possible implementation, the method further includes: determining a message level in the logical storage unit based on the position of the first message data within the logical storage unit. The message level indicates the maximum readable position on the logical storage unit, and is used by any proxy node in the proxy cluster to process read requests from the logical storage unit. This allows the message level of the logical storage unit to be updated in real time based on the position of the acquired first message data, ensuring the accuracy of the message level.
[0015] In one possible implementation, the first request is a read request, which includes a logical read position. A mapping relationship indicates the relationship between the location of message data in the physical storage unit and the location of message data in the logical storage unit. The read request is processed by the first proxy node by reading the message data at the physical position corresponding to the logical read position, where the physical position is determined based on the logical read position and the mapping relationship. Thus, the correct reading of message data can be achieved through the mapping relationship.
[0016] In one possible implementation, the first request is a read request, which includes a read timestamp. The mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The first request is processed by the first proxy node by reading the message data at the physical location corresponding to the read timestamp, where the physical location is determined based on the read timestamp and the mapping relationship. Thus, the correct reading of the message data can be achieved through the mapping relationship.
[0017] In one possible implementation, the physical location is also determined based on the message level of the logical storage unit, which indicates the maximum readable location on the logical storage unit. Thus, the message level ensures that the determined physical location will not exceed the maximum readable location, avoiding read errors.
[0018] In one possible implementation, after any message data in the physical storage unit is deleted, the method further includes: deleting the mapping relationship of any message data; or, deleting the mapping relationship of any message data when the publication time of any message data reaches its aging time. This allows for flexible deletion of mapping relationships, preventing them from continuously occupying storage space.
[0019] In one possible implementation, the method further includes: obtaining a second request for a logical storage unit; and, if the number of proxy nodes in the proxy cluster changes, processing the second request through a second proxy node, wherein the second proxy node is a proxy node in the changed proxy cluster that meets the load balancing conditions. If the number of proxy nodes in the proxy cluster changes, for example, if the number of proxy nodes in the proxy cluster increases or decreases, subsequent requests can be directly distributed to the changed proxy cluster, achieving seamless scaling up or down of the proxy cluster for the user.
[0020] Secondly, embodiments of this application provide an apparatus for processing requests, the apparatus including at least one functional module for performing the method for processing requests as provided in the first aspect or any possible implementation thereof.
[0021] In one possible implementation, the device is applied to a service device that provides request processing services through a proxy cluster. The proxy cluster includes multiple proxy nodes for processing requests, and the multiple proxy nodes share a physical storage unit. The device includes: an acquisition module for acquiring a first request from a logical storage unit, the logical storage unit being used to manage message data based on a mapping relationship, the message data being stored in the physical storage unit, the mapping relationship indicating the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit, or the mapping relationship indicating the relationship between the publication time of the message data and the location of the message data in the logical storage unit, the order of the message data in the logical storage unit being consistent with the publication order of the message data; a determination module for determining a first proxy node in the proxy cluster, the first proxy node being a proxy node in the proxy cluster that meets load balancing conditions, the load balancing conditions including that the load difference between any two proxy nodes in the proxy cluster is less than a difference threshold; and a processing module for processing a first request through the first proxy node, the first request being a write request or a read request.
[0022] In one possible implementation, the first request is a write request, which includes first message data; the processing module is used to write the first message data to a first physical storage unit through a first proxy node; and to obtain a first mapping relationship of the first message data, which is used by any proxy node in the proxy cluster to read the first message data.
[0023] In one possible implementation, the write request further includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit.
[0024] In one possible implementation, the acquisition module is used to write a first processing record of the first message data into a log module of the logical storage unit. The first processing record includes a first sequence identifier, an identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data. The log module writes processing records of message data for the logical storage unit by any proxy node. The module sequentially scans each processing record in the log module. When a first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, the position of the first message data in the logical storage unit is determined based on the current arrangement position of the logical storage unit and the length of the first message data. The first mapping relationship is obtained based on the position of the first message data in the logical storage unit and the first processing record. The second processing record includes a sequence identifier for processing records before the first sequence identifier.
[0025] In one possible implementation, the acquisition module is further configured to, upon acquiring the mapping relationship of any message data in the logical storage unit, write the mapping relationship of any message data into the metadata module of the logical storage unit, wherein the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data.
[0026] In one possible implementation, the acquisition module is used to sequentially scan each processing record in the log module based on checkpoints, where checkpoints are used to mark the scan position for the log module, and the value of the checkpoint remains unchanged in the case of restart or fault recovery.
[0027] In one possible implementation, the device further includes: a determining module, configured to determine the message level of the logical storage unit based on the position of the first message data in the logical storage unit, the message level indicating the maximum readable position on the logical storage unit, the message level being used by any proxy node in the proxy cluster to process read requests for the logical storage unit.
[0028] In one possible implementation, the first request is a read request, which includes a logical read position and a mapping relationship indicating the relationship between the location of message data in the physical storage unit and the location of message data in the logical storage unit; the processing module is used to read message data at the physical position corresponding to the logical read position through the first proxy node, and the physical position is determined based on the logical read position and the mapping relationship.
[0029] In one possible implementation, the first request is a read request, which includes a read timestamp and a mapping relationship indicating the relationship between the publication time of the message data and the location of the message data in the logical storage unit; and a processing module, which is used to read the message data at the physical location corresponding to the read timestamp through the first proxy node, wherein the physical location is determined based on the read timestamp and the mapping relationship.
[0030] In one possible implementation, the physical location is also determined based on the message level of the logical storage unit, which indicates the maximum readable location on the logical storage unit.
[0031] In one possible implementation, after any message data in the physical storage unit is deleted, the apparatus further includes: a deletion module for deleting the mapping relationship of any message data; or, deleting the mapping relationship of any message data when the publication time of any message data reaches the aging time.
[0032] In one possible implementation, the acquisition module is further configured to acquire a second request for a logical storage unit; the processing module is further configured to process the second request through a second proxy node when the number of proxy nodes in the proxy cluster changes, wherein the second proxy node is a proxy node in the changed proxy cluster that meets the load balancing conditions.
[0033] Thirdly, embodiments of this application provide a computing device cluster, including at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device to cause the computing device cluster to perform a method for processing requests as provided in the first aspect or any possible implementation of the first aspect.
[0034] Fourthly, embodiments of this application provide a computer program or product containing instructions that, when executed by a computing device cluster, cause the computing device cluster to perform a processing request as provided in the first aspect or any possible implementation thereof. The computer program or product may be a software installation package, which can be downloaded and executed on the computing device cluster when the aforementioned functionality of the computing device cluster is required.
[0035] Fifthly, embodiments of this application provide a computer-readable storage medium including computer program instructions that, when executed by a cluster of computing devices, enable the cluster of computing devices to perform a method for processing requests as described in the first aspect or any possible implementation thereof. The storage medium includes, but is not limited to, volatile memory, such as random access memory, and non-volatile memory, such as flash memory, hard disk drive (HDD), and solid-state drive (SSD).
[0036] It should be understood that the beneficial effects achieved by the technical solutions of the second to fifth aspects of this application and their corresponding possible implementations can be found in the technical effects of the first aspect and its corresponding possible implementations described above, and will not be repeated here. Furthermore, the apparatus for processing requests mentioned in the second aspect can be the computing device cluster mentioned in the third aspect. Attached Figure Description
[0037] Figure 1 is a schematic diagram of a partition migration provided in related technologies;
[0038] Figure 2 is a schematic diagram of adding partitions provided in related technologies;
[0039] Figure 3 is a schematic diagram of the implementation environment of a method for processing requests provided in an embodiment of this application;
[0040] Figure 4 is a flowchart of a method for processing requests provided in an embodiment of this application;
[0041] Figure 5 is a schematic diagram of the distribution of request processing provided in an embodiment of this application;
[0042] Figure 6 is a schematic diagram of a request processing framework provided in an embodiment of this application;
[0043] Figure 7 is a schematic diagram of a write request processing procedure provided in an embodiment of this application;
[0044] Figure 8 is a schematic diagram of a data structure for processing records provided in an embodiment of this application;
[0045] Figure 9 is a schematic diagram of the processing records stored in a write-ahead logging (WAL) module provided in an embodiment of this application;
[0046] Figure 10 is a schematic diagram of a mapping relationship acquisition process provided in an embodiment of this application;
[0047] Figure 11 is a schematic diagram of a process for constructing a mapping relationship and updating message water levels according to an embodiment of this application;
[0048] Figure 12 is a schematic diagram of message data mapping provided in an embodiment of this application;
[0049] Figure 13 is a schematic diagram of a read request processing procedure provided in an embodiment of this application;
[0050] Figure 14 is a schematic diagram of a message data reading process provided in an embodiment of this application;
[0051] Figure 15 is a schematic diagram of the structure of a device for processing requests provided in an embodiment of this application;
[0052] Figure 16 is a schematic diagram of the hardware structure of a computing device provided in an embodiment of this application;
[0053] Figure 17 is a schematic diagram of the structure of a computing device cluster provided in an embodiment of this application;
[0054] Figure 18 is a schematic diagram of a connection method for a computing device cluster provided in an embodiment of this application. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0056] In most mainstream message queues, requests for a single partition are handled by the same broker node. When some partitions in a broker cluster experience exceptionally high request traffic, resulting in traffic skew, significant differences in load can occur between different broker nodes in the cluster. For example, some broker nodes may reach their bottlenecks while others remain idle, leading to slower request responses and low resource utilization.
[0057] Especially in the context of cloudification and serverless computing, the above problems become more prominent, requiring cloud vendors to incur higher resource costs and resulting in resource waste. Cloudification refers to migrating infrastructure resources such as computers, storage, and networks to the cloud, and using technologies such as cloud computing, cloud storage, and cloud networking to integrate and dynamically allocate these resources to form elastic, personalized, secure, and reliable cloud services, which are then provided to users. Serverless computing refers to running application code and logic in the cloud, where users do not need to deploy, configure, or manage servers; server resources are provided and managed by the cloud platform.
[0058] In related technologies, partitions of the same topic are migrated between broker nodes or the number of partitions within the same topic is increased to balance the distribution of partitions across broker nodes. For example, referring to the partition migration diagram in Figure 1, partition 0 (topic-B partition-0) in topic B is migrated from broker-0 node to broker-3, and partition-0 of topic-D is migrated from broker-1 node to broker-4. Thus, partitions on high-load broker nodes are migrated to low-load broker nodes, thereby balancing the load across broker nodes.
[0059] However, the smallest unit of load balancing in partition migration is the partition itself. Therefore, it still cannot balance the load when a single partition is under extremely high load. Furthermore, the partition migration process requires data synchronization. The resulting traffic surges and bandwidth contention can disrupt normal business operations, and when the amount of data to be synchronized is large, it can also lead to long migration times.
[0060] Referring to Figure 2, which illustrates the addition of partitions, topic-A partition-0 is split into five partitions: topic-Apartition-0 to topic-Apartition-4, with each partition located on a different broker node. Thus, by increasing the number of partitions in a topic, the newly added partitions are distributed across low-load broker nodes, achieving a load balancing effect.
[0061] However, adding partitions relies on client configuration to produce and consume messages in the newly added partitions. Otherwise, the new partitions will have no data, and the load will remain unbalanced across broker nodes. During client configuration, improper configuration may cause some messages to be skipped and not properly consumed. Furthermore, while messages within each partition are ordered, the order between different partitions is not guaranteed. Therefore, adding partitions within the same topic will disrupt the global ordering of the topic. Global ordering means that all messages in a topic must be consumed in the order they were produced, ensuring that the message order remains consistent from production to consumption.
[0062] This application provides a method for processing requests, achieving global ordering of message data while maintaining load balancing. The method provided in this application can be applied to cloud services, systems, or software platforms, such as message queue-type cloud services. The cloud service can be built on a public cloud, hybrid cloud, or private cloud.
[0063] Figure 3 is a schematic diagram of an implementation environment provided in an embodiment of this application. As shown in Figure 3, the implementation environment includes a terminal 101 and a server 102. The terminal 101 is directly or indirectly connected to the server 102 via a wireless network or a wired network. The terminal 101 can refer to one of a number of terminals or a collection of multiple terminals; the server 102 can be a single computing device, a cluster of computing devices, a virtual machine, or a container engine, etc. This embodiment of the application does not limit the number or type of each type of device in the implementation environment.
[0064] Terminal 101 can be at least one of a smartphone, desktop computer, augmented reality terminal, tablet computer, e-book reader, and laptop computer. Terminal 101 has an application installed and running that supports message queuing functionality. This application can be a client application, a browser application, etc., and is not limited thereto.
[0065] Server 102 can be a standalone physical server, a server cluster consisting of multiple physical servers, a distributed file system, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Server 102 is used to run message queues, providing background services for applications that support message queue functionality. In some embodiments, server 102 runs message queues through virtual machines, or through a container engine; this is not limited.
[0066] In some embodiments, the aforementioned wireless or wired networks utilize standard database technologies and / or protocols. Networks include, but are not limited to, data center networks, storage area networks (SANs), local area networks (LANs), metropolitan area networks (MANs), wide area networks (WANs), mobile, wired or wireless networks, private networks, or any combination of virtual private networks. In some implementations, technologies and / or formats, including Hypertext Markup Language (HTML), Extensible Markup Language (XML), etc., are used to represent data exchanged over the network. Furthermore, conventional encryption technologies such as Secure Sockets Layer (SSL), Transport Layer Security (TLS), Virtual Private Networks (VPNs), and Internet Protocol Security (IPsec) can be used to encrypt all or part of the link.
[0067] Figure 4 is a flowchart illustrating a method for processing requests according to an embodiment of this application. This method can be executed by a service device, such as server 102 in the implementation environment shown in Figure 3. The service device provides request processing services through a proxy cluster, which includes multiple proxy nodes for processing requests, and these proxy nodes share a physical storage unit. Referring to Figure 4, the method for processing requests includes steps 401-403.
[0068] Step 401: Obtain the first request of the logical storage unit. The logical storage unit is used to manage message data based on the mapping relationship. The message data is stored in the physical storage unit. The mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit. Alternatively, the mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The order of the message data in the logical storage unit is consistent with the publication order of the message data.
[0069] In this embodiment, a logical storage unit is used to implement the logical storage of message data, and a physical storage unit is used to implement the physical storage of message data. A mapping relationship is used to map message data between the logical storage unit and the physical storage unit. Different message data can be written to different physical storage units through different proxy nodes, but the message data maintains global order within the logical storage unit. Optionally, the method for obtaining a first request for a logical storage unit may include: receiving a first request for a logical storage unit sent by a client.
[0070] For example, a logical storage unit can correspond to a queue, a partition, or a topic in a message queue. A broker node corresponds to a broker node, responsible for handling requests. The broker node can run on a separate server, a virtual machine, or a container engine. There can be multiple message data items, and at least one message data item corresponds to a mapping relationship. For example, one message data item corresponds to one mapping relationship, or a batch of message data items corresponds to one mapping relationship, where the batch of message data items includes at least two message data items.
[0071] Step 402: Determine the first proxy node in the proxy cluster. The first proxy node is the proxy node in the proxy cluster that meets the load balancing conditions. The load balancing conditions include that the load difference between any two proxy nodes in the proxy cluster is less than the difference threshold.
[0072] The difference threshold can be set based on experience or adjusted flexibly according to the application scenario. The first proxy node satisfying the load balancing condition means that after the first request is processed by the first proxy node, the load changes among the various proxy nodes in the proxy cluster move towards the goal of load balancing; it does not mean that the current proxy cluster has already met the load balancing condition. In other words, the first proxy node satisfying the load balancing condition means that, compared to processing the first request through any other proxy node in the proxy cluster, processing the first request through the first proxy node results in a more balanced load across the proxy cluster.
[0073] This application does not limit the method of determining the first proxy node in the proxy cluster. Optionally, requests can be distributed to each proxy node in the proxy cluster through round-robin; or, requests can be distributed to each proxy node in the proxy cluster according to the business characteristics of different requests through methods such as hashing. In the process of distributing requests to each proxy node in the proxy cluster, the processing capabilities of different proxy nodes must also be considered to ensure that the proxy cluster achieves load balancing without exceeding the processing capabilities of the proxy nodes.
[0074] For example, taking broker nodes as the proxy nodes, refer to Figure 5 for a schematic diagram of request processing distribution. Figure 5 illustrates a proxy cluster consisting of 5 broker nodes. The entry point of the proxy cluster is the load balancing (LB) module. The LB module evenly distributes requests for logical storage units initiated by clients to all broker nodes in the proxy cluster. All broker nodes share the burden of processing requests, achieving the effect of load balancing.
[0075] Step 403: Process the first request through the first proxy node. The first request is either a write request or a read request.
[0076] Once the first proxy node that satisfies load balancing is identified, the first request can be processed through this first proxy node. Optionally, each proxy node in the proxy cluster processes requests in the same way. Taking the first proxy node processing the first request as an example, the method of proxy node processing requests will be illustrated. In this embodiment, the first request can be either a write request or a read request. A write request is used to write message data, and a read request is used to read message data. The method of the first proxy node processing the first request will differ depending on the type of request.
[0077] In scenario one, the first request is a write request, which includes the first message data.
[0078] In this scenario, the method for handling write requests through the first proxy node includes: writing the first message data to the first physical storage unit through the first proxy node; and obtaining the first mapping relationship of the first message data. The mapping relationship of the first message data indicates the relationship between at least one of the location or publication time of the first message data in the physical storage unit and the location of the first message data in the logical storage unit. The first mapping relationship is used by any proxy node in the proxy cluster to read the first message data.
[0079] Therefore, while writing the first message data to the first physical storage unit, the first agent node obtains the mapping relationship of the first message data in real time, ensuring the timeliness and accuracy of the mapping relationship acquisition, thereby enabling the first message data to be read at any time through the mapping relationship of the first message data, ensuring the timeliness of the first message data reading.
[0080] In this embodiment, the physical storage unit is shared among all proxy nodes, and each proxy node can access each physical storage unit. Optionally, one logical storage unit corresponds to one physical storage unit, and each proxy node writes the message data of the logical storage unit to the same physical storage unit. For example, both the first proxy node and the second proxy node write the message data of the logical storage unit to the first physical storage unit. Alternatively, one logical storage unit corresponds to one physical storage unit for each proxy node, that is, each proxy node includes a physical storage unit corresponding to the logical storage unit. For example, the first proxy node corresponds to the first physical storage unit, and the second proxy node corresponds to the second physical storage unit. The first proxy node writes the message data of the logical storage unit to the first physical storage unit, and the second proxy node writes the message data of the logical storage unit to the second physical storage unit.
[0081] In one possible implementation, the write request further includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit. By including the sequence identifier in the write request, the location of the first message data in the logical storage unit can be obtained based on the sequence identifier, thereby ensuring that the order of the message data in the logical storage unit is consistent with the publication order of the message data. The publication order can also be referred to as the production order, that is, the order in which the producers produce the message data.
[0082] For example, taking physical storage units as data files, as shown in Figure 5, each broker node includes a data file corresponding to a logical storage unit. After receiving a write request, each broker node writes the message data in the write request to the corresponding data file. The write request also includes an order identifier (order id) field, which is ordered and used to identify the publication order of the message data.
[0083] Taking write requests 1, 2, and 3 as shown in Figure 5 as examples, write request 1 includes message batch (msg-batch)-1 and order id=1; write request 2 includes msg-batch-2 and order id=2; and write request 3 includes msg-batch-3 and order id=3. Here, msg-batch represents message data, and order id represents the sequence identifier. Through load balancing by the LB module, write request 1 is distributed to broker1 node for processing, and msg-batch-1 is stored in data file 1; write request 2 is distributed to broker2 node for processing, and msg-batch-2 is stored in data file 2; and write request 3 is distributed to broker4 node for processing, and msg-batch-3 is stored in data file 4.
[0084] After writing the first message data to the first physical storage unit, the first proxy node can obtain the position range of the first message data within the first physical storage unit. This position range indicates the location of the first message data within the first physical storage unit. It can also obtain the largest timestamp in the first message data, which indicates the publication time of the first message data. For example, each time the proxy node writes a message data item, it can generate a corresponding processing record. The processing record includes, but is not limited to, a sequence identifier, a physical storage unit identifier, the location of the message data within the physical storage unit, and the publication time of the message data. Therefore, the mapping relationship of each message data item can be obtained through the processing record of each message data item.
[0085] Optionally, the method for obtaining the first mapping relationship of the first message data includes: writing the first processing record of the first message data into the log module of the logical storage unit, wherein the first processing record includes a first sequence identifier, an identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data, and the log module is written with processing records of message data for the logical storage unit by any proxy node; sequentially scanning each processing record in the log module, and when the first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, determining the position of the first message data in the logical storage unit based on the current arrangement position of the logical storage unit and the length of the first message data, obtaining the first mapping relationship based on the position of the first message data in the logical storage unit and the first processing record, wherein the second processing record includes processing records whose sequence identifier precedes the first sequence identifier.
[0086] Therefore, a log module is used to store the processing records of each message data in the logical storage unit. Then, each processing record in the log module is scanned sequentially to obtain the mapping relationship of each message data. Since different message data may be processed by different proxy nodes, and the processing speeds of different proxy nodes vary, the order of the processing records of each message data stored in the log module may differ from the publication order of the message data. Therefore, during the scanning process, the processing records of each message data are rearranged according to the sequence identifier, which indicates the publication order of the message data. This ensures that the position order of each message data in the logical storage unit is consistent with the publication order of the message data, satisfying the global ordering of the logical storage unit.
[0087] In this embodiment, the logical storage unit linearly stores each message data. For example, if the current arrangement position of the logical storage unit is 10, and the length of the first message data is 20, then the position of the first message data in the logical storage unit is 11-31. After determining the position of each message data in the logical storage unit, the message level of the logical storage unit can be updated based on the position of the first message data in the logical storage unit. The message level indicates the maximum readable position on the logical storage unit. For example, if the position of the first message data in the logical storage unit is 11-31, then the message level is updated to 31. Therefore, the message level of the logical storage unit can be updated in real time according to the obtained position of the first message data in the logical storage unit, ensuring the accuracy of the message level.
[0088] During the sequential scanning of each processing record in the log module, checkpoints can be used to mark the scanning position for the log module. This scan position refers to the location where the corresponding mapping relationship has been obtained after scanning. The checkpoint is updated once the mapping relationship for each scanned processing record is obtained. Therefore, marking the scan position with checkpoints and scanning according to the checkpoint-marked position avoids duplicate scanning of each processing record in the log module. The checkpoint value remains unchanged during restarts or fault recovery scenarios, allowing scanning to continue from the last scan position without starting from the beginning. After being scanned and read by the scanning module, processing records in the log module can be deleted directly, or deleted after a period of time.
[0089] In one possible implementation, the method further includes: upon obtaining the mapping relationship of any message data in the logical storage unit, writing the mapping relationship of any message data into the metadata module of the logical storage unit, wherein the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data. Since the order in which the mapping relationships of any message data are obtained is consistent with the sequence identifier, writing each obtained mapping relationship into the metadata module ensures that the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data, making it more convenient to read the mapping relationships in the metadata module.
[0090] For mapping relationships stored in the metadata module, these relationships can be selectively deleted after the corresponding message data is deleted. Optionally, after any message data in the physical storage unit is deleted, the method further includes: deleting the mapping relationship of that message data; or, deleting the mapping relationship of that message data when the publication time of any message data reaches its aging time. The aging time can be set based on experience or flexibly adjusted according to the application scenario. This allows for flexible deletion of mapping relationships, preventing them from continuously occupying storage space.
[0091] For example, referring to the request processing framework diagram shown in Figure 6, it includes a load balancer (LB) module, a broker cluster, a physical storage pool, a write-ahead logging (WAL) module, a scanner module, and a metadata module. The LB module is used to evenly distribute requests to the broker nodes for processing. Each broker node in the broker cluster receives requests from the LB module and performs corresponding business processing. The write request processing method includes: writing message data to the data file corresponding to the physical storage pool and writing processing records to the write-ahead logging (WAL) module.
[0092] A physical storage pool corresponds to a physical storage unit. Optionally, the physical storage pool is a pooled storage layer used to store persistent message data. Multiple broker nodes can jointly access the physical storage pool to read and write message data. Each broker's read and write operations on each logical storage unit will have one or more corresponding data files in the physical storage pool. Broker nodes can access the data files written by other brokers.
[0093] The WAL module corresponds to the log module and is used to store the data write records of the broker node in the data file, that is, to store the processing records of each message data mentioned above. Optionally, when the broker node writes message data to the data file, it also writes a processing record to the WAL module. Based on the writing process shown in Figure 5, the processing record includes the data file identifier (id), the data write position range, the order id, and the maximum timestamp. Among them, the data file id corresponds to the identifier of the first physical storage unit, the data write position range corresponds to the position of the first message data in the first physical storage unit, the order id corresponds to the first sequence identifier, and the maximum timestamp corresponds to the publication time of the first message data.
[0094] The scanning module can be an asynchronous scanning module. After startup, the scanning module is used to perform real-time scanning of the WAL module, sequentially read the processing records stored in the WAL module, construct a mapping relationship between logical storage units and data files based on the processing records, and write the mapping relationship into the metadata module for persistent storage.
[0095] The metadata module stores the mapping relationship between logical storage units and physical data files. After the scanner module scans the WAL module and constructs the mapping relationship, it writes it to the metadata module. The metadata module maintains distributed consistency; the data in the metadata module is consistent across multiple distributed broker nodes. Broker nodes read this mapping relationship from the metadata module; this mapping relationship can be called metadata. Specifically, by processing the order ID, the mapping relationship is organized according to the order ID, ensuring global ordering during message reading.
[0096] Taking the interaction between the client, LB module, broker node, physical storage pool, and WAL module in handling write requests as an example, refer to Figure 7 for a schematic diagram of the write request processing process. After receiving a write request for a logical partition from the client, the LB module forwards it to the backend broker node in a round-robin fashion. Upon receiving the write request, the broker node writes the message data to the data file corresponding to the logical partition, obtains the position range of the message data in the data file, and calculates the maximum timestamp in the message data. The broker node combines the data file ID, data position range, order ID, and maximum timestamp corresponding to this write operation into a processing record and writes the processing record to the WAL module.
[0097] One of the data structures for a processing record is shown in Figure 8. The processing record is stored in binary format. The data file id (data_file_id) field, with a length of 8 bytes, represents the id of the actual stored data file; the start offset field, with a length of 8 bytes, represents the starting position of the message data in the data file during this write operation; the end offset field, with a length of 8 bytes, represents the ending position of the message data in the data file during this write operation; the order id field, with a length of 8 bytes, represents the sequence number of the message data publication; and the timestamp field, with a length of 8 bytes, represents the largest timestamp in the message being written.
[0098] In this embodiment, the WAL module uses linear storage, with each processing record appended to the previous one. For example, the processing records stored in the WAL module can be as shown in Figure 9, where the number of processing records increases linearly in the direction of the arrows, and the storage position is represented by the offset. For the nth processing record with offset = n, it includes: data_file_1, local offset: 10-30, order id = 1, and timestamp = 946686602500. data_file_1 represents the identifier of the data file; local offset: 10-30 indicates that the message data is stored in data_file_1 within the range of 10-30; order id = 1 indicates that the order identifier is 1. In the four processing records shown in Figure 9, the offset order (n, n+1, n+2, and n+3) is inconsistent with the order id order (1, 3, 2, and 4). Therefore, during the process of obtaining the mapping relationship based on the processing records, the order needs to be readjusted according to the order id.
[0099] Taking the interaction between the scanning module, broker node, WAL module, and metadata module to obtain mapping relationships as an example, refer to Figure 10 for a schematic diagram of the mapping relationship acquisition process. The scanning module continuously reads the stored processing records from the WAL module and constructs mapping relationships based on these records. The scanning module writes the constructed mapping relationships to the metadata module for persistent storage. After successfully writing to the metadata module, the scanning module updates the checkpoint of the scanning WAL module, for example, by incrementing the WAL module's offset by 1. The broker node listens for data changes in the metadata module. When a change in the mapping relationship is detected, it reads the changed mapping relationship and updates the mapping relationship cached by the broker node. The broker node updates the message watermark (high watermark), i.e., the maximum data point visible to consumers, based on the latest logical position in the updated mapping relationship. During the scanning of the WAL module, if the scanning module finds processing records with discontinuous order IDs, it first temporarily stores the processing records. When it scans the processing record corresponding to the missing order ID, it parses and constructs the mapping relationship together, ensuring that the record order in the mapping relationship is consistent with the order ID order, thereby guaranteeing global ordering.
[0100] For example, the process of constructing the mapping relationship and updating the message watermark for the processing record shown in Figure 9 can be illustrated in Figure 11. The WAL module starts with checkpoint = n. Processing records with offset = n in the WAL module are scanned sequentially. Taking the current arrangement position of the logical storage unit as 9 as an example, the processing record with offset = n reads order id = 1 and local offset: 10-30, indicating that the length of message data 1 is 20. Therefore, the logical offset = 10-30, where logical offset = 10-30 represents the position of message data 1 in the logical storage unit as 10-30. The checkpoint is then updated to n+1. As shown in Figure 11, the physical offset that maps to logical offset = 10-30 includes data_file_1: 10-30, representing the position of message data 1 in the physical storage unit as 10-30 of data_file_1. Optionally, the mapping relationship also includes timestamps. Simultaneously, the logical high watermark (logical hw) is updated to 30.
[0101] Continue scanning the processing records with offset = n+1 in the WAL module. The current permutation position of the logical storage unit is 30. Read the processing record with offset = n+1 where order id = 3 and local offset: 5-25, indicating that the length of message data 3 is 20. Since order id = 3 and order id = 1 are not consecutive, temporarily store the processing record with offset = n+1 without obtaining the corresponding mapping relationship. Since no mapping relationship has been obtained, do not update the checkpoint for now.
[0102] Continue scanning the processing records with offset = n+2 in the WAL module. The current arrangement position of the logical storage unit is 30. Read the order id = 2 and local offset: 15-20 from the processing record with offset = n+2, which means that the length of message data 2 is 5. Then the logical offset of message data 2 is 30-35, where logical offset = 30-35 means that the position of message data 2 in the logical storage unit is 30-35. Update checkpoint = n+3. As shown in Figure 11, the physical offset corresponding to logical offset = 30-35 is data_file_4: 15-20, which means that the position of message data 1 in the physical storage unit is 15-20 of data_file_4. Since the temporarily stored order id = 3 is consecutive to order id = 2, based on the length of message data 3 being 20, continue to obtain the logical offset of message data 3: 35-55. The physical offset corresponding to logical offset = 35-55 is data_file_2: 5-25. Since the mapping relationship between the two processing records, offset = n+1 and offset = n+2, is obtained, checkpoint = n+2 is updated. Simultaneously, the logical high watermark (logical hw) is updated to 55.
[0103] In summary, the above process of handling write requests maps different message data within the same logical storage unit to different physical storage units. For example, as shown in Figure 12, message data at different points in a logical partition are mapped to different physical data files through mapping relationships. All physical data files together form a logically complete partition, which is associated with each other through mapping relationships.
[0104] Scenario 2: The first request is a read request, which includes a logical read position or a read timestamp.
[0105] When a read request includes a logical read position, the consumer reads message data based on the position range. The mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit. The method of processing read requests through the first proxy node includes: reading the message data at the physical position corresponding to the logical read position through the first proxy node, where the physical position is determined based on the logical read position and the mapping relationship.
[0106] When a read request includes a read timestamp, the consumer reads message data based on a time range. The mapping relationship indicates the relationship between the message data's publication time and its location in the logical storage unit. The first request is processed through the first proxy node by reading the message data at the physical location corresponding to the read timestamp, where the physical location is determined based on the read timestamp and the mapping relationship.
[0107] Whether reading message data based on a location range or a timestamp, the physical location must be determined based on the message level of the logical storage unit to ensure that the determined physical location does not exceed the maximum readable location and to avoid reading errors.
[0108] For example, consider a consumer reading message data based on a location range. Refer to Figure 13 for a schematic diagram of the read request processing. After receiving a read request for a logical partition from the client, the LB module forwards it to the backend broker node in a round-robin fashion. Upon receiving the read request, the broker node, based on the consumption location (corresponding to the logical read location) and message level specified in the read request, queries the cached mapping relationship for the data file and physical location corresponding to the consumption location; it then reads the message data corresponding to the physical location from the data file and returns the message data to the client.
[0109] In the request processing framework diagram shown in Figure 6, each broker node in the proxy cluster is also used to process read requests. Based on the mapping relationship in the metadata store module, it reads message data from the data file corresponding to the physical storage pool and returns the message data to the client. Taking a logical read position of logical offset: 35 in a read request as an example, refer to the message data reading process diagram shown in Figure 14. Based on the logical read position of logical offset: 35 and the message watermark logical hw: 55, the position on the logical storage unit to be read is 35-55. Looking up the mapping relationship cached in the metadata module, the physical point corresponding to logical offset: 35-55 is data_file_2: 5-25. Then, starting from position 2 of data file 2 in the physical storage pool, the message data is obtained by reading to position 25 of data file 2.
[0110] The above describes the implementation method of processing the first request through the first proxy node. Furthermore, in this embodiment, when scaling up or down the proxy cluster, it is only necessary to add or remove broker nodes from the proxy cluster, register the added broker nodes accordingly, and unregister the removed broker nodes, for example, by deleting their registration. Then, during the next request allocation, load balancing is performed on the broker nodes in the updated proxy cluster, so that the client is unaware of the scaling up or down of the proxy cluster. For example, by registering or unregistering broker nodes in the LB module, the LB will automatically perform dynamic load balancing on the registered broker nodes, without requiring client awareness or processing.
[0111] Optionally, after processing the first request through the first proxy node, the method further includes: obtaining a second request for a logical storage unit; and, if the number of proxy nodes in the proxy cluster changes, processing the second request through a second proxy node, wherein the second proxy node is a proxy node in the changed proxy cluster that meets the load balancing conditions. The method of processing the second request through the second proxy node is the same as the method of processing the first request through the first proxy node described above, and will not be repeated here.
[0112] The method provided in this application handles requests for logical storage units through proxy nodes in a proxy cluster that meet load balancing conditions, rather than binding requests for logical storage units to a single proxy node. Therefore, load balancing distributes requests for the same logical storage unit across different proxy nodes in the proxy cluster, resulting in a relatively balanced load among the proxy nodes and improving resource utilization. Furthermore, by mapping message data between logical and physical storage units, and ensuring that the order of message data within the logical storage unit matches the order of message data publication, the method guarantees the global orderliness of message data within the same logical storage unit.
[0113] The above describes the method for processing requests according to embodiments of this application. Corresponding to the above method, embodiments of this application also provide an apparatus for processing requests. This apparatus is applied to a service device, which provides request processing services through a proxy cluster. The proxy cluster includes multiple proxy nodes for processing requests, and the multiple proxy nodes share a physical storage unit. Optionally, the apparatus includes at least one functional module for executing the request processing method shown in Figure 4 above. Figure 15 is a schematic diagram of the structure of an apparatus for processing requests provided by an embodiment of this application. The apparatus for processing requests can implement the aforementioned request processing method through software, hardware, or a combination of both. It should be understood that the apparatus may include more additional modules than those shown or omit some of the modules shown, and embodiments of this application do not limit this. As shown in Figure 15, the apparatus for processing requests includes an acquisition module 1501, a determination module 1502, and a processing module 1503.
[0114] In one possible implementation, the acquisition module 1501 is used to acquire a first request from a logical storage unit. The logical storage unit is used to manage message data based on a mapping relationship. The message data is stored in a physical storage unit. The mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit. Alternatively, the mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The order of the message data in the logical storage unit is consistent with the publication order of the message data. The determination module 1502 is used to determine a first proxy node in the proxy cluster. The first proxy node is a proxy node in the proxy cluster that meets the load balancing conditions. The load balancing conditions include that the load difference between any two proxy nodes in the proxy cluster is less than a difference threshold. The processing module 1503 is used to process the first request through the first proxy node. The first request is a write request or a read request.
[0115] In one possible implementation, the first request is a write request, which includes first message data; the processing module 1503 is used to write the first message data to the first physical storage unit through the first proxy node; and to obtain a first mapping relationship of the first message data, which is used by any proxy node in the proxy cluster to read the first message data.
[0116] In one possible implementation, the write request further includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit.
[0117] In one possible implementation, the acquisition module 1501 is used to write a first processing record of the first message data into the log module of the logical storage unit. The first processing record includes a first sequence identifier, an identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data. The log module is used to write processing records of message data for the logical storage unit by any proxy node. The module sequentially scans each processing record in the log module. When the first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, the position of the first message data in the logical storage unit is determined based on the current arrangement position of the logical storage unit and the length of the first message data. The first mapping relationship is obtained based on the position of the first message data in the logical storage unit and the first processing record. The second processing record includes a sequence identifier for the processing record before the first sequence identifier.
[0118] In one possible implementation, the acquisition module 1501 is further configured to, upon acquiring the mapping relationship of any message data in the logical storage unit, write the mapping relationship of any message data into the metadata module of the logical storage unit, wherein the positional order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data.
[0119] In one possible implementation, the acquisition module 1501 is used to sequentially scan each processing record in the log module based on checkpoints. The checkpoints are used to mark the scan position for the log module, and the values of the checkpoints remain unchanged in the case of restart or fault recovery.
[0120] In one possible implementation, the device further includes: a determining module, configured to determine the message level of the logical storage unit based on the position of the first message data in the logical storage unit, the message level indicating the maximum readable position on the logical storage unit, the message level being used by any proxy node in the proxy cluster to process read requests for the logical storage unit.
[0121] In one possible implementation, the first request is a read request, which includes a logical read position and a mapping relationship indicating the relationship between the location of message data in the physical storage unit and the location of message data in the logical storage unit; the processing module 1503 is used to read the message data at the physical position corresponding to the logical read position through the first proxy node, and the physical position is determined based on the logical read position and the mapping relationship.
[0122] In one possible implementation, the first request is a read request, which includes a read timestamp and a mapping relationship indicating the relationship between the publication time of the message data and the location of the message data in the logical storage unit; the processing module 1503 is used to read the message data at the physical location corresponding to the read timestamp through the first proxy node, and the physical location is determined based on the read timestamp and the mapping relationship.
[0123] In one possible implementation, the physical location is also determined based on the message level of the logical storage unit, which indicates the maximum readable location on the logical storage unit.
[0124] In one possible implementation, after any message data in the physical storage unit is deleted, the apparatus further includes: a deletion module for deleting the mapping relationship of any message data; or, deleting the mapping relationship of any message data when the publication time of any message data reaches the aging time.
[0125] In one possible implementation, the acquisition module 1501 is further configured to acquire a second request for a logical storage unit; the processing module 1503 is further configured to process the second request through a second proxy node when the number of proxy nodes in the proxy cluster changes, wherein the second proxy node is a proxy node in the changed proxy cluster that meets the load balancing conditions.
[0126] The apparatus provided in this application handles requests for logical storage units through proxy nodes in a proxy cluster that meet load balancing conditions, rather than binding requests for logical storage units to a single proxy node. Therefore, load balancing distributes requests for the same logical storage unit across different proxy nodes in the proxy cluster, resulting in a relatively balanced load among the proxy nodes and improving resource utilization. Furthermore, by mapping message data between logical and physical storage units, and ensuring that the order of message data within the logical storage unit matches the order of message data publication, the apparatus guarantees the global orderliness of message data within the same logical storage unit.
[0127] It should be understood that the device shown in Figure 15 is only illustrated by the division of the above-described functional modules. In practical applications, the functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. Furthermore, the device and method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process and beneficial effects are detailed in the method embodiments, and will not be repeated here.
[0128] Furthermore, in the aforementioned request processing apparatus, the acquisition module 1501, the determination module 1502, and the processing module 1503 can all be implemented in software or in hardware. For example, the implementation of the acquisition module 1501 will be described below. Similarly, the implementation of the determination module 1502, the processing module 1503, and other modules can refer to the implementation of the acquisition module 1501.
[0129] As an example of a software functional unit, module 1501 may include code running on a computing instance. The computing instance may include at least one of a physical host (computing device), a virtual machine, or a container. Further, the aforementioned computing instance may be one or more. For example, module 1501 may include code running on multiple hosts / virtual machines / containers. It should be noted that the multiple hosts / virtual machines / containers used to run the code may be distributed within the same region or in different regions. Further, the multiple hosts / virtual machines / containers used to run the code may be distributed within the same availability zone (AZ) or in different AZs, each AZ including one or more geographically proximate data centers. Typically, a region may include multiple AZs.
[0130] Similarly, multiple hosts / virtual machines / containers used to run this code can be distributed within the same Virtual Private Cloud (VPC) or across multiple VPCs. Typically, a VPC is set up within a region. Communication between two VPCs within the same region, as well as between VPCs in different regions, requires a communication gateway to be set up within each VPC to enable interconnection between VPCs.
[0131] As an example of a hardware functional unit, the acquisition module 1501 may include at least one computing device. Alternatively, the acquisition module 1501 may also be a device implemented using an application-specific integrated circuit (ASIC) or a programmable logic device (PLD). The PLD may be implemented using a complex programmable logical device (CPLD), a field-programmable gate array (FPGA), generic array logic (GAL), or any combination thereof.
[0132] The multiple computing devices included in the acquisition module 1501 can be distributed in the same region or in different regions. Similarly, the multiple computing devices included in the acquisition module 1501 can be distributed in the same Availability Zone (AZ) or in different AZs. Likewise, the multiple computing devices included in the acquisition module 1501 can be distributed in the same VPC or in multiple VPCs. These multiple computing devices can be any combination of computing devices such as servers, ASICs, PLDs, CPLDs, FPGAs, and GALs.
[0133] It should be noted that, in other embodiments, the acquisition module 1501 can be used to execute any step in the method for processing requests. That is, the steps implemented by the acquisition module 1501, the determination module 1502, and the processing module 1503 can be specified as needed. The entire function of the request processing device is achieved by implementing different steps in the request processing method through the acquisition module 1501, the determination module 1502, and the processing module 1503 respectively. Furthermore, the request processing device and the request processing method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process is detailed in the method embodiments, which will not be repeated here.
[0134] This application also provides a computing device that can be configured as a server in the above-described implementation environment. Referring to FIG16, FIG16 is a schematic diagram of the hardware structure of a computing device provided in this application embodiment. As shown in FIG16, the computing device 1400 includes: a bus 1402, a processor 1404, a memory 1406, and a communication interface 1408. The processor 1404, the memory 1406, and the communication interface 1408 communicate with each other via the bus 1402. It should be understood that this application does not limit the number of processors and memories in the computing device 1400.
[0135] Bus 1402 can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, only one line is used in Figure 16, but this does not imply that there is only one bus or one type of bus. Bus 1402 can include pathways for transmitting information between various components of computing device 1400 (e.g., memory 1406, processor 1404, communication interface 1408).
[0136] The processor 1404 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0137] The memory 1406 may include volatile memory, such as random access memory (RAM). The processor 1404 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0138] The memory 1406 stores executable program code, and the processor 1404 executes the executable program code to implement the functions of the aforementioned acquisition module 1501, determination module 1302, and generation module 1303, thereby realizing the method for processing requests. That is, the memory 1406 stores instructions for executing the method for processing requests.
[0139] The communication interface 1408 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 1400 and other devices or communication networks.
[0140] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. This computing device can be configured as a server in the above-described implementation environment, such as a central server, an edge server, or a local server in a local data center.
[0141] Figure 17 is a schematic diagram of a computing device cluster provided in an embodiment of this application. As shown in Figure 17, the computing device cluster includes at least one computing device 1400. The memory 1406 of one or more computing devices 1400 in the computing device cluster may store the same instructions for executing a method for processing requests.
[0142] In some possible implementations, the memory 1406 of one or more computing devices 1400 in the computing device cluster may also store partial instructions for executing the method for processing the request. In other words, a combination of one or more computing devices 1400 can jointly execute the instructions for executing the method for processing the request.
[0143] It should be noted that the memory 1406 in different computing devices 1400 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the processing request device. That is, the instructions stored in the memory 1406 of different computing devices 1400 can implement the functions of one or more modules among the acquisition module 1501, the determination module 1502, and the processing module 1503.
[0144] In some embodiments, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 18 is a schematic diagram of a connection method for a computing device cluster provided in an embodiment of this application. As shown in Figure 18, two computing devices 1400 are connected via a network. Specifically, they are connected to the network through the communication interfaces in each computing device. In this type of possible implementation, the connection method between the computing device clusters shown in Figure 18 takes into account that the processing request method provided in this application involves a large amount of data processing. Therefore, the functions of the acquisition module 1501 and the determination module 1502 are delegated to one computing device, and the function of the processing module 1503 is delegated to the other computing device. For example, the memory 1406 in one computing device 1400 stores instructions for executing the functions of the acquisition module 1501 and the determination module 1502. The memory 1406 in the other computing device 1400 stores instructions for executing the function of the processing module 1503.
[0145] It should be understood that the functions of the computing device 1400 shown in Figure 18 can also be performed by multiple computing devices 1400.
[0146] This application also provides a computer program or product containing instructions. The computer program or product may be software, program, or product containing instructions capable of running on a computing device or stored on any usable medium. When the computer program or product is run on at least one computing device, it causes the at least one computing device to perform a method for processing a request.
[0147] This application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium capable of being stored by a computing device, or a data storage device such as a data center containing 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., DVD), or a semiconductor medium (e.g., solid-state drive). The computer-readable storage medium includes instructions that instruct the computing device to perform a method for processing a request.
[0148] It should be noted that all information (including but not limited to user device information, user personal information, etc.), data (including but not limited to data used for analysis, stored data, displayed data, etc.), and signals involved in this application have been authorized by the user or fully authorized by all parties, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant countries and regions. For example, the message data involved in this application was obtained with full authorization.
[0149] In this application, the terms "first," "second," etc., are used to distinguish identical or similar items that have substantially the same function and purpose. It should be understood that there is no logical or temporal dependency between "first," "second," and "nth," nor does it limit the quantity or execution order. It should also be understood that although the following description uses the terms "first," "second," etc., to describe various elements, these elements should not be limited by the terms. These terms are merely used to distinguish one element from another. For example, without departing from the various examples described, a first request may be referred to as a second request, and similarly, a second request may be referred to as a first request. Both a first request and a second request can be requests, and in some cases, they can be separate and distinct requests.
[0150] In this application, the term "at least one" means one or more, and the term "multiple" means two or more. For example, multiple phrases means two or more phrases.
[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0152] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, in the form of program structure information. This program structure information includes one or more program instructions. When these program instructions are loaded and executed on a computing device, the processes or functions according to the embodiments of this application are generated, in whole or in part.
[0153] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0154] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the protection scope of the technical solutions of the embodiments of this application.
Claims
1. A method of processing a request, characterized by, The method is applied to a service device that provides request processing services through a proxy cluster. The proxy cluster includes multiple proxy nodes for processing requests, and the multiple proxy nodes share a physical storage unit. The method includes: A first request is made to obtain a logical storage unit, which is used to manage message data based on a mapping relationship. The message data is stored in the physical storage unit. The mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit. Alternatively, the mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The order of the location of the message data in the logical storage unit is consistent with the publication order of the message data. In the proxy cluster, a first proxy node is determined. The first proxy node is a proxy node in the proxy cluster that meets the load balancing conditions. The load balancing conditions include that the load difference between any two proxy nodes in the proxy cluster is less than the difference threshold. The first request is processed through the first proxy node, and the first request is either a write request or a read request.
2. The method of claim 1, wherein, The first request is the write request, which includes first message data; processing the first request through the first proxy node includes: The first message data is written to the first physical storage unit through the first proxy node; Obtain a first mapping relationship for the first message data. The first mapping relationship is used by any proxy node in the proxy cluster to read the first message data.
3. The method of claim 2, wherein, The write request also includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit.
4. The method according to claim 2 or 3, characterized in that, The step of obtaining the first mapping relationship of the first message data includes: The first processing record of the first message data is written into the log module of the logical storage unit. The first processing record includes a first sequence identifier, the identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data. The log module is written with the processing record of the message data of the logical storage unit by any proxy node. Each processing record in the log module is scanned sequentially. When the first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, the position of the first message data in the logical storage unit is determined based on the current arrangement position of the logical storage unit and the length of the first message data. The first mapping relationship is obtained based on the position of the first message data in the logical storage unit and the first processing record. The second processing record includes processing records whose sequence identifiers precede the first sequence identifier.
5. The method of claim 4, wherein, The method further includes: If the mapping relationship of any message data in the logical storage unit is obtained, the mapping relationship of any message data is written into the metadata module of the logical storage unit, and the position order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data.
6. The method according to claim 4 or 5, characterized in that, The sequential scanning of each processing record in the log module includes: Based on checkpoints, each processing record in the log module is scanned sequentially. The checkpoints are used to mark the scan position for the log module, and the values of the checkpoints remain unchanged in the case of restart or fault recovery.
7. The method according to any of claims 1 to 6, characterized in that The method further includes: The message level of the logical storage unit is determined based on the position of the first message data in the logical storage unit. The message level indicates the maximum readable position on the logical storage unit. The message level is used by any proxy node in the proxy cluster to process the read request of the logical storage unit.
8. The method of claim 1, wherein, The first request is the read request, which includes a logical read position, and the mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit; The process of processing the first request through the first proxy node includes: The message data at the physical location corresponding to the logical read location is read through the first proxy node, and the physical location is determined based on the logical read location and the mapping relationship.
9. The method of claim 1, wherein, The first request is a read request, which includes reading a timestamp. The mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The process of processing the first request through the first proxy node includes: The message data at the physical location corresponding to the read timestamp is read through the first proxy node, and the physical location is determined based on the read timestamp and the mapping relationship.
10. The method according to claim 8 or 9, characterized in that, The physical location is also determined based on the message level of the logical storage unit, which indicates the maximum readable location on the logical storage unit.
11. The method according to any one of claims 1 to 10, characterized in that, After any message data in the physical storage unit is deleted, the method further includes: Delete the mapping relationship of any of the message data; or, if the publication time of any of the message data reaches the aging time, delete the mapping relationship of any of the message data.
12. The method of any one of claims 1-11, wherein, The method includes: A second request to obtain the logical storage unit; If the number of proxy nodes in the proxy cluster changes, the second request is processed by a second proxy node, which is a proxy node in the changed proxy cluster that meets the load balancing conditions.
13. An apparatus for processing a request, the apparatus comprising: Applied to a service device that provides request processing services through a proxy cluster, the proxy cluster including multiple proxy nodes for processing requests, the multiple proxy nodes sharing a physical storage unit, the device comprising: The acquisition module is used to acquire a first request from a logical storage unit. The logical storage unit is used to manage message data based on a mapping relationship. The message data is stored in the physical storage unit. The mapping relationship indicates the relationship between the position of the message data in the physical storage unit and the position of the message data in the logical storage unit. Alternatively, the mapping relationship indicates the relationship between the publication time of the message data and the position of the message data in the logical storage unit. The order of the positions of the message data in the logical storage unit is consistent with the publication order of the message data. The determination module is used to determine a first proxy node in the proxy cluster. The first proxy node is a proxy node in the proxy cluster that meets the load balancing conditions. The load balancing conditions include that the load difference between any two proxy nodes in the proxy cluster is less than a difference threshold. The processing module is used to process the first request through the first proxy node, wherein the first request is a write request or a read request.
14. The apparatus of claim 13, wherein, The first request is the write request, which includes first message data; the processing module is used to write the first message data into the first physical storage unit through the first proxy node; and to obtain a first mapping relationship of the first message data, which is used by any proxy node in the proxy cluster to read the first message data.
15. The apparatus of claim 14, wherein, The write request also includes a first sequence identifier, which indicates the publication order of the first message data and is used to obtain the location of the first message data in the logical storage unit.
16. The apparatus of claim 13 or 14, wherein, The acquisition module is used to write the first processing record of the first message data into the log module of the logical storage unit. The first processing record includes the first sequence identifier, the identifier of the first physical storage unit, the position of the first message data in the first physical storage unit, and the publication time of the first message data. The log module is written with the processing record of message data of any proxy node for the logical storage unit. Each processing record in the log module is scanned sequentially. When the first processing record is scanned and the mapping relationship corresponding to the second processing record has been obtained, the position of the first message data in the logical storage unit is determined based on the current arrangement position of the logical storage unit and the length of the first message data. The first mapping relationship is obtained based on the position of the first message data in the logical storage unit and the first processing record. The second processing record includes processing records whose sequence identifiers precede the first sequence identifier.
17. The apparatus of claim 16, wherein, The acquisition module is further configured to, upon acquiring the mapping relationship of any message data of the logical storage unit, write the mapping relationship of any message data into the metadata module of the logical storage unit, wherein the position order of the mapping relationships of multiple message data in the metadata module is consistent with the publication order of the multiple message data.
18. The apparatus of claim 16 or 17, wherein, The acquisition module is used to sequentially scan each processing record in the log module based on checkpoints. The checkpoints are used to mark the scan position for the log module, and the value of the checkpoints remains unchanged in the scenario of restart or fault recovery.
19. The apparatus of any of claims 13-18, wherein, The device further includes: The determination module is used to determine the message level of the logical storage unit based on the position of the first message data in the logical storage unit. The message level indicates the maximum readable position on the logical storage unit. The message level is used by any proxy node in the proxy cluster to process the read request of the logical storage unit.
20. The apparatus of claim 13, wherein, The first request is a read request, the read request includes a logical read position, and the mapping relationship indicates the relationship between the location of the message data in the physical storage unit and the location of the message data in the logical storage unit; The processing module is used to read message data at the physical location corresponding to the logical read location through the first proxy node, wherein the physical location is determined based on the logical read location and the mapping relationship.
21. The apparatus of claim 13, wherein, The first request is the read request, which includes reading a timestamp. The mapping relationship indicates the relationship between the publication time of the message data and the location of the message data in the logical storage unit. The processing module is used to read message data at the physical location corresponding to the read timestamp through the first proxy node, wherein the physical location is determined based on the read timestamp and the mapping relationship.
22. The apparatus of claim 20 or 21, wherein, The physical location is also determined based on the message level of the logical storage unit, which indicates the maximum readable location on the logical storage unit.
23. The apparatus of any of claims 13-22, wherein, After any message data in the physical storage unit is deleted, the device further includes: a deletion module, used to delete the mapping relationship of the message data; or, when the publication time of the message data reaches the aging time, to delete the mapping relationship of the message data.
24. The apparatus of any of claims 13-23, wherein, The acquisition module is further configured to acquire the second request of the logical storage unit; the processing module is further configured to process the second request through a second proxy node when the number of proxy nodes in the proxy cluster changes, wherein the second proxy node is a proxy node in the changed proxy cluster that meets the load balancing conditions.
25. A cluster of computing devices, characterized in that, The system includes at least one computing device, each computing device including a processor and a memory; the processor of the at least one computing device is configured to execute instructions stored in the memory of the at least one computing device to cause the cluster of computing devices to perform a method for processing a request as described in any one of claims 1-12.
26. A computer program product comprising instructions, wherein: When the instruction is executed by the computing device cluster, the computing device cluster performs the method for processing the request as described in any one of claims 1-12.
27. A computer readable storage medium, characterized in that, Includes computer program instructions, which, when executed by a cluster of computing devices, perform a method for processing a request as described in any one of claims 1-12.