Message sending method and device, server and storage medium
By storing messages in a virtualized environment according to business scenarios and dynamically adjusting queue load, the performance overload problem of the message system under high load is solved, and load balancing and ordered message sending are achieved.
Patent Information
- Application Number
- CN202211105046.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2042-09-09
AI Technical Summary
When a large number of business systems send messages to the messaging system simultaneously, the messaging system's limited capacity leads to performance overload and inability to provide normal service.
By storing messages in corresponding queues according to business scenarios in a virtualized environment and dynamically adjusting them based on queue load information, load balancing is achieved, thereby enabling messages to be sent in an orderly manner.
It achieves load balancing of the messaging system in a virtualized environment, ensuring timely and orderly message delivery, and improving the availability and efficiency of the messaging system.
Smart Images

Figure CN117692401B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of Internet technology, and in particular to a message sending method, apparatus, server, storage medium and program product. Background Technology
[0002] With the rapid development of Internet technology, a large number of business systems need to send verification codes, notification messages, marketing information and other messages to users. By using a messaging system running in a virtual environment to integrate the sending of messages, messages in different scenarios can be quickly sent to terminals through the network, making message push of business systems more convenient and faster.
[0003] In related technologies, when a large number of business systems simultaneously send messages to a messaging system running in a virtual environment, the limited capacity of the messaging system can cause a sudden surge in pressure, leading to performance overload and preventing the messaging system from providing normal services.
[0004] There is currently no effective solution in the relevant technologies for ensuring the availability of messaging systems. Summary of the Invention
[0005] This application provides a message sending method, apparatus, server, computer-readable storage medium, and computer program product that can balance the load of each queue in a message system, thereby ensuring orderly and efficient message sending.
[0006] The technical solution of this application embodiment is implemented as follows: This application provides a message sending method, the method including: Receive at least one message from at least one business system; Based on the business scenario corresponding to each message, each message is stored in a queue in the virtualization environment that corresponds to the business scenario. Each queue is used to store a message corresponding to a business scenario. Based on the load information of multiple queues, the virtualization environment is dynamically adjusted. From multiple queues in the dynamically adjusted virtualization environment, at least one message is scheduled, and the message sending service is invoked to send the scheduled message to the terminal.
[0007] This application provides a message sending device, which includes: The message receiving module is used to receive at least one message from at least one business system; The message storage module is used to store each message into a queue corresponding to the business scenario in the virtualization environment, based on the business scenario corresponding to each message. Each queue is used to store a message corresponding to a business scenario. The queue adjustment module is used to dynamically adjust multiple queues in the virtualization environment based on the load information of multiple queues. The message sending module is used to schedule at least one message from multiple queues in the dynamically adjusted virtualization environment and call the message sending service to send the scheduled message to the terminal.
[0008] This application embodiment provides a server, the server comprising: Memory, used to store executable instructions; The processor, when executing executable instructions stored in memory, implements the message sending method provided in the embodiments of this application.
[0009] This application provides a computer-readable storage medium storing executable instructions, which, when executed by a processor, implement the message sending method provided in this application.
[0010] This application provides a computer program product, including a computer program or instructions, which, when executed by a processor, are used to implement the message sending method provided in this application.
[0011] The embodiments of this application have the following beneficial effects: Messages are stored in queues corresponding to the business scenarios within the virtualization environment, based on the scenario they correspond to. This isolates the storage of messages from different business scenarios within the virtualization environment. Furthermore, the queues are dynamically adjusted based on their load information, thereby achieving load balancing across the various queues in the virtualization environment and ensuring that messages in the queues are sent out in a timely and orderly manner. Attached Figure Description
[0012] Figure 1A This is a schematic diagram of the architecture of the message processing system provided in the embodiments of this application; Figure 1B This is a schematic diagram of the architecture of the messaging system provided in an embodiment of this application; Figure 2 This is a schematic diagram of the server structure in the messaging system provided in this application embodiment; Figure 3 This is a flowchart illustrating a message sending method provided in an embodiment of this application; Figure 4 This is a schematic diagram of a message storage process provided in an embodiment of this application; Figure 5 This is a schematic diagram of a process for storing serialized messages provided in an embodiment of this application; Figure 6 This is a flowchart illustrating the dynamic adjustment of multiple queues provided in an embodiment of this application; Figure 7 This is a flowchart illustrating a process for dynamically adjusting the number of container combinations used to run multiple queues in a virtualized environment, as provided in an embodiment of this application. Figure 8 This is another schematic diagram of a process for dynamically adjusting the number of container combinations used to run multiple queues in a virtualized environment, provided in an embodiment of this application. Figure 9 This is a flowchart illustrating a deterministic message sending service provided in an embodiment of this application; Figure 10 This is a schematic diagram of a process for sending a message to a terminal by calling a message sending service according to an embodiment of this application; Figure 11 This is a schematic diagram illustrating the architectural principle of message sending provided in an embodiment of this application; Figure 12 This is a flowchart illustrating a message sending method provided in an embodiment of this application; Figure 13 This is a schematic diagram of a process for dynamically adjusting a virtual container provided in an embodiment of this application; Figure 14 This is a schematic diagram of load balancing for message sending services provided in an embodiment of this application; Figure 15 This is a schematic diagram illustrating the message sending architecture provided in an embodiment of this application; Figure 16 This is a flowchart illustrating a message receiving and sending scheme provided in an embodiment of this application; Figures 17A-17C This is a schematic diagram of the message sending interface provided in an embodiment of this application; Detailed Implementation To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0013] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0014] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0015] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of this application only and is not intended to limit this application.
[0016] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0017] 1) Cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize the computing, storage, processing, and sharing of data.
[0018] 2) Container Operating Platform (Kubernetes): Abbreviated as K8S, it is an open source container operating platform that can combine several containers into a service and dynamically allocate the host on which the container runs, providing great convenience for users to use containers.
[0019] 3) Resource Object (HPA, Horizontal Pod Autoscaler): This is a resource object in the Kubernetes container operating platform that can dynamically scale the number of Pods based on certain metrics, enabling services running on it to adapt to changes in these metrics.
[0020] 4) Container Assembly (POD): Used to encapsulate multiple tightly coupled, collaborative containers simultaneously, enabling resource sharing among them. Containers within the same POD can collaborate as a service unit, such as sharing files. The POD manages the storage resources of these containers as a single entity. 5) Kubernetes Application Programming Interface (API): Registers a resource with a specific purpose and defines the associated API. Extends the resource's data to the Kubernetes cluster and leverages the Kubernetes controller pattern framework to implement a new controller. The API service monitors the cluster's status regarding this resource and defines the logic for handling status changes.
[0021] 6) Message Queue: A message queue is a container that stores messages during message transmission. The message queue manager acts as an intermediary when relaying messages from their source to their destination. The main purpose of a message queue is to provide routing and ensure message delivery; if the receiver is unavailable when a message is sent, the message queue will retain the message until it can be successfully delivered.
[0022] 7) Software as a Service (SaaS): This refers to programs that provide local services to customers in conjunction with a server. Aside from some applications that run only locally, these are typically installed on ordinary client machines and require interaction with the server to function. With the development of the Internet, common client applications include web browsers used on the World Wide Web, email clients for sending and receiving emails, and instant messaging client software. For these types of applications, corresponding servers and service programs on the network are needed to provide the services, such as database services and email services. Therefore, specific communication connections need to be established between the client and server to ensure the normal operation of the application.
[0023] During the implementation of the embodiments of this application, the applicant discovered the following problems with the related technology: When a message system responds to a message request sent by a business system, it sends the message sent by the business system to the terminal via the network. When a large number of business systems send message requests to the message system at the same time, the limited carrying capacity of the message system will cause the pressure on the message system to increase sharply in an instant, causing the message system to overload and resulting in the message system being unable to provide normal services.
[0024] This application provides a message sending method, apparatus, server, computer-readable storage medium, and computer program product, which can achieve load balancing of various queues in a virtualized environment and ensure that messages in the queues can be sent in a timely and orderly manner. The following describes an exemplary application of the message sending device provided in this application. The message system provided in this application can be implemented as a server.
[0025] It's important to note that messaging systems can run in virtualized environments. These virtualized environments, at the physical level, include servers and are essentially cloud computing resource pools, also known as cloud platforms or Infrastructure as a Service (IaaS) platforms. These resource pools deploy various types of virtual resources for external customers to choose from. Cloud computing resource pools include: computing devices (virtualized machines containing operating systems), storage devices, and network devices. Logically, Platform as a Service (PaaS) can be deployed on top of Infrastructure as a Service (IaaS), and Software as a Service (SaaS) can be deployed on top of PaaS. Alternatively, SaaS can be directly deployed on IaaS. PaaS is a platform for running software, such as databases and containers. SaaS refers to various types of business software, such as web portals and bulk SMS senders. Generally, SaaS and PaaS are upper layers compared to IaaS.
[0026] See Figure 1A , Figure 1A This is a schematic diagram of the architecture of a message processing system provided in an embodiment of this application. In the schematic diagram of the message processing system 20, the message system 200 is used to receive messages sent by the business system 100, and calls the message sending service 300 to send the messages to the terminal 400. The terminal 400 is used to display the received messages in a graphical interface. The business system 100, the message system 200, the message sending service 300, and the terminal 400 are interconnected through wired or wireless networks. The message sending service can be provided by different message providers.
[0027] In some embodiments, the business system 100 may include an independent physical server, a server cluster or distributed system composed of multiple physical servers, 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, CDN, and big data and artificial intelligence platforms. The terminal 400 may be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, in-vehicle terminal, etc., but is not limited to these. The terminal and server can be directly or indirectly connected via wired or wireless communication, which is not limited in this embodiment.
[0028] See Figure 1B , Figure 1BThis is a schematic diagram of the architecture of the messaging system provided in this application embodiment. The messaging system 200 can be implemented using various virtualization technologies, such as Kubernetes. After receiving a message sent by the business system, the messaging system 200 stores the message in a queue according to the business scenario corresponding to each message. The container combination (POD) in the virtual environment includes multiple virtual containers 2001. The virtual containers are used to run queues 2002 that store messages. One virtual container can run one or more queues.
[0029] See Figure 2 , Figure 2 This is a schematic diagram of the server structure in the messaging system provided in this application embodiment. Figure 2 The server 210 in the illustrated messaging system 200 includes at least one processor 2110, a memory 2150, and at least one network interface 2120. The various components of server 210 are coupled together via a bus system 2140. It is understood that the bus system 2140 is used to implement communication between these components. In addition to a data bus, the bus system 2140 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general designated all buses as Bus System 2140.
[0030] Processor 2110 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among them, the general-purpose processor can be a microprocessor or any conventional processor, etc.
[0031] The memory 2150 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state storage, hard disk drives, optical disk drives, etc. The memory 2150 may optionally include one or more storage devices physically located away from the processor 2110.
[0032] The memory 2150 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 2150 described in this application embodiment is intended to include any suitable type of memory.
[0033] In some embodiments, memory 2150 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.
[0034] Operating system 2151 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks; The network communication module 2152 is used to reach other computing devices via one or more (wired or wireless) network interfaces 2120, such as Bluetooth, WiFi, and Universal Serial Bus (USB). In some embodiments, the message sending device provided in this application can be implemented in software. Figure 2 A message sending device 2155 storing messages in memory 2150 is shown. This device can be software in the form of programs or plug-ins, and includes the following software modules: a message receiving module 21551, a message storage module 21552, a queue adjustment module 21553, and a message sending module 21554. These modules are logically connected and can therefore be arbitrarily combined or further separated according to the functions they implement. The functions of each module will be described below.
[0035] As mentioned above, the data processing method provided in this application embodiment can be implemented by a server in a messaging system. See also Figure 3 , Figure 3 This is a flowchart illustrating a message sending method provided in an embodiment of this application, combined with... Figure 3 The steps shown are explained.
[0036] In step 201, at least one message is received from at least one business system.
[0037] The business application scenarios of the business system include social networking, email sending, and message verification. Messages can be instant messaging messages, emails, verification SMS, etc.
[0038] In step 202, each message is stored in a queue corresponding to the business scenario in the virtualization environment, based on the business scenario corresponding to each message.
[0039] As an example, business scenarios include real-time scenarios, gray-scale testing scenarios, and non-real-time scenarios. Non-real-time scenarios include mass messaging scenarios, where real-time message delivery is not required.
[0040] Gray-scale testing refers to a scenario where two different application versions exist simultaneously: a black version and a white version. By observing the performance of the two versions, the ratio of the black and white versions is adjusted, gradually transitioning all users' applications from the black version to the white version. This testing process using coexisting black and white versions is called gray-scale testing or gray-scale release. In this context, the black version indicates that users are not satisfied with the current version's functional requirements, while the white version indicates that users are satisfied with the current version's functional requirements.
[0041] See Figure 4 , Figure 4 This is a schematic diagram of a message storage process provided in an embodiment of this application. In some embodiments, Figure 3 Step 202 shown can be achieved through Figure 4 Steps 2021-2023 in the process will be implemented.
[0042] In step 2021, priority parameters corresponding to multiple business scenarios are obtained from the configuration file.
[0043] In some embodiments, pre-configured priority parameters corresponding to multiple business scenarios are obtained from configuration files deployed in a virtualized environment.
[0044] For example, the business scenarios include business scenario 1, business scenario 2, and business scenario 3. The configuration file sets corresponding priority parameters ac for business scenarios 1-3 respectively. Then, the priority parameters ac corresponding to business scenarios 1-3 are obtained from the configuration file. Different priority parameters correspond to different business scenarios. This correspondence can be pre-configured. The priority parameter consists of three fields: business identifier, source identifier, and message type identifier.
[0045] In step 2022, the message parameters in the message are matched with the priority parameters corresponding to multiple business scenarios to obtain the storage address of the message in the virtualization environment.
[0046] In some embodiments, the message parameters in the message include a service identifier, a source identifier, and a message type identifier. These identifiers are combined into a string, which is then matched against priority parameters corresponding to multiple service scenarios. The service scenario corresponding to the successfully matched priority parameter is determined as the service scenario corresponding to the message. The storage address of the queue storing messages for this service scenario in the virtualization environment is used as the message's storage address in the virtualization environment. Assuming the queue occupies a contiguous storage space in the virtualization environment, the storage address can be the start and end addresses of that contiguous storage space. The storage addresses of queues for different service scenarios in the virtualization environment can be pre-configured, or a storage space can be automatically allocated and a corresponding storage address determined for each newly accessed queue of a service scenario. The length of the storage space for different service scenarios can be the same, or the storage space can be allocated according to the proportion of messages previously generated by different service scenarios.
[0047] For example, the priority parameter ac has a one-to-one correspondence with business scenarios 1-3. For instance, priority parameter a corresponds to business scenario 1, priority parameter b corresponds to business scenario 2, and priority parameter c corresponds to business scenario 3. The various identifiers included in the message parameters of message A are concatenated to obtain the concatenated string A. The concatenated string A is matched with the priority parameter ac. The business scenario corresponding to the priority parameter a after a successful match is determined as the business scenario corresponding to the message. Thus, message A corresponds to business scenario 1. For example, the storage address of the queue corresponding to business scenario 1 is Address1, the storage address of the queue corresponding to business scenario 2 is Address2, and the storage address of the queue corresponding to business scenario 3 is Address3. The storage address of the queue storing message A in the virtualization environment is determined to be Address1.
[0048] In step 2023, the message is stored in the queue corresponding to the business scenario in the virtualization environment according to the storage address.
[0049] See Figure 5 , Figure 5 This is a schematic diagram of a process for storing serialized messages provided in an embodiment of this application. In some embodiments, Figure 4 The step 2023 shown can be achieved through Figure 5 Steps 20231-20232 are implemented.
[0050] In step 20231, the message is serialized to obtain the serialization result corresponding to the message.
[0051] Serialization refers to converting the state information of a message object into a form that can be stored or transmitted. For example, writing the current state of a message object to temporary or persistent storage, and recreating the message object by reading or deserializing the object's state from storage. Serialization includes binary serialization and Extensible Markup Language (XML) serialization.
[0052] In step 20232, the serialization result is stored in a queue in the virtualization environment that corresponds to the business scenario.
[0053] Continuing from the previous example, the serialization results stored in temporary or persistent storage areas are stored in queues in the virtualization environment that correspond to the business scenario, according to their storage addresses.
[0054] In step 203, multiple queues in the virtualization environment are dynamically adjusted based on their load information.
[0055] The load information for each queue includes the number of messages piling up in the queue and the utilization of storage resources (such as CPU, disk, memory, etc.). In some embodiments, the dynamic adjustment method includes expanding or shrinking the number of container combinations used to run multiple queues in the virtualization environment.
[0056] See Figure 6 , Figure 6 This is a flowchart illustrating the dynamic adjustment of multiple queues provided in an embodiment of this application. In some embodiments, Figure 3 Step 203 shown can be achieved through Figure 6 Steps 2031-2032 are implemented.
[0057] In step 2031, the total number of messages piling up in multiple queues is detected according to the detection frequency, and the detection results are used as the load information corresponding to multiple queues.
[0058] For example, the detection frequency refers to detecting the total number of messages piling up in multiple queues in a unit time period (e.g., 1 hour, 1 quarter of an hour, 1 minute). For example, the total number of messages piling up in N1 queues is detected once every 15 seconds, and the detection result is the piling number Num1. Then, the piling number Num1 is used as the load information corresponding to the N1 queues.
[0059] In step 2032, the number of container combinations used to run multiple queues in the virtualization environment is dynamically adjusted based on the load information of multiple queues.
[0060] Continuing from the previous example, the total number of queues is detected in units of time (e.g., 1 hour, 1 quarter of an hour, 1 minute) as a cycle (e.g., a cycle of 15 seconds). The total number of queues is used as load information to scale down or up the capacity of the virtualization environment. The capacity of the virtualization environment represents the number of container combinations used to run multiple queues in the virtualization environment.
[0061] See Figure 7 , Figure 7 This is a flowchart illustrating a process for dynamically adjusting the number of container combinations used to run multiple queues in a virtualized environment, as provided in an embodiment of this application. Figure 6 Step 2032 shown can be achieved through Figure 8 Steps 20321A-20322A in the process enable dynamic adjustment of the number of container combinations used to run multiple queues in the virtualization environment.
[0062] In step 20321A, when the total number of messages in multiple queues reaches a first total number threshold, the ratio of the total number of messages in multiple queues to a reference number of messages in multiple queues is determined, and the first product of the ratio and the number of containers in the current multiple queues is determined. The first total number threshold of messages in multiple queues is greater than the reference number of messages in multiple queues. Here, the container combination of queues represents the number of containers in the running queue.
[0063] Continuing from the previous example, the reference backlog count represents the average of the total number of messages backlogged in multiple queues during the off-peak period corresponding to the historical backlog count. The total number of messages backlogged in N2 queues is detected in a period of one unit of time (e.g., 1 hour, 1 quarter of an hour, 1 minute) (e.g., one period is 15 seconds), and the detection result is the backlog count Num2. When the value of the backlog count Num2 is greater than or equal to the first backlog count threshold, the ratio Num2 / Num3 of the current backlog count Num2 and the reference backlog count Num3 is calculated. The ratio Num2 / Num3 is then multiplied by the number of containers in the current multiple queues to obtain the product result.
[0064] In step 20322A, the first product is rounded up to obtain the first rounding result; the number of containers running multiple queues in the virtualization environment is increased to the first rounding result, wherein the ratio of the first rounding result to the reference stacking number is less than or equal to a set multiple.
[0065] It should be noted that, since the ratio of the first rounding result to the reference heap size is limited to less than or equal to a set multiple, the maximum range of the first rounding result is limited to the product of the reference heap size and the set multiple. This is to avoid excessively increasing the number of container combinations as the number of containers running multiple queues in the virtualization environment increases, thereby saving resources.
[0066] In some embodiments, see Figure 8 , Figure 8 This is another flowchart illustrating the dynamic adjustment of the number of container combinations used to run multiple queues in a virtualized environment, as provided in this application embodiment. Figure 6 Step 2032 shown can be achieved through Figure 8 Steps 20321B-20322B in the process yield multiple sets of quota identifiers to be eliminated.
[0067] In step 20321B, when the total number of messages in multiple queues does not reach the second total number threshold, the ratio of the number of messages in the queues to the reference number is determined, and the second product of the ratio and the number of containers in the current multiple queues is determined. The second total number threshold is less than the reference number of messages in the queues, and the first total number threshold is greater than the second total number threshold.
[0068] For example, the total number of messages piling up in multiple queues is detected in a unit time period (e.g., 1 hour, 1 quarter of an hour, 1 minute) (e.g., a period of 15 seconds), and the detection result is the piling up number Num4. When the value of the piling up number Num4 is less than the first piling up number total threshold, the ratio Num4 / Num5 of the current piling up number Num4 and the reference piling up number Num5 is calculated. The above ratio is multiplied by the number of containers in the current multiple queues to obtain the product result.
[0069] In step 20322B, the second product is rounded up to obtain the second rounding result, which reduces the number of containers running multiple queues in the virtualization environment to the second rounding result.
[0070] It should be noted that by relating the change (decrease or increase) in the number of containers combined in multiple queues to the ratio of the reference backlog to the current backlog, the storage resources in the virtual scenario are maximized, while the message system achieves high availability and low cost in response to sudden traffic surges.
[0071] In step 204, at least one message is scheduled from multiple queues in the dynamically adjusted virtualization environment.
[0072] Here, a target queue is randomly selected from multiple queues in the dynamically adjusted virtualization environment, and at least one message is scheduled from the target queue in a first-in-first-out manner.
[0073] In some embodiments, see Figure 9 , Figure 9 This is a flowchart illustrating a deterministic message sending service provided in an embodiment of this application. Figure 3 After scheduling at least one message from multiple queues in step 204, as shown, it is also possible to... Figure 9 Steps 2041-2043 determine the message sending service.
[0074] In step 2041, the weights corresponding to multiple candidate message sending services are obtained, wherein the normalized weights represent the probability that a candidate message sending service is selected for sending messages.
[0075] In some embodiments, the weights corresponding to multiple candidate message sending services are determined based on the cumulative number of messages sent by the candidate message sending service or the number of messages that the candidate message sending service can process per unit time. The weights corresponding to the multiple candidate message sending services are then normalized. The steps for normalizing the weights corresponding to the multiple candidate message sending services are as follows: For example, if the number of multiple candidate message sending services is 3, the weights corresponding to them are w1, w2, and w3, respectively. w1, w2, and w3 are added together to obtain w. w1 / w is used as the probability of the first candidate message sending service, w2 / w is used as the probability of the second candidate message sending service, and w3 / w is used as the probability of the third candidate message sending service.
[0076] It should be noted that the weight of the candidate message sending service is positively correlated with the proportion of the cumulative number of messages sent by the candidate service in all message sending services, or positively correlated with the processing capacity of the candidate message sending service (i.e. the number of messages that can be processed per unit time). By setting different weights for multiple candidate message sending services, the probability of a candidate message sending service being selected for sending messages can be controlled, that is, the load of the candidate message sending services can be balanced.
[0077] For example, the candidate message sending services can be sorted in descending order based on the cumulative number of messages sent in the past. The candidate message sending services that are ranked higher in the ranking result are given a larger weight value than the candidate message sending services that are ranked lower. Alternatively, the candidate message sending services can be sorted in descending order based on their load capacity. The candidate message sending services that are ranked higher in the ranking result are given a larger weight value than the candidate message sending services that are ranked lower.
[0078] In step 2042, the messages in the queue are grouped according to the number of candidate message sending services to obtain at least two message groups.
[0079] In some embodiments, the messages in the queue are divided into the same number of groups as the number of candidate message sending services, and the messages in the queue are grouped proportionally according to the weights corresponding to each candidate message sending service, resulting in at least two message groups with different message counts.
[0080] For example, the number of candidate message sending services is 3, denoted as candidate message sending service AC. The messages in the queue are divided into 3 groups, where there is a one-to-one correspondence between the 3 message groups and the candidate message sending services. The ratio of the number of messages in the 3 message groups is equal to the ratio of the weights of the candidate message sending services corresponding to the 3 message groups. For example, when the weights of the candidate message sending services are 20, 30, and 50, the ratio of the number of messages in the three groups is 2:3:5.
[0081] In step 2043, the candidate message sending service corresponding to the message group to which the message belongs is used as the message sending service.
[0082] Continuing from the previous example, based on the first-in, first-out (FIFO) principle of message sending in the queue, the first 20 messages belonging to message group M1 in the queue are assigned to candidate message sending service F1 for sending. That is, candidate message sending service F1 acts as the message sending service to send messages belonging to message group M1. Similarly, the first 20 messages belonging to message group M2 in the queue are assigned to candidate message sending service F2 for sending, and the first 30 messages belonging to message group M3 in the queue are assigned to candidate message sending service F3 for sending.
[0083] In some embodiments, determining a message sending service from candidate message sending services can also be achieved through the following steps: determining three corresponding intervals, for example, Q, based on the weights corresponding to candidate message sending services M1-M3. A (0, 20), Q B (21, 40), Q C (41, 100), map the candidate message sending services F1-F3 to the three intervals one-to-one. For example, map server F1 to interval Q. A Server F2 corresponds to interval Q B Server F3 corresponds to the interval Q C Randomly select one queue from multiple queues and schedule at least one message from the selected queue according to the first-in-first-out rule. Randomly generate a positive integer in the range (1-100) and use the candidate message sending service corresponding to the specific interval where the positive integer falls as the message sending service.
[0084] In some embodiments, after scheduling at least one message from multiple queues, the message sending service can be determined by the following steps: finding the sending configuration file for the business scenario corresponding to at least one message; selecting at least one message sending service from multiple candidate message sending services according to the message sending service scope in the sending configuration file, wherein the message sending service scope includes multiple candidate message sending services accessing the virtualization environment.
[0085] For example, at least one message sending service can be randomly selected from multiple candidate message sending services based on the message sending service range in the sending configuration file. Alternatively, a message sending service can be selected from the message sending service range in the sending configuration file based on the user's choice.
[0086] In some embodiments, multiple candidate message sending services within the message sending service scope have their own different attributes, such as different sending costs and different delivery quality. By searching the message sending service scope in the sending configuration file corresponding to the business scenario of the message, the candidate message sending service with the target attribute (i.e. the attribute that the message sending service needs to satisfy) can be arbitrarily selected from the configuration file, thereby enhancing the user's right to choose, forming customized user choices and specific sending channels, ensuring the quality of message delivery, and optimizing the user experience.
[0087] In step 205, the message sending service is invoked to send at least one scheduled message to the terminal.
[0088] In some embodiments, see Figure 10 , Figure 10 This is a schematic diagram illustrating a process of sending a message to a terminal using a message sending service provided in this application embodiment. Figure 3 Step 205 shown can be achieved through Figure 10 Steps 2051-2053 are implemented.
[0089] In step 2051, the message is parsed to obtain the message parameters, which include message request parameters and the identifier of the message sending service template.
[0090] For example, messages are scheduled from multiple dynamically adjusted queues and parsed to obtain message parameters, where message request parameters include message address and account information for message sending service; In step 2052, the message sending service template is determined based on the identifier of the message sending service template, and the placeholders in the message sending service template are replaced with the request parameters in the message to obtain the message content corresponding to the message.
[0091] For example, the message sending service template corresponding to the message sending service is determined based on the identifier of the message sending service template, and the placeholders in the template message sending service template are replaced with the account and password of the message sending service to assemble the complete message content.
[0092] In step 2053, the request parameters in the message are concatenated to obtain the sending protocol corresponding to the message sending service. The message sending service corresponding to the sending protocol is called through the sending protocol to send the message content corresponding to the message to the terminal.
[0093] In some embodiments, the request parameters in the message are concatenated into a sending protocol corresponding to the message sending service, such as the sending protocol of the AWS Business Process Management Development Platform or the Mailchimp online email subscription tool, and the message is sent by calling the message sending service interface corresponding to the concatenated sending protocol.
[0094] In some embodiments, after the message sending service is invoked to send at least one scheduled message to the terminal, the message identifier and message status corresponding to at least one message returned by the message sending service can also be received; the message status is marked by a state machine, and the marked message status is stored according to the message identifier to obtain statistical data corresponding to at least one message; based on the statistical data, a message statistical report including at least one message is generated.
[0095] For example, upon receiving the message identifier and message status corresponding to the message returned by the message sending service, the message status is re-marked using a state machine. For instance, the message status can be marked as one of the following states: current state (not delivered, not clicked), conditional state (click operation), or next state (delivered, clicked). The physical principle behind the state machine marking the message status is that the state machine consists of a state register and combinational logic circuits. It can transition between states according to a pre-set state based on control signals. It is the control center that coordinates related signal actions and completes specific operations. The message status is stored according to the correspondence between the message identifier and the marked message status to obtain the corresponding statistical data. The correspondence includes a one-to-one correspondence between the message identifier and the marked message status. The marked status corresponding to the message is then looked up using the message identifier to generate a message statistical report including at least one message. This allows for a direct view of message delivery and click status.
[0096] In some embodiments, after the message sending service is invoked to send at least one scheduled message to the terminal, the system can also receive common parameters and message status returned by the message sending service. The common parameters represent the common message identifier of multiple messages. The message status is marked by a state machine, and the marked messages are stored according to the common message identifier of multiple messages to obtain statistical data corresponding to multiple messages. Based on the statistical data, a message statistical report including multiple messages is generated.
[0097] For example, upon receiving a common message identifier and message status corresponding to multiple messages returned by the message sending service, the message status is re-marked using a state machine. For instance, the message status can be marked as one of the following states: current state (not delivered, not clicked), conditional state (click operation), or next state (delivered, clicked). The message status is stored according to the correspondence between the common message identifier and the marked message status of multiple messages, thus obtaining the corresponding statistical data. The correspondence includes one common message identifier corresponding to multiple marked message statuses. The marked statuses of multiple messages are uniformly searched using the common message identifier of multiple messages, generating a message statistical report that includes multiple messages. This allows for more efficient generation of message statistical reports while providing an intuitive view of message delivery and click status.
[0098] In some embodiments, when an anomaly is detected in the message sending service, the system automatically switches to a backup message sending service.
[0099] For example, when an abnormal situation such as network failure or program crash is detected in the message sending service, the interface of the message sending service is replaced with the interface of the backup message sending service, thereby avoiding the inability to send messages through the message sending service and improving the efficiency of message sending.
[0100] In some embodiments, before invoking the message sending service to send at least one scheduled message to the terminal, the sending configuration file of the business scenario corresponding to at least one message can be searched; according to the message sending service range in the sending configuration file, at least one message sending service is selected from multiple candidate message sending services, wherein the message sending service range includes multiple candidate message sending services.
[0101] For example, before calling the message sending service to send at least one scheduled message to the terminal, the sending configuration file of the business scenario corresponding to the message is searched to obtain multiple candidate message sending services that can be selected from the configuration file. At least one message sending service is randomly selected from the multiple candidate message sending services, and the message is sent according to the selected at least one message sending service. In this way, the candidate message sending services are limited by the sending configuration file of the business scenario corresponding to the message, and the number of message sending services is increased, thereby improving the efficiency of message sending and realizing the load balancing of message sending.
[0102] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario, taking a game business system as an example and a game scenario as the business scenario.
[0103] The messaging system receives multiple messages from various game business systems. Based on the game scenario corresponding to each message (including social, email, and message verification scenarios), each message is stored in different queues on the cloud platform according to its game scenario. This means that messages corresponding to different game scenarios are categorized and stored accordingly. These messages include instant messaging messages, emails, and verification SMS messages. When a queue used for storing messages is full, the cloud platform's queues are expanded. When a queue used for storing messages is empty, the cloud platform's queues are shrunk. At least one message is scheduled from the multiple queues on the cloud platform after the adjustment, and the message sending service is invoked to send the scheduled message to the terminal.
[0104] The following will describe an exemplary application of the embodiments of this application in a real-world application scenario.
[0105] This application's embodiments can be applied to message services (i.e., the message system mentioned above) on cloud platforms (i.e., the virtualized environment above), such as message sending scenarios and information verification scenarios. This application's embodiments propose a message sending scheme that decouples message storage, dynamically adjusts the queue size based on message accumulation, and visually displays the message sending status. See also... Figure 11 , Figure 11 This is a schematic diagram illustrating the architectural principle of message sending provided in an embodiment of this application, as shown below. Figure 11As shown, the message service uses a scheduling module (including the aforementioned message storage module and queue adjustment module), a sending module (i.e., the aforementioned message sending module), and a callback statistics module to uniformly send received messages. The message status is updated, queried, and queried and updated through the message status database and the query engine corresponding to the message status (i.e., the hardware and software implementation module corresponding to the state machine). Thus, the callback statistics module can collect statistics on the message status data and obtain statistical results. Based on the statistical results, a message statistics report is generated, which will be explained in detail below.
[0106] The business system sends messages to the scheduling module via the network protocol (HTTP, Hyper Text Transfer Protocol). After receiving the message request, the scheduling module finds the corresponding business parameters in the configuration file based on the business parameters of the message request, queries the address and queue name corresponding to the message from the key-value storage system, encapsulates the message request into a message, serializes it, and enqueues it into the queue corresponding to the address and queue name.
[0107] The sending module retrieves messages from the queue and parses the messages to obtain the message request parameters (including the message address, message template name, and the identifier of the account used for the message sending service). Different message sending services can be provided by different message providers.
[0108] The sending module replaces the placeholders in the template with the request parameters carried in the message, assembles them into complete message content, concatenates the parameters into the message sending service protocol, and then calls the message sending service interface to send the message content to the terminal through the concatenated protocol.
[0109] After the sending module calls message sending services 1-5 to send a message, it asynchronously returns the message status of successful message reception to the client and returns the unique identifier corresponding to the message to the callback statistics module.
[0110] The callback statistics module updates the message status to the message status database using the message's unique identifier and message status. The callback statistics module then uses the message status database and query engine to determine and perform statistics such as message delivery rate, click rate, and open rate, and generates statistical reports based on the statistical data.
[0111] It's important to note that key-value stores support master-slave synchronization. Data can be synchronized from the master server to any number of slave servers, and a slave server can be a master server associated with other slave servers. The roles of master and slave servers can be interchangeable. This allows key-value stores to perform single-level tree replication, and write operations can be performed intentionally or unintentionally during storage. Because a publish / subscribe mechanism is fully implemented, slave databases can subscribe to a channel and receive the complete message publication record from the master server when synchronizing the tree from anywhere. Synchronization greatly benefits the scalability of read operations and data redundancy.
[0112] See Figure 12 , Figure 12 This is a flowchart illustrating a message sending method provided in an embodiment of this application, combined with... Figure 12 The steps shown are explained.
[0113] Step 401: The scheduling module stores the received messages in a queue according to the business scenario corresponding to the message.
[0114] The scheduling module parses the received message to obtain the message's business parameters, including the game identifier and the source identifier. After concatenating the business parameters, a string corresponding to the concatenated business parameters is obtained. The string is matched with the priority parameter to obtain the message's storage address in the virtualization environment. Based on the storage address, the message is stored in the queue in the virtualization environment corresponding to the business scenario (including high real-time scenarios, gray-scale testing scenarios, and mass sending scenarios).
[0115] The method for setting the storage address in the configuration file is illustrated by the following pseudocode: { "queue_path": { "redis_instance_config": { "redis_1": "ip: / / 10.191.90.16:6379@password", / / Redis address, username, password "redis_2": "ip: / / 10.191.90.17:6379@password", / / Redis address, username, password "redis_3": "ip: / / 10.191.90.18:6379@password" / / Redis address, username, and password }, "priority_config": { "listgroup1:1": [ "redis_1" / / The Redis address (i.e., storage address) in redis_instance_config ], "listgroup1:2": [ "redis_2" / / The Redis address in redis_instance_config ], "listgroup1:3": [ "redis_3" / / The Redis address in redis_instance_config ] }, "listgroup_config": { "email_group1": [ "listgroup1:1", / / The name of the queue group with a priority of 1, for scenarios with the highest real-time requirements. The Redis address is found in priority_config. "listgroup1:2", / / The name of the queue group with priority 2, the queue for gray-scale testing, whose Redis address is found in priority_config. "listgroup1:3" / / Queue name with priority 3, suitable for mass messaging scenarios where real-time requirements are not high; the Redis address is found in priority_config. "email": { "11_0": "email_group1", / / Emails sent to gameid=11, source=0 are sent using the queue group email_group1 "12_0": "email_group1" / / Emails sent for gameid=12 and source=0 use the queue group email_group1 } } It should be noted that, as can be seen from the pseudocode above, the storage address of the message can be determined by matching the strings (12_0, 11_0) concatenated from the business parameters in the message with the priority parameters (listgroup1:1, listgroup1:2, listgroup1:3). Messages from different scenarios can then be stored in different queues, thereby achieving business isolation. This ensures that if a queue accumulates due to excessive business volume in one business, it will not affect the sending service of other businesses, thus improving service availability.
[0116] Based on the business parameters, the queue address corresponding to the stored message is found, as illustrated by the following pseudocode: / / Currently, priority levels 1, 2, and 3 are only supported. if priority<1 || priority>3 { priority = DEFAULT_PRIORITY } G_dispath.RLock() / / Business: EMAIL or SMS / / Get the Redis address and queue name of all business configuration queues dispath := G_dispath.DispathCfg[G_dispath_index].queueDispath.QueuePath[business] / / Default queue name and Redis address if no business configuration is found. defaultQueue := G_dispath.DispathCfg[G_dispath_index].queueDispath.DefaultVal[business][int(priority)] G_dispath.RUnlock() var businessList []string / / Key composed of gameid and source businessList = append(businessList, fmt.Sprintf("%d_%d", gameid,source)) var priorityList map[int][]RedisConfig var redisIntanceList[]RedisConfig var ok bool for _, key := range businessList { log.DebugContextf(ctx, key) / / Configuration for query services priorityList, ok = dispath[key] if ok { / / Get the queue with the corresponding priority redisIntanceList, ok = priorityList[int(priority)] if !ok { / / No priority queue found, the queue with priority 1 will be used by default. redisIntanceList = priorityList[PRIORITY_1] } break } } It should be noted that, as can be seen from the pseudocode above, by reading the business parameters in the message and concatenating the business parameters (gameid, source) into a keyword string, writing the keyword string into businessList, searching the configuration file based on the keyword string in businessList, querying the corresponding business configuration, and iterating through the priorityList array with the obtained priority parameter to obtain the queue corresponding to the message priority, thereby determining the queue address for storing the message based on the queried business configuration and priority parameter, and then retrieving the corresponding business message from the queue.
[0117] Step 402: The scheduling module shrinks or expands multiple queues by detecting the accumulation of messages in the queues.
[0118] The scheduling module triggers Kubernetes HPA to dynamically scale up or down the queue size based on message backlog in the queue. Dynamic scaling of Kubernetes HPA can be achieved through the following steps: The container detection program in the scheduling module detects the total number of messages backlogged in virtual containers. When the duration exceeds a preset duration (e.g., 3 seconds) and the backlog exceeds a preset backlog limit (e.g., 1000), Kubernetes HPA is triggered to scale the virtual containers. Alternatively, the number of replicas can be dynamically scaled up or down based on the current utilization of POD resources (e.g., CPU, disk, memory) to alleviate pressure on individual PODs. Besides CPU utilization and memory usage, automatic scaling can also be performed based on custom metrics provided by other applications. Under specific circumstances, when backlogged messages are detected and no backlogged messages are detected within 15 seconds, automatic scaling down will occur, maximizing resource utilization, handling sudden traffic surges, and achieving overall high availability and low cost for the service.
[0119] See Figure 13 , Figure 13 This is a flowchart illustrating the dynamic adjustment of a virtual container provided in an embodiment of this application. Figure 13 To illustrate the specific process of dynamic scaling, the scheduling module mentioned above includes a container detection program, a detection process, a third-party custom metric collector, a self-adaptor, a controller, and a virtual container quantity adjuster.
[0120] A container detection program monitors message backlog within virtual containers and sends this backlog as a custom metric to the detection process. The detection process pushes this custom metric data to a third-party custom metric collector, which then pushes the data out and converts it into Kubernetes metrics. These metrics are then pushed into the controller via a self-adaptor. The controller controls the virtual container size regulator, enabling elastic scaling of virtual containers.
[0121] It's important to note that Kubernetes (k8s) can efficiently manage these clusters, which can be deployed across public, private, or hybrid clouds. In related technologies, enterprise application traffic varies significantly, with peaks and troughs. Maintaining a constant number of storage machines capable of handling peak traffic at all times would be extremely costly. The usual solution is to automatically adjust the number of storage machines based on traffic volume or resource utilization.
[0122] Step 403: The sending module integrates the interfaces of multiple message sending services through a plugin.
[0123] The sending module assigns different weights to multiple candidate message sending services, and determines the message sending service from among them based on the weights of the candidate message sending services and the position of the messages in the queue. Different message sending services can be provided by different message providers.
[0124] The following pseudocode illustrates the deterministic message sending service: / / Increase the candidate message sending service and its corresponding weight func (r) WeightRoundRobin) AddAccount(accountinfo AccountInfo) { accountinfo.Start = r.totalWeight r.totalWeight += accountinfo.Weight accountinfo.End = r.totalWeight r.AllAccount = append(r.AllAccount, accountinfo) } / / Confirm message sending service func (r) WeightRoundRobin) GetBackendAccount(ctx context.Context) ( AccountInfo, error) { guid := xid.New() v:=int(crc32.ChecksumIEEE([]byte(guid.String()))) v = v %r.totalWeight log.DebugContextf(ctx, "%d", v) for _, account:= range r.AllAccount { if v>= account.Start&&v <account.End { return account, nil } } It should be noted that, as can be seen from the pseudocode above, after storing messages from different scenarios in different queues, during the process of determining the message sending service from the messages in the queue, candidate message sending services and their corresponding weights can be added to ensure that the number of messages in a message group in the queue is equal to the weight of the candidate message sending service corresponding to the message group. This allows the messages in the queue to be assigned to different candidate message sending services. See [link to relevant documentation]. Figure 14 , Figure 14 This is a schematic diagram of load balancing for message sending services provided in this application embodiment, such as... Figure 14 As shown, there are three candidate message sending services: F1, F2, and F3, with weights of 10, 10, and 20, respectively. Based on the weight allocation intervals, the first 10 messages in the queue are assigned to candidate message sending service F1, messages from the 11th to the 20th are assigned to candidate message sending service F2, and messages from the 21st to the 40th are assigned to message sending service F3. Alternatively, based on the weights 10, 10, and 20, three intervals are determined: Q1 (0, 10), Q2 (11, 20), and Q3 (21, 40). Intervals Q1-Q3 correspond to candidate message sending services F1-F3. When a message is retrieved from the queue, a random number is generated, and the interval containing the random number is determined. The retrieved message is then assigned to the candidate message sending service corresponding to that interval, and the assigned candidate message sending service sends the message.
[0125] When a message sending service becomes unavailable, a backup message sending service will be switched on to retry sending SMS messages and emails. Multiple message sending services share the message sending load. Step 404: The callback statistics module detects the message status through a state machine and generates a message status report based on the detection data. (See [link]). Figure 15 , Figure 15 This is a schematic diagram of the message sending architecture provided in the embodiments of this application. The process of generating the message status report after message sending is described in detail below.
[0126] The business system accesses the scheduling module via a network protocol (HTTP, Hyper Text Transfer Protocol). After receiving a message request, the scheduling module finds the corresponding business parameters in the configuration file based on the business parameters of the message request (gameid, sourceid), obtains the address and queue name corresponding to the message from the key-value storage system, encapsulates the message request into a message, serializes it, and enqueues it into the queue corresponding to the address and queue name. The queue detection program (there is a one-to-one correspondence between queues and queue detection programs) retrieves at least one message from the queue and sends it to the message service. When the message sending service successfully sends the message in the queue, it asynchronously returns the message identifier and message status to the queue detection program. The queue detection program updates the message status corresponding to the message stored in the message status database. The message status database has its corresponding query engine (including online query engine and offline query engine).
[0127] The callback statistics module retrieves message identifiers and statuses from the message sending service and updates the message identifier record in the message status database. The message status in the database can be recorded or retrieved using a unique identifier. The search criteria for message status include address and date. The unique message identifier is assigned a common parameter (task_name) to messages sent in batches for the same task. This common parameter is used to statistically mark the batch-sent messages. The callback statistics module uses this common parameter to query and analyze statistics such as delivery rate, click-through rate, and open rate of batch-sent messages in the message status database, and generates statistical reports based on the results.
[0128] The container detection program in the scheduling module polls the load status of the detection queue. When a new message is received, it is retrieved, parsed, and its address (e.g., phone number or email address), template name, and identifier of the message sending service account are obtained. Next, a local template is rendered, replacing placeholders with the request parameters carried in the message, assembling the complete message content, and then concatenating these parameters into the message sending service protocol. The message sending service interface is then called to send the message content. The message sending service returns a unique message identifier (which is needed by downstream message sending services to query and update records during subsequent callbacks) and message status. The callback statistics module records the message status returned by the message sending service in the message status database. During this period, the message has been delivered to the message sending service.
[0129] When a user receives and opens a message, the message sending service sends an event to the callback statistics module. The callback statistics module records the message's status based on its ID. Similarly, if the message contains an external link, the callback statistics module receives a click event when the user opens that link. By marking each message's status (delivery, open, click, rejection, blocking, complaint, etc.), and then generating statistical reports by querying message identifiers and their corresponding statuses, message content can be optimized based on these reports.
[0130] This application's embodiments can be applied to unified message delivery scenarios, such as game message sending scenarios and email sending scenarios. The following explanation uses a game message sending scenario as an example: See below Figure 16 , Figure 16 This is a flowchart illustrating a message receiving and sending scheme provided in an embodiment of this application. The following is based on... Figure 16 The message receiving and sending scheme is explained.
[0131] The game business party submits the message sending request, and the delivery operations personnel and the game business party confirm the use case. When the use case is determined to be a registration, account deletion, or other similar scenario, the SaaS platform provides an SDK package to the game business party. The game business party embeds the SDK package into the game project and calls the corresponding function for the use case. When the use case is determined to be a marketing scenario, the game business party provides a table of user groups that need to receive the message, and the game business party confirms the sending area and other information.
[0132] Delivery operations personnel configure the sending entity, message content, templates, etc., in the management interface of the SaaS platform according to business needs, and preview the message display on the page. When mass messaging is required, the recipient table is imported in the management interface of the SaaS platform. The test team conducts tests in the test environment, such as verifying whether mobile phones, email addresses, etc. receive messages, and whether the message style meets expectations. The launched messaging service generates statistical reports based on mass messaging tasks or business-level statistics such as message open rate, click rate, subscription rate, and unsubscribe rate.
[0133] See below Figures 17A-17C , Figures 17A-17C This is a schematic diagram of the message sending interface provided in an embodiment of this application. Figure 17AThe displayed email service providers include multiple different email service providers (i.e., message sending services). MailChimp162 represents the name of a specific email service provider. Users select the specific email service provider by checking box 161 on the message sending interface diagram. The selected email service provider is then designated as the one sending the current email. It can be seen that the message sending system aggregates and displays multiple message sending services, allowing users to choose the service they prefer. This achieves load balancing across the various message sending services, as illustrated in the interface diagram. Figure 17B The template name 163, email subject 164, and simulated content 165 shown can all be represented by placeholders (e.g., verify_code). Therefore, the specific content corresponding to the template name 163, email subject 164, and simulated content 165 does not need to be completely input by the user. It can be seen that the message sending system configures the sending body through the management terminal, allowing settings for the template name, template title, and template content. It also allows for customized configuration of corresponding email templates for various scenarios (including account registration, password modification, login verification, and account modification). Default support includes account registration, password modification, and account modification, and it supports template configuration variables. When sending, the template name and variable mapping are passed in, increasing user efficiency when sending emails. (See the interface illustration.) Figure 17C The data summary 166 shown includes the number of requests sent, the number of requests approved, the number of emails delivered, the number of emails opened, the number of emails bounced, and the number of users who clicked links. Figure 17C The system displays the number of emails corresponding to different statuses (including sent request, request accepted, delivered, opened, bounced, and clicked link). It can be seen that the message sending system counts the number of emails corresponding to different statuses at different times in the mass message task and draws the statistical data into a statistical report, so that the system can understand the open rate, click rate and other statistical data of the message after it is delivered in real time.
[0134] In summary, the embodiments of this application have the following beneficial effects: 1. Under the cloud platform architecture, it aggregates functions such as SMS, email, and APP notifications, and uses queues to physically separate and store messages in different business scenarios, thereby decoupling message storage. The number of queues is dynamically adjusted according to the accumulation of messages in the queues to achieve load balancing of message storage.
[0135] 2. Multiple candidate message sending services are aggregated, and weights are assigned to the candidate message sending services using the concept of application load balancing. The message sending service is determined by matching the weights with the messages in the queue. The determined message sending service is then used to send messages. The rendering template and message content are provided to the message sending service for sending, which simplifies the message sending process and improves the message sending efficiency.
[0136] 3. The state machine measures and controls the status of messages, and generates statistical reports based on the message status data after asynchronous callbacks. The statistical reports visually display statistical information such as delivery rate, click rate, and open rate of batch message sending, which intuitively reflects the quality of message sending and gives business users an intuitive understanding of message content determination and sending method selection.
[0137] It is understood that, in the embodiments of this application, the data related to instant messaging messages, etc., need to obtain user permission or consent when the embodiments of this application are applied to specific products and technologies, and the collection, use and processing of related data need to comply with the relevant laws, regulations and standards of relevant countries and regions.
[0138] The following description continues to illustrate the exemplary structure of the message sending device 2155 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software modules in the message sending device 2155 stored in the memory 2140 may include: a message receiving module 21551, used to receive at least one message from at least one business system; a message storage module 21552, used to store each message in a queue corresponding to a business scenario in the virtualization environment according to the business scenario corresponding to each message, wherein each queue is used to store a message corresponding to a business scenario; a queue adjustment module 21553, used to dynamically adjust multiple queues in the virtualization environment according to the load information of multiple queues; and a message sending module 21554, used to schedule at least one message from the multiple queues in the dynamically adjusted virtualization environment and call the message sending service to send the scheduled at least one message to the terminal.
[0139] In some embodiments, the message storage module 21552 is further configured to obtain priority parameters corresponding to multiple business scenarios from the configuration file, wherein the priority parameters correspond one-to-one with multiple business scenarios; and perform the following processing for each message: match the message parameters in the message with the priority parameters to obtain the storage address of the message in the virtualization environment; and store the message in the queue corresponding to the business scenario in the virtualization environment according to the storage address.
[0140] In some embodiments, the message storage module 21552 is further configured to perform serialization processing on the message to obtain the serialization result corresponding to the message; and store the serialization result in a queue in the virtualization environment corresponding to the business scenario.
[0141] In some embodiments, the queue adjustment module 21553 is further configured to detect the sum of the number of messages accumulated in multiple queues according to the detection frequency, and use the obtained detection result as the load information corresponding to the multiple queues; and dynamically adjust the number of container combinations used to run the multiple queues in the virtualization environment according to the load information of the multiple queues, wherein the dynamic adjustment method includes: expanding the number of container combinations used to run the multiple queues in the virtualization environment, or shrinking the number of container combinations used to run the multiple queues in the virtualization environment.
[0142] In some embodiments, the queue adjustment module 21553 is further configured to: determine the ratio of the number of messages in multiple queues to a reference number of messages when the total number of messages in multiple queues reaches a first total number of messages threshold; determine the first product of the ratio and the number of containers in the current multiple queues, wherein the first total number of messages threshold is greater than the reference number of messages in multiple queues; round up the first product to obtain a first rounding result; and increase the number of containers in the multiple queues running in the virtualization environment to the first rounding result, wherein the ratio of the first rounding result to the reference number of messages in multiple queues is less than or equal to a set multiple.
[0143] In some embodiments, the queue adjustment module 21553 is further configured to: determine the ratio of the number of messages piling up in multiple queues to the reference number of messages piling up when the total number of messages piling up in multiple queues does not reach the second total number of messages piling up threshold; determine the second product of the ratio and the number of containers in the current multiple queues, wherein the second total number of messages piling up threshold is less than the reference number of messages piling up, and the first total number of messages piling up threshold is greater than the second total number of messages piling up threshold; perform rounding up on the second product to obtain the second rounding result; and reduce the number of containers in the virtualization environment running multiple queues to the second rounding result.
[0144] In some embodiments, the message sending module 21554 is further configured to obtain the weights corresponding to multiple candidate message sending services, wherein the weights represent the probability that a candidate message sending service is selected for sending messages; group the messages in the queue according to the number of candidate message sending services to obtain at least two message groups; wherein each message group has a one-to-one correspondence with a candidate message sending service, and the number of messages in each message group is equal to the weight of the candidate message sending service corresponding to the message group; and use the candidate message sending service corresponding to the message group to which the message belongs as the message sending service.
[0145] In some embodiments, the message sending module 21554 is further configured to perform the following processing on any message: parse the message to obtain message parameters, wherein the message parameters include message request parameters and an identifier of the message sending service template; determine the message sending service template according to the identifier of the message sending service template, and replace the placeholders in the message sending service template with the request parameters in the message to obtain the message content corresponding to the message; concatenate the request parameters in the message to obtain the sending protocol corresponding to the message sending service; and call the message sending service corresponding to the sending protocol through the sending protocol to send the message content corresponding to the message to the terminal.
[0146] In some embodiments, the message sending device 2155 further includes: a callback statistics module, configured to receive a message identifier and message status corresponding to at least one message returned by the message sending service; perform a marking and storage process on the message identifier and message status through a state machine to obtain statistical data corresponding to at least one message; and generate a message statistics report including at least one message based on the statistical data.
[0147] In some embodiments, the callback statistics module is further configured to receive common parameters and message status returned by the message sending service, wherein the common parameters represent a common message identifier for multiple messages; perform marking and storage processing on the common parameters and message status through a state machine to obtain statistical data corresponding to multiple messages; and generate a message statistics report including multiple messages based on the statistical data.
[0148] In some embodiments, the message sending module 21554 is further configured to automatically switch to a backup message sending service when an abnormality is detected in the message sending service.
[0149] In some embodiments, the message sending module 21554 is further configured to find the sending configuration file of the business scenario corresponding to at least one message; and select at least one message sending service from multiple candidate message sending services according to the message sending service range in the sending configuration file, wherein the message sending service range includes multiple candidate message sending services.
[0150] This application provides a computer program product or computer program that includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the message sending method described in this application.
[0151] This application provides a computer-readable storage medium storing executable instructions. When these executable instructions are executed by a processor, they cause the processor to execute the message sending method provided in this application, for example... Figure 3 The message sending method is shown.
[0152] In some embodiments, the computer-readable storage medium may be a memory such as FRAM, ROM, PROM, EPROM, EEPROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.
[0153] In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as a standalone program or as a module, component, subroutine, or other unit suitable for use in a computing environment.
[0154] As an example, executable instructions can be deployed to execute on a single computing device, or on multiple computing devices located in one location, or on multiple computing devices distributed across multiple locations and interconnected via a communication network.
[0155] The above are merely embodiments of this application and are not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.
Claims
1. A message sending method, characterized in that, The method includes: Receive at least one message from at least one business system; Based on the business scenario corresponding to each message, each message is stored in a queue corresponding to the business scenario in the virtualization environment, wherein each queue is used to store one message corresponding to the business scenario; Based on the load information of multiple queues, the number of container combinations used to run the multiple queues in the virtualization environment is dynamically adjusted, wherein the load information includes the number of messages accumulated in the multiple queues; When the total number of messages accumulated in the multiple queues reaches a first total accumulation threshold, the ratio of the total accumulation to a reference accumulation is determined, and a first product of the ratio and the number of container combinations of the multiple queues is determined, wherein the first total accumulation threshold is greater than the reference accumulation; the first product is rounded up to obtain a first rounding result; the number of container combinations of the multiple queues running in the virtualization environment is increased to the first rounding result; When the total number of messages accumulated in the multiple queues does not reach the second total accumulation threshold, the ratio of the total accumulation to the reference accumulation is determined, and the second product of the ratio and the number of container combinations of the current multiple queues is determined, where the second total accumulation threshold is less than the reference accumulation; the second product is rounded up to obtain a second rounding result; the number of container combinations of the multiple queues running in the virtualization environment is reduced to the second rounding result; At least one message is scheduled from the multiple queues of the dynamically adjusted virtualization environment, and the message sending service is invoked to send the scheduled message to the terminal.
2. The method according to claim 1, characterized in that, The step of dynamically adjusting the number of container combinations used to run the multiple queues in the virtualization environment based on the load information of the multiple queues includes: Based on the detection frequency, the number of messages accumulated in the multiple queues is detected, and the detection results are used as the load information corresponding to the multiple queues. Based on the load information of the multiple queues, the number of container combinations used to run the multiple queues in the virtualization environment is dynamically adjusted. The dynamic adjustment method includes: expanding the number of container combinations used to run the multiple queues in the virtualization environment, or reducing the number of container combinations used to run the multiple queues in the virtualization environment.
3. The method according to claim 1, characterized in that, The ratio of the first rounded result to the reference stacking quantity is less than or equal to a set multiple.
4. The method according to claim 1, characterized in that, The first total stacking threshold is greater than the second total stacking threshold.
5. The method according to claim 1, characterized in that, Each message includes message parameters; The step of storing each message into a queue corresponding to the business scenario in the virtualization environment, based on the business scenario corresponding to each message, includes: Obtain priority parameters corresponding to the multiple business scenarios from the configuration file, wherein the priority parameters correspond one-to-one with the multiple business scenarios; For each of the aforementioned messages, perform the following processing: The message parameters in the message are matched with priority parameters corresponding to the multiple business scenarios to obtain the storage address of the message in the virtualization environment; Based on the storage address, the message is stored in the queue corresponding to the business scenario in the virtualization environment.
6. The method according to claim 5, characterized in that, The step of storing the message in the queue corresponding to the business scenario in the virtualization environment includes: The message is serialized to obtain the serialization result corresponding to the message; The serialization result is stored in a queue in the virtualization environment that corresponds to the business scenario.
7. The method according to any one of claims 1 to 6, characterized in that, Before invoking the message sending service to send at least one of the scheduled messages to the terminal, the method further includes: Obtain the weights corresponding to multiple candidate message sending services, wherein the normalized weights represent the probability that the candidate message sending service is selected for sending messages; The messages in the queue are grouped according to the number of candidate message sending services to obtain at least two message groups; Each message group has a one-to-one correspondence with the candidate message sending service, and the number of messages in each message group is equal to the weight of the candidate message sending service corresponding to the message group. The candidate message sending service corresponding to the message group to which the message belongs is used as the message sending service.
8. The method according to any one of claims 1 to 6, characterized in that, The message includes request parameters and message content; The message sending service sends at least one scheduled message to the terminal, including: For any of the aforementioned messages, perform the following processing: The message is parsed to obtain the message parameters, wherein the message parameters include message request parameters and the identifier of the message sending service template; The message sending service template is determined based on the identifier of the message sending service template, and the placeholders in the message sending service template are replaced with the request parameters in the message to obtain the message content corresponding to the message; The request parameters in the message are concatenated to obtain the sending protocol corresponding to the message sending service; The message content corresponding to the message is sent to the terminal by invoking the message sending service corresponding to the sending protocol.
9. The method according to any one of claims 1 to 6, characterized in that, The method further includes: Receive the message identifier and message status corresponding to at least one of the messages returned by the message sending service; By using a state machine to mark and store the message identifier and the message state, statistical data corresponding to at least one message can be obtained. Based on the statistical data, generate a message statistics report that includes at least one of the messages.
10. The method according to claim 9, characterized in that, The method further includes: Receive common parameters and message status returned by the message sending service, wherein the common parameters represent a common message identifier for multiple messages; By using a state machine to mark and store the common parameters and the message status, statistical data corresponding to multiple messages can be obtained. Based on the statistical data, a message statistics report including multiple messages is generated.
11. The method according to any one of claims 1 to 6, characterized in that, The method further includes: When an abnormality is detected in the message sending service, the system will automatically switch to the backup message sending service.
12. The method according to any one of claims 1 to 6, characterized in that, Before invoking the message sending service to send at least one of the scheduled messages to the terminal, the method further includes: Locate the sending configuration file for at least one of the aforementioned messages corresponding to the business scenario; Based on the message sending service range in the sending configuration file, at least one message sending service is selected from multiple candidate message sending services, wherein the message sending service range includes multiple candidate message sending services.
13. A message sending device, characterized in that, The message sending device includes: The message receiving module is used to receive at least one message from at least one business system; The message storage module is used to store each message into a queue corresponding to the business scenario in the virtualization environment, according to the business scenario corresponding to each message, wherein each queue is used to store one message corresponding to the business scenario; A queue adjustment module is used to dynamically adjust the number of container combinations running the multiple queues in the virtualization environment based on the load information of multiple queues, wherein the load information includes the number of messages backlogged in the multiple queues; when the sum of the number of messages backlogged in the multiple queues reaches a first backlogged quantity threshold, the module determines the ratio of the sum of the backlogged quantity to a reference backlogged quantity, and determines a first product of the ratio and the current number of container combinations of the multiple queues, wherein the first backlogged quantity threshold is greater than the reference backlogged quantity; the first product is rounded up to obtain a first rounded result; the number of container combinations running the multiple queues in the virtualization environment is increased to the first rounded result; when the sum of the number of messages backlogged in the multiple queues does not reach a second backlogged quantity threshold, the module determines the ratio of the sum of the backlogged quantity to a reference backlogged quantity, and determines a second product of the ratio and the current number of container combinations of the multiple queues, wherein the second backlogged quantity threshold is less than the reference backlogged quantity; the second product is rounded up to obtain a second rounded result; the number of container combinations running the multiple queues in the virtualization environment is decreased to the second rounded result; The message sending module is used to schedule at least one message from the multiple queues of the dynamically adjusted virtualization environment, and call the message sending service to send the scheduled message to the terminal.
14. The apparatus according to claim 13, characterized in that, The queue adjustment module is also used for: Based on the detection frequency, the number of messages accumulated in the multiple queues is detected, and the detection results are used as the load information corresponding to the multiple queues. Based on the load information of the multiple queues, the number of container combinations used to run the multiple queues in the virtualization environment is dynamically adjusted. The dynamic adjustment method includes: expanding the number of container combinations used to run the multiple queues in the virtualization environment, or reducing the number of container combinations used to run the multiple queues in the virtualization environment.
15. The apparatus according to claim 13, characterized in that, The ratio of the first rounded result to the reference stacking quantity is less than or equal to a set multiple.
16. The apparatus according to claim 13, characterized in that, The first total stacking threshold is greater than the second total stacking threshold.
17. The apparatus according to claim 13, characterized in that, Each message includes message parameters; the message storage module is further configured to: Obtain priority parameters corresponding to the multiple business scenarios from the configuration file, wherein the priority parameters correspond one-to-one with the multiple business scenarios; For each of the aforementioned messages, perform the following processing: The message parameters in the message are matched with priority parameters corresponding to the multiple business scenarios to obtain the storage address of the message in the virtualization environment; Based on the storage address, the message is stored in the queue corresponding to the business scenario in the virtualization environment.
18. The apparatus according to claim 17, characterized in that, The message storage module is also used for: The message is serialized to obtain the serialization result corresponding to the message; The serialization result is stored in a queue in the virtualization environment that corresponds to the business scenario.
19. The apparatus according to any one of claims 13 to 18, characterized in that, The message sending module is also used for: Before invoking the message sending service to send at least one scheduled message to the terminal, obtain the weights corresponding to multiple candidate message sending services, wherein the normalized weights represent the probability that the candidate message sending service is selected for sending messages; The messages in the queue are grouped according to the number of candidate message sending services to obtain at least two message groups; Each message group has a one-to-one correspondence with the candidate message sending service, and the number of messages in each message group is equal to the weight of the candidate message sending service corresponding to the message group. The candidate message sending service corresponding to the message group to which the message belongs is used as the message sending service.
20. The apparatus according to any one of claims 13 to 18, characterized in that, The message includes request parameters and message content; the message sending module is further configured to: For any of the aforementioned messages, perform the following processing: The message is parsed to obtain the message parameters, wherein the message parameters include message request parameters and the identifier of the message sending service template; The message sending service template is determined based on the identifier of the message sending service template, and the placeholders in the message sending service template are replaced with the request parameters in the message to obtain the message content corresponding to the message; The request parameters in the message are concatenated to obtain the sending protocol corresponding to the message sending service; The message content corresponding to the message is sent to the terminal by invoking the message sending service corresponding to the sending protocol.
21. The apparatus according to any one of claims 13 to 18, characterized in that, The device further includes: The callback statistics module is used to receive the message identifier and message status corresponding to at least one of the messages returned by the message sending service; By using a state machine to mark and store the message identifier and the message state, statistical data corresponding to at least one message can be obtained. Based on the statistical data, generate a message statistics report that includes at least one of the messages.
22. The apparatus according to claim 21, characterized in that, The callback statistics module is also used for: Receive common parameters and message status returned by the message sending service, wherein the common parameters represent a common message identifier for multiple messages; By using a state machine to mark and store the common parameters and the message status, statistical data corresponding to multiple messages can be obtained. Based on the statistical data, a message statistics report including multiple messages is generated.
23. A server for sending messages, characterized in that, The server includes: Memory, used to store executable instructions; A processor, when executing executable instructions stored in the memory, implements the method according to any one of claims 1 to 12.
24. A computer-readable storage medium storing executable instructions, characterized in that, When the executable instructions are executed by the processor, they implement the message sending method according to any one of claims 1 to 12.
25. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, the message sending method according to any one of claims 1 to 12 is implemented.
Citation Information
Patent Citations
Data processing method and device
CN103246653A
Message queue management method and device
CN113138860A
Message queue management method, management system and electronic equipment
CN114265753A
