CN-114706699-B - Message processing method and device
Abstract
The invention relates to the technical field of computers and provides a message processing method and device. The method comprises the steps of receiving a writing request of a target message, determining a target physical node used for storing the target message in each physical node according to node information of each physical node of a container arrangement system and storage information of the target message, creating a basic container on the target physical node, and storing the target message to the target physical node according to the basic container. According to the method and the device for processing the message, the target physical node for storing the target message is determined, the basic container is created on the target physical node, the target message is stored to the target physical node according to the created basic container, the storage of the target message is realized, meanwhile, the basic container is created only when the message is written, the message is stored, and when no message writing requirement exists, fixed message storage resources are not required to be consumed, and system resources are saved.
Inventors
- XU SHOUMING
- CAI SHAODONG
- HAN XU
- FENG JIAHAO
Assignees
- 美的集团股份有限公司
Dates
- Publication Date
- 20260505
- Application Date
- 20220422
Claims (12)
- 1. A method of processing a message, for use in a faas service in a container orchestration system, comprising: Receiving a write request of a target message; Determining a target physical node for storing the target message in each physical node according to node information of each physical node in a container arrangement system and storage information of the target message; creating a basic container on the target physical node, and storing the target message to the target physical node according to the basic container; after the target message is stored in the target physical node, the method further comprises: Based on the base container monitoring the message writing request of the faas serving gateway, releasing the base container after the monitoring reaches the preset time and no new message writing request exists; updating the message state metadata in the target physical node and synchronizing the updated message state metadata to other physical nodes in the container arrangement system; The method comprises the steps of receiving a message reading request, determining whether unread messages exist in a target physical node based on updated message state metadata, reading unread messages in the target physical node based on the updated message state metadata if the unread messages exist, determining the physical node with the unread messages based on the updated message state metadata if the unread messages do not exist, and redirecting the message reading request to the physical node with the unread messages.
- 2. The method for processing the message according to claim 1, wherein the storing the target message to the target physical node according to the base container comprises: And according to the basic container, calling a function, namely a message writing faas function in a service faas service, and storing the target message to the target physical node.
- 3. The method of processing a message according to claim 1, wherein said creating a base container on said target physical node comprises: A first set of containers is created on the target physical node and the base container is created in the first set of containers.
- 4. The method for processing a message according to claim 1, wherein determining a target physical node for storing the target message among the physical nodes based on node information of the physical nodes in the container arrangement system and storage information of the target message comprises: Determining hash values of node information of all physical nodes in the container arrangement system and hash key values of storage information of the target message based on a hash consistency algorithm; and determining a target physical node for storing the target message in each physical node according to the hash value of the node information of each physical node and the hash key value.
- 5. The method according to claim 4, wherein after determining a target physical node for storing the target message in the physical nodes, further comprising: Storing the hash key value to the target physical node.
- 6. The method according to claim 5, wherein after storing the target message in the target physical node, further comprising: receiving an acquisition request of a target message; And determining a target physical node for storing the target message according to the hash key value, and acquiring the target message from the target physical node.
- 7. The method for processing the message according to claim 6, wherein the obtaining the target message from the target physical node includes: Creating a second container group on the target physical node and creating a watchdog container in the second container group according to a scheduler serviced by faas; and calling a message reading faas function according to the watchdog container to acquire the target message.
- 8. The method for processing the message according to claim 1, further comprising, after storing the target message in the target physical node: And acquiring the address of each physical node in the container arrangement system, and synchronizing the storage state information of each physical node in the container arrangement system according to an epidemic protocol gossip protocol.
- 9. A message processing apparatus for use in a container orchestration system for faas services, comprising: The message receiving module is used for receiving a writing request of the target message; The storage node determining module is used for determining a target physical node for storing the target message in each physical node according to the node information of each physical node in the container arrangement system and the storage information of the target message; The message storage module is used for creating a basic container on the target physical node and storing the target message to the target physical node according to the basic container; after the target message is stored in the target physical node, the method further comprises: Based on the base container monitoring the message writing request of the faas serving gateway, releasing the base container after the monitoring reaches the preset time and no new message writing request exists; updating the message state metadata in the target physical node and synchronizing the updated message state metadata to other physical nodes in the container arrangement system; The method comprises the steps of receiving a message reading request, determining whether unread messages exist in a target physical node based on updated message state metadata, reading unread messages in the target physical node based on the updated message state metadata if the unread messages exist, determining the physical node with the unread messages based on the updated message state metadata if the unread messages do not exist, and redirecting the message reading request to the physical node with the unread messages.
- 10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, characterized in that the processor implements the method of processing a message according to any of claims 1 to 8 when executing the computer program.
- 11. A non-transitory computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when executed by a processor, implements a method of processing a message according to any of claims 1 to 8.
- 12. A computer program product comprising a computer program which, when executed by a processor, implements a method of processing a message according to any one of claims 1 to 8.
Description
Message processing method and device Technical Field The present invention relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a message. Background In the system architecture of the existing IT (Internet Technology ) enterprises, a message storage system is generally adopted to implement writing, storage, reading and query of messages. The existing message storage system needs to consume huge CPU (Central Processing Unit ) resources and memory resources when in use. But for message services, it is only used for a fixed period of time per day, and there is no traffic for most of the other time. This creates a significant waste of operating costs and resources for the enterprise. Disclosure of Invention The present invention aims to solve at least one of the technical problems existing in the prior art. Therefore, the invention provides a message processing method, so that a basic container is created for message storage only when the message is written, and fixed message storage resources are not required to be consumed when the message writing requirement is not needed, thereby avoiding wasting fixed service resource cost and saving system resources. The invention also provides a message processing device. The invention further provides electronic equipment. The invention also proposes a non-transitory computer readable storage medium. The invention also proposes a computer program product. The message processing method according to the embodiment of the first aspect of the invention comprises the steps of receiving a writing request of a target message, determining a target physical node for storing the target message in each physical node according to node information of each physical node in a container arrangement system and storage information of the target message, creating a basic container on the target physical node, and storing the target message to the target physical node according to the basic container. According to the message processing method provided by the embodiment of the invention, the storage of the target message is realized by determining the target physical node for storing the target message in each physical node of the container arrangement system, creating a basic container on the target physical node and storing the target message to the target physical node according to the created basic container. Meanwhile, a basic container is created for message storage only when the message is written, and fixed message storage resources are not required to be consumed when the message writing requirement does not exist, so that the dynamic storage of the target message is realized, the waste of fixed service resource cost is avoided, and the system resource is saved. According to one embodiment of the invention, the storing the target message to the target physical node according to the base container includes storing the target message to the target physical node according to the base container by calling a function, i.e., a message write faas function in a service faas. And storing the target message into the target physical node through writing the message in faas services into a faas function, thereby realizing the storage of the target message. Meanwhile, through faas service, the message writing faas function is called to store the message, so that the message writing faas function is called to store the message when the message writing is needed, and fixed message storage resources are not required to be consumed when the message writing is not needed, and system resources are saved. According to one embodiment of the invention, 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. By creating a first container group on the target physical node and creating a base container in the first container group, a basis is provided for subsequent implementation of storage of the target message in the target physical node. According to one embodiment of the invention, the method for determining the target physical node for storing the target message in each physical node according to the node information of each physical node of the container arrangement system and the storage information of the target message comprises the steps of determining hash values of the node information of each physical node in the container arrangement system and hash key values 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 in each physical node according to the hash values of the node information of each physical node and the hash key values. And determining the hash value of the node information of each physical node in the container arrangement system and the hash key value of the storage information of the tar