Method and apparatus for processing messages
By creating the base container only when messages are being written in the container orchestration system and dynamically allocating resources using the FaaS service, the problem of resource waste in the message storage system during off-peak hours is solved, achieving dynamic storage and resource conservation.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- MIDEA GROUP CO LTD
- Filing Date
- 2022-04-22
- Publication Date
- 2026-05-05
AI Technical Summary
Existing message storage systems consume a large amount of CPU and memory resources during off-peak hours, leading to increased operating costs and wasted resources for businesses.
In the container orchestration system, basic containers are created for storage only when messages are written. Resources are dynamically allocated using Function as a Service (FaaS), storage nodes are determined through a hash consistency algorithm, and state information is synchronized using an epidemic protocol.
It enables dynamic storage when there is a need to write messages, avoiding the waste of fixed resources and saving system resource costs.
Smart Images

Figure CN114706699B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a message processing method and apparatus. Background Technology
[0002] In the existing system architecture of IT (Internet Technology) enterprises, message storage systems are generally used to implement the writing, storage, reading and querying of messages.
[0003] Existing message storage systems consume significant amounts of CPU (Central Processing Unit) and memory resources during operation. However, message services are only used during fixed time periods each day, with virtually no traffic during most other times. This results in a substantial waste of operational costs and resources for businesses. Summary of the Invention
[0004] This invention aims to at least solve one of the technical problems existing in the prior art. To this end, this invention proposes a message processing method that creates a basic container for message storage only when there is a message to write. When there is no message writing requirement, there is no need to consume fixed message storage resources, thereby avoiding the waste of fixed service resource costs and saving system resources.
[0005] The present invention also proposes a message processing apparatus.
[0006] The present invention also proposes an electronic device.
[0007] The present invention also proposes a non-transitory computer-readable storage medium.
[0008] The present invention also proposes a computer program product.
[0009] A message processing method according to a first aspect of the present invention includes: receiving a write request for a target message; determining a target physical node for storing the target message among the physical nodes based on node information of each physical node in a container orchestration system and storage information of the target message; creating a base container on the target physical node; and storing the target message in the target physical node based on the base container.
[0010] According to the message processing method of this invention, the target physical node for storing the target message is determined among the physical nodes of the container orchestration system, and a basic container is created on the target physical node. Based on the created basic container, the target message is stored in the target physical node, thus achieving the storage of the target message. Simultaneously, by creating the basic container for message storage only when there is a message write requirement, no fixed message storage resources are consumed when there is no message write requirement, achieving dynamic storage of the target message. This avoids wasting fixed service resource costs and saves system resources.
[0011] According to one embodiment of the present invention, storing the target message in the target physical node based on the base container includes: calling the message writing FaaS function in the FaaS service based on the base container to store the target message in the target physical node. By storing the target message in the target physical node through the message writing FaaS function in the FaaS service, the storage of the target message is achieved. Simultaneously, by calling the message writing FaaS function for message storage through the FaaS service, the message writing FaaS function is invoked to store messages when there is a message writing requirement. When there is no message writing requirement, no fixed message storage resources are consumed, thus saving system resources.
[0012] According to one embodiment of the present invention, creating a basic container on the target physical node includes: creating a first container group on the target physical node, and creating the basic container within the first container group. By creating a first container group on the target physical node and creating the basic container within the first container group, a foundation is provided for the subsequent storage of target messages on the target physical node.
[0013] According to one embodiment of the present invention, determining the target physical node for storing the target message among the physical nodes based on the node information of each physical node in the container orchestration system and the storage information of the target message includes: determining the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message based on a hash consistency algorithm; and determining the target physical node for storing the target message among the physical nodes based on the hash value of the node information of each physical node and the hash key value. By using the hash consistency algorithm to determine the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message, the target physical node for storing the target message is finally determined, providing a foundation for subsequent storage of the target message.
[0014] According to one embodiment of the present invention, after determining the target physical node among the physical nodes for storing the target message, the method further includes: storing the hash key value in the target physical node. By storing the hash key value of the storage information of the target message in the target physical node, subsequent querying and reading of the stored target message is facilitated.
[0015] According to one embodiment of the present invention, after storing the target message in the target physical node, the method further includes: receiving a request to retrieve the target message; determining the target physical node storing the target message based on the hash key value, and retrieving the target message from the target physical node. By determining the target physical node storing the target message using the hash key value of the storage information of the stored target message, and retrieving the target message from the target physical node, the retrieval of the target message is achieved.
[0016] According to one embodiment of the present invention, obtaining the target message from the target physical node includes: creating a second container group on the target physical node according to the scheduler of the FaaS service, and creating a watchdog container in the second container group; and calling a message reading FaaS function according to the watchdog container to obtain the target message. Obtaining the target message through the message reading FaaS function in the FaaS service achieves the acquisition of the target message. Simultaneously, by calling the message reading FaaS function through the FaaS service to obtain the message, the message reading FaaS function is invoked to store the message when there is a message reading requirement, and no fixed message storage resources are consumed when there is no message reading requirement, thus saving system resources.
[0017] According to one embodiment of the present invention, after storing the target message to the target physical node, the method further includes: obtaining the addresses of each physical node in the container orchestration system, and synchronizing the storage status information of each physical node in the container orchestration system according to the gossip protocol. By obtaining the addresses of each physical node in the container orchestration system and synchronizing the storage status information of each physical node in the container orchestration system according to the gossip protocol after the target message is stored, it is convenient to determine the message storage node based on the node information of each physical node in the container orchestration system when a message is subsequently received and written.
[0018] According to a second aspect of the present invention, a message processing apparatus includes: a message receiving module for receiving a write request for a target message; a storage node determining module for determining a target physical node for storing the target message among the physical nodes based on node information of each physical node in a container orchestration system and storage information of the target message; and a message storage module for creating a basic container on the target physical node and storing the target message in the target physical node based on the basic container.
[0019] According to the message processing apparatus of the present invention, the target physical node for storing the target message is determined among the physical nodes of the container orchestration system, and a basic container is created on the target physical node. Based on the created basic container, the target message is stored in the target physical node, thus achieving the storage of the target message. Simultaneously, by creating the basic container for message storage only when there is a message write requirement, no fixed message storage resources are consumed when there is no message write requirement, achieving dynamic storage of the target message. This avoids wasting fixed service resource costs and saves system resources.
[0020] An electronic device according to a third aspect of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the message processing method as described above.
[0021] According to a fourth aspect of the present invention, a non-transitory computer-readable storage medium is provided thereon storing a computer program that, when executed by a processor, implements the message processing method as described above.
[0022] A computer program product according to a fifth aspect of the present invention includes a computer program that, when executed by a processor, implements a message processing method as described above.
[0023] The above-described one or more technical solutions in the embodiments of the present invention have at least one of the following technical effects:
[0024] By identifying the target physical node among the physical nodes of the container orchestration system for storing target messages, and creating a basic container on the target physical node, the target message is stored in the target physical node according to the created basic container, thus achieving target message storage. Simultaneously, by creating the basic container for message storage only when there is a message write requirement, and avoiding the consumption of fixed message storage resources when there is no message write requirement, dynamic storage of target messages is achieved, thereby avoiding the waste of fixed service resource costs and saving system resources.
[0025] Additional aspects and advantages of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0026] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0027] Figure 1 This is a flowchart illustrating the message processing method provided in an embodiment of the present invention;
[0028] Figure 2 This is a schematic diagram of the message writing process provided in an embodiment of the present invention;
[0029] Figure 3 This is a schematic diagram of the structure of message status metadata provided in an embodiment of the present invention;
[0030] Figure 4 This is a schematic diagram of the message acquisition process provided in an embodiment of the present invention;
[0031] Figure 5 This is a schematic diagram of the structure of the message processing device provided in an embodiment of the present invention;
[0032] Figure 6 This is a schematic diagram of the structure of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0033] The embodiments of the present invention will be described in further detail below with reference to the accompanying drawings and examples. The following examples are for illustrative purposes only and should not be construed as limiting the scope of the invention.
[0034] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0035] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0036] Figure 1 This is a flowchart illustrating a message processing method provided in an embodiment of the present invention. (Refer to...) Figure 1 The message processing method provided in this embodiment of the invention may include:
[0037] Step 110: Receive the write request for the target message;
[0038] Step 120: Based on the node information of each physical node in the container orchestration system and the storage information of the target message, determine the target physical node among the physical nodes used to store the target message;
[0039] Step 130: Create a base container on the target physical node, and store the target message on the target physical node according to the base container.
[0040] The execution entity of the message processing method provided in this embodiment of the invention can be a FaaS service deployed in a container orchestration system. The following describes the technical solution of the invention in detail by taking the execution of the message processing method provided in this embodiment of the invention by a FaaS service.
[0041] It's important to note that container orchestration systems are used to manage containerized applications across multiple nodes in a cloud platform, and Kubernetes clusters are one type. The goal of Kubernetes clusters is to simplify and expedite the deployment of containerized applications, providing mechanisms for application deployment, planning, updating, and maintenance. FaaS (Function as a Service) services, relying on Kubernetes clusters, offer the ability to dynamically create function runtimes and invoke them for execution. All function runtimes in FaaS services do not require fixed allocation of server resources; they are dynamically allocated and destroyed only when a function call is needed. FaaS services enable on-demand dynamic scheduling of computing resources, thereby saving enterprises significant service resources and operational costs.
[0042] In step 110, a write request for an external target message is received based on the gateway of the FaaS service deployed in the container orchestration system.
[0043] The gateway for the FaaS service continuously listens for write requests to target messages from outside.
[0044] In step 120, the gateway of the FaaS service determines the target physical node for storing the target message based on the storage information of the target message and the node information of each physical node in the container orchestration system.
[0045] Optionally, for the target message to be written, the FaaS service gateway can query the number of physical nodes in the current cluster and the node information of each physical node through a container orchestration system such as the etcd component in a Kubernetes cluster. To obtain the node information of each physical node in the Kubernetes cluster and the storage information of the target message, a consistent hashing algorithm can be used to calculate the hash value of the node information of each physical node and the hash key value of the storage information of the target message. Based on the calculated hash values of the node information of each physical node and the hash key value, the specific physical node where the target message will be stored can be determined.
[0046] In step 130, after determining the target physical node for storing the target message, the FaaS service gateway creates a base container on the target physical node. Based on the created base container, the target message is stored in the target physical node.
[0047] Optionally, the base container can read the `index.json` file in the `host-path` directory of the target physical node's local storage volume to obtain the filename containing the latest written message. It then opens this chunk file, locates the file write pointer offset using the byte offset within the chunk file containing the latest written message, and writes the target message data at that position. If the chunk file size exceeds 64KB, a new chunk file is created. Subsequently, the contents of the `index.json` file are updated to store the target message.
[0048] After completing the local storage of the target message, the base container will continuously listen for message write requests from the FaaS service gateway. Once the listening time reaches a preset duration and no new message write requests are received, the base container will be automatically released to reduce system resource consumption.
[0049] The message processing method provided in this invention determines the target physical node for storing the target message among the physical nodes of the container orchestration system, creates a basic container on the target physical node, and stores the target message in the target physical node according to the created basic container, thus achieving the storage of the target message. Simultaneously, by creating the basic container for message storage only when there is a message write requirement, no fixed message storage resources are consumed when there is no message write requirement, achieving dynamic storage of the target message, thereby avoiding the waste of fixed service resource costs and saving system resources.
[0050] In one embodiment, storing the target message in the target physical node according to the base container includes: calling the message writing faas function in the Function as a Service (FaaS) according to the base container, and storing the target message in the target physical node.
[0051] After determining the target physical node for storing the target message, the message writing faas function in the faas service is called based on the underlying container to store the target message in the target physical node.
[0052] Understandably, FaaS services allow for dynamic creation and execution of functions by calling FaaS functions to store messages based on the need for writing target messages. This is because all functions in a FaaS service do not require fixed server resource allocation during runtime; they are only dynamically allocated and destroyed when a function call is required. By calling functions to store messages when there is a need to write them, and avoiding the consumption of fixed message storage resources when there is no need to write messages, enterprises avoid wasting fixed service resource costs and save system resources.
[0053] The message processing method provided in this embodiment of the invention stores the target message in the target physical node through the message writing Faas function in the Faas service, thereby realizing the storage of the target message. Simultaneously, by calling the message writing Faas function through the Faas service for message storage, the message storage function is invoked only when there is a message writing requirement, and no fixed message storage resources are consumed when there is no message writing demand, thus saving system resources.
[0054] In one embodiment, creating a base container on the target physical node includes: creating a first container group on the target physical node, and creating the base container in the first container group.
[0055] A container group is a pod within a container orchestration system. A pod is the smallest unit that can be created and deployed within a container orchestration system; it is an application instance within the system. A pod contains one or more containers, as well as shared resources such as storage and networking. Pods also support various container environments.
[0056] After determining the target physical node for message storage, the first step is to create a first container group (pod) on that node. Following this, a base container (the infrastructure container) is created within the first container group. Subsequent message storage operations are then performed through the infrastructure container.
[0057] The message processing method provided in this embodiment of the invention creates a first container group on the target physical node and a basic container in the first container group, which provides a foundation for the subsequent storage of target messages on the target physical node.
[0058] In one embodiment, determining the target physical node for storing the target message among the physical nodes based on the node information of each physical node in the container orchestration system and the storage information of the target message includes: determining the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message based on a hash consistency algorithm; and determining the target physical node for storing the target message among the physical nodes based on the hash value of the node information of each physical node and the hash key value.
[0059] After obtaining the node information of each physical node in the container orchestration system and the storage information of the target message, the target physical node for storing the target message is determined according to the hash consistency algorithm. Specifically, the hash value of the node information of each physical node and the hash key value of the target information are calculated according to the hash consistency algorithm. Based on the calculated hash value of the node information and hash key value of each physical node, the target physical node for storing the target message is determined.
[0060] The message processing method provided in this embodiment of the invention uses a hash consistency algorithm to determine the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message, thereby finally determining the target physical node in each physical node used to store the target message, providing a foundation for the subsequent storage of the target message.
[0061] In one embodiment, after determining the target physical node among the physical nodes for storing the target message, the method further includes: storing the hash key value in the target physical node.
[0062] After determining the hash key value of the target message's storage information based on the hash consistency algorithm, the hash key value of the target message's storage information is stored in the target physical node for subsequent querying or reading of the target message.
[0063] The message processing method provided in this embodiment of the invention facilitates subsequent querying and reading of the stored target message by storing the hash key value of the storage information of the target message in the target physical node.
[0064] In one embodiment, after storing the target message in the target physical node, the method further includes: receiving a request to retrieve the target message; determining the target physical node storing the target message based on the hash key value; and retrieving the target message from the target physical node.
[0065] Based on the FaaS service gateway, a request to retrieve a target message is received. This retrieval can include reading or querying the target message. Upon receiving the request, the target physical node storing the target message is determined based on the hash key value of the stored target message information, and the target message is retrieved from that target physical node.
[0066] The message processing method provided in this embodiment of the invention determines the target physical node storing the target message by using the hash key value of the storage information of the target message, and retrieves the target message from the target physical node storing the target message, thereby realizing the retrieval of the target message.
[0067] In one embodiment, obtaining the target message from the target physical node includes: creating a second container group on the target physical node according to the scheduler of the FaaS service, and creating a watchdog container in the second container group; and calling the message reading FaaS function according to the watchdog container to obtain the target message.
[0068] A container group is a pod within a container orchestration system. A pod is the smallest unit that can be created and deployed within a container orchestration system; it is an application instance within the system. A pod contains one or more containers, as well as shared resources such as storage and networking. Pods also support various container environments.
[0069] Optionally, the scheduler of the FaaS service creates a second container group pod on the target physical node storing the target message, and creates a watchdog container on the pod. This watchdog container pulls the image of the message reading FaaS function from the image repository and loads it into the current watchdog container, where it executes the message reading FaaS function to obtain the target message.
[0070] By calling the message reading faas function, messages can be retrieved when there is a need to read them. When there is no need to read messages, the function does not consume fixed message storage resources, thus saving system resources.
[0071] The message processing method provided in this embodiment of the invention obtains the target message through the message reading Faas function in the Faas service, thus achieving the acquisition of the target message. Simultaneously, by calling the message reading Faas function through the Faas service to retrieve the message, the message is stored when there is a message reading requirement, and when there is no message reading requirement, no fixed message storage resources are consumed, saving system resources.
[0072] In one embodiment, after storing the target message in the target physical node, the method further includes: obtaining the address of each physical node in the container orchestration system, and synchronizing the storage status information of each physical node in the container orchestration system according to the gossip protocol.
[0073] Optionally, after the base container completes the operation of storing the target message to the target physical node, for the Kubernetes cluster in the container orchestration system, it can query the etcd component of the Kubernetes cluster to obtain the addresses of other physical nodes in the Kubernetes cluster. Then, it uses the gossip protocol to communicate with other physical nodes in the Kubernetes cluster to synchronize storage state information. After completing the synchronization of target message storage and cluster storage state information, the base container will continuously listen for message write requests from the FaaS service gateway, as well as the synchronization of storage state information of other physical nodes in the Kubernetes cluster.
[0074] The message processing method provided in this embodiment of the invention obtains the addresses of each physical node in the container orchestration system after the target message is stored, and synchronizes the storage status information of each physical node in the container orchestration system according to the gossip protocol. This facilitates the determination of the message storage node based on the node information of each physical node in the container orchestration system when a message is subsequently received and written.
[0075] The following example, using a message processing method provided by an embodiment of the present invention, illustrates the technical solution provided by the present invention:
[0076] The message processing method provided by the embodiments of the present invention includes writing the target message and acquiring the target message.
[0077] The process of writing the target message is as follows Figure 2The message writing process provided in this embodiment of the invention is illustrated in the diagram. When a target message write request arrives, the message data first reaches the gateway of the FaaS service in the cluster. The FaaS service gateway generates a globally unique auto-incrementing identifier for the message and dynamically queries the number of currently available physical nodes in the Kubernetes cluster. A consistent hashing algorithm is used to calculate the target physical node where the currently received target message should be stored, as well as the hash key value of the target message's storage information.
[0078] The FaaS service gateway creates a container group (pod) on the target physical node, and within that pod, it creates an infrastructure container. The infrastructure container writes target messages to the message log file located on the target physical node's local storage volume (host-path) and updates the message state metadata on the target physical node. The message state metadata and its structure are illustrated in the diagram below. Figure 3 The structural diagram of message status metadata provided in this embodiment of the invention is shown. The message status metadata includes meta.json data, index.json data, and chunk file data. The meta.json data stores message storage information for each physical node, including the range of hash keys for messages stored in each physical node, which messages were recently written, and which messages have been read. The index.json data stores message storage information for this physical node, including the range of hash keys for messages in this physical node, the specific location of the most recently written message in which chunk file, and the specific location of the most recently read message in which chunk file. The chunk file data stores the relevant data for each chunk file where messages are stored in this physical node.
[0079] After the target message is stored, the infra container will query the IP addresses of other physical nodes in the current cluster, such as physical node 1 and physical node 2, through the Kubernetes cluster management API (Application Programming Interface), and use the gossip protocol to synchronize the target physical node message status metadata with physical node 1 and physical node 2 in the cluster.
[0080] Specifically, the infra container of the target physical node reads the index.json file in the host-path of the target physical node, retrieves the filename of the latest written message of the target physical node, opens the chunk file corresponding to the filename, and then locates the offset position of the file write pointer by using the byte offset in the chunk file where the latest written message of the target physical node is located, and writes the data of the target message at that position.
[0081] If the chunk file size exceeds 64KB, a new chunk file will be created. Then, the contents of the index.json file will be updated.
[0082] After updating the local message status metadata, the infra container will synchronize the index.json data of the target physical node with other physical nodes in the Kubernetes cluster, such as physical node 1 and physical node 2, using the gossip protocol.
[0083] The process of obtaining the target message is as follows: Figure 4 The message retrieval process provided in this embodiment of the invention is illustrated in the diagram. When a request to retrieve a target message is received, a container group pod is created in the Kubernetes cluster through the scheduler of the FaaS service, and a watchdog container process is created in this pod. This process retrieves the image file of the message reading FaaS function from the image repository. Subsequently, the watchdog process creates a child process to start the base container and executes the called message reading FaaS function.
[0084] The execution of the message reading faas function first checks the host-path of the current physical node. Based on the content of the message status metadata, it reads the index.json file to determine whether there are any latest unread message logs on the current physical node.
[0085] If not, the function will query the meta.json file to find a physical node with "unread messages" and then redirect the read request to another physical node.
[0086] If there is a latest unread message log on the current physical node, the query function will read the filename of the latest read message on the index.json file, open the chunk file corresponding to the filename, and then locate the offset position of the file read pointer by the byte offset in the chunk file where the latest read message is located, and read the message log at that position.
[0087] After the message reading faas function is executed, it updates the message status metadata of this node.
[0088] Figure 5 This is a schematic diagram of the structure of a message processing apparatus provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the device includes:
[0089] The message receiving module 510 is used to receive write requests for the target message;
[0090] The storage node determination module 520 is used to determine the target physical node for storing the target message among the physical nodes based on the node information of each physical node in the container orchestration system and the storage information of the target message.
[0091] The message storage module 530 is used to create a basic container on the target physical node and store the target message on the target physical node according to the basic container.
[0092] The message processing apparatus provided in this embodiment of the invention determines the target physical node for storing the target message among the physical nodes of the container orchestration system, creates a basic container on the target physical node, and stores the target message in the target physical node according to the created basic container, thereby achieving the storage of the target message. Simultaneously, by creating the basic container for message storage only when there is a message write requirement, no fixed message storage resources are consumed when there is no message write requirement, thus achieving dynamic storage of the target message, avoiding the waste of fixed service resource costs, and saving system resources.
[0093] In one embodiment, the message storage module 530 is specifically used for:
[0094] The step of storing the target message in the target physical node according to the basic container includes:
[0095] Based on the underlying container, the message writing function in the FaaS service is called to store the target message in the target physical node.
[0096] In one embodiment, the message storage module 530 is further configured to:
[0097] Creating a base container on the target physical node includes:
[0098] Create a first container group on the target physical node, and create the base container in the first container group.
[0099] In one embodiment, the storage node determination module 520 is specifically used for:
[0100] Based on the node information of each physical node in the container orchestration system and the storage information of the target message, the target physical node for storing the target message is determined, including:
[0101] Based on the hash consistency algorithm, the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message are determined.
[0102] Based on the hash value of the node information of each physical node and the hash key value, the target physical node for storing the target message is determined among the physical nodes.
[0103] In one embodiment, the storage node determination module 520 is further configured to:
[0104] After determining the target physical node among the physical nodes used to store the target message, the method further includes:
[0105] The hash key value is stored in the target physical node.
[0106] In one embodiment, the storage node determination module 520 is further configured to:
[0107] After storing the target message in the target physical node, the process further includes:
[0108] Receive the request to retrieve the target message;
[0109] Based on the hash key value, determine the target physical node where the target message is stored, and retrieve the target message from the target physical node.
[0110] In one embodiment, the storage node determination module 520 is further configured to:
[0111] Obtaining the target message from the target physical node includes:
[0112] According to the scheduler of the FaaS service, a second container group is created on the target physical node, and a watchdog container is created in the second container group;
[0113] Based on the watchdog container, the message reading faas function is called to obtain the target message.
[0114] In one embodiment, the message storage module 530 is further configured to:
[0115] After storing the target message in the target physical node, the process further includes:
[0116] Obtain the addresses of each physical node in the container orchestration system, and synchronize the storage status information of each physical node in the container orchestration system according to the gossip protocol.
[0117] Figure 6 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 6 As shown, the electronic device may include a processor 610, a communications interface 620, a memory 630, and a communication bus 640, wherein the processor 610, the communications interface 620, and the memory 630 communicate with each other via the communication bus 640. The processor 610 can call logical instructions in the memory 630 to execute the following methods:
[0118] Receive write requests for the target message;
[0119] Based on the node information of each physical node in the container orchestration system and the storage information of the target message, determine the target physical node among the physical nodes used to store the target message;
[0120] A base container is created on the target physical node, and the target message is stored on the target physical node based on the base container.
[0121] Furthermore, the logical instructions in the aforementioned memory 630 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0122] Furthermore, this invention discloses a computer program product, which includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions, and when these instructions are executed by a computer, the computer can perform the message processing methods provided in the above-described method embodiments, such as:
[0123] Receive write requests for the target message;
[0124] Based on the node information of each physical node in the container orchestration system and the storage information of the target message, determine the target physical node among the physical nodes used to store the target message;
[0125] A base container is created on the target physical node, and the target message is stored on the target physical node based on the base container.
[0126] On the other hand, embodiments of the present invention also provide a non-transitory computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the message processing methods provided in the above embodiments, including, for example:
[0127] Receive write requests for the target message;
[0128] Based on the node information of each physical node in the container orchestration system and the storage information of the target message, determine the target physical node among the physical nodes used to store the target message;
[0129] A base container is created on the target physical node, and the target message is stored on the target physical node based on the base container.
[0130] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0131] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0132] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention 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; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
[0133] The above embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. Although the invention has been described in detail with reference to the embodiments, those skilled in the art should understand that various combinations, modifications, or equivalent substitutions of the technical solutions of the invention do not depart from the spirit and scope of the invention and should be covered within the scope of the claims of the invention.
Claims
1. A message processing method, characterized in that, Faaas services applied in container orchestration systems include: Receive write requests for the target message; Based on the node information of each physical node in the container orchestration system and the storage information of the target message, determine the target physical node among the physical nodes used to store the target message; A base container is created on the target physical node, and the target message is stored on the target physical node according to the base container; After storing the target message in the target physical node, the method further includes: The basic container listens for message write requests to the gateway of the FaaS service. After listening for a preset time and no new message write requests are received, the basic container is released. Update the message state metadata in the target physical node, and synchronize the updated message state metadata to other physical nodes in the container orchestration system; Upon receiving a message read request, based on the updated message status metadata, determine whether there are any unread messages on the target physical node; if there are unread messages, read the unread messages from the target physical node based on the updated message status metadata; if there are no unread messages, determine the physical node with unread messages based on the updated message status metadata, and redirect the message read request to the physical node with unread messages.
2. The message processing method according to claim 1, characterized in that, The step of storing the target message in the target physical node according to the basic container includes: Based on the underlying container, the message writing function in the FaaS service is called to store the target message in the target physical node.
3. The message processing method according to claim 1, characterized in that, Creating the basic container on the target physical node includes: Create a first container group on the target physical node, and create the base container in the first container group.
4. The message processing method according to claim 1, characterized in that, The step of determining the target physical node for storing the target message based on the node information of each physical node in the container orchestration system and the storage information of the target message includes: Based on the hash consistency algorithm, the hash value of the node information of each physical node in the container orchestration system and the hash key value of the storage information of the target message are determined. Based on the hash value of the node information of each physical node and the hash key value, the target physical node for storing the target message is determined among the physical nodes.
5. The message processing method according to claim 4, characterized in that, After determining the target physical node among the physical nodes used to store the target message, the method further includes: The hash key value is stored in the target physical node.
6. The message processing method according to claim 5, characterized in that, After storing the target message in the target physical node, the method further includes: Receive the request to retrieve the target message; Based on the hash key value, determine the target physical node where the target message is stored, and retrieve the target message from the target physical node.
7. The message processing method according to claim 6, characterized in that, Obtaining the target message from the target physical node includes: According to the scheduler of the FaaS service, a second container group is created on the target physical node, and a watchdog container is created in the second container group; Based on the watchdog container, the message reading faas function is called to obtain the target message.
8. The message processing method according to claim 1, characterized in that, After storing the target message in the target physical node, the method further includes: Obtain the addresses of each physical node in the container orchestration system, and synchronize the storage status information of each physical node in the container orchestration system according to the gossip protocol.
9. A message processing apparatus, characterized in that, Faaas services applied in container orchestration systems include: The message receiving module is used to receive write requests for the target message; The storage node determination module is used to determine the target physical node for storing the target message among the physical nodes based on the node information of each physical node in the container orchestration system and the storage information of the target message. A message storage module is used to create a basic container on the target physical node and store the target message on the target physical node according to the basic container; After storing the target message in the target physical node, the method further includes: The basic container listens for message write requests to the gateway of the FaaS service. After listening for a preset time and no new message write requests are received, the basic container is released. Update the message state metadata in the target physical node, and synchronize the updated message state metadata to other physical nodes in the container orchestration system; Upon receiving a message read request, based on the updated message status metadata, determine whether there are any unread messages on the target physical node; if there are unread messages, read the unread messages from the target physical node based on the updated message status metadata; if there are no unread messages, determine the physical node with unread messages based on the updated message status metadata, and redirect the message read request to the physical node with unread messages.
10. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the message processing method as described in any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the message processing method as described in any one of claims 1 to 8.
12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the message processing method as described in any one of claims 1 to 8.
Citation Information
Patent Citations
Data set management method, system and device, electronic equipment and storage medium
CN112925788A
Data distribution method and device, electronic equipment and storage medium
CN113918342A