Message broadcasting methods, apparatus, devices, storage media, and computer program products
By expanding the server cluster and binding online tag information, the problems of user number limitation and storage resource consumption in the group function were solved, and efficient message broadcasting was achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-03-02
- Publication Date
- 2026-05-26
AI Technical Summary
In existing technologies, group functions cannot support message broadcasting among a large number of users, and message transmission requires storing and retrieving messages, resulting in high system storage resource consumption and low efficiency.
By estimating the capacity occupied by the target group, expanding the server cluster, binding long connection information and group identifiers, and allocating online tagging information to sub-servers, real-time broadcasting of group messages is achieved, avoiding storage and retrieval operations.
It expands the capacity of group users, enables support for a large number of users, saves system storage resources, and improves message propagation efficiency.
Smart Images

Figure CN116743517B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to a message broadcasting method, apparatus, device, storage medium, and computer program product. Background Technology
[0002] With the development of information technology, people have gained many conveniences in information dissemination, supporting information interaction, message transmission, and information capture among users, such as text and image information, and voice information. To improve the efficiency of information transmission among users, group functions are widely used in information dissemination scenarios. Users can use group functions to send information to multiple users within a group, thereby enhancing the information's reach. When broadcasting information through group functions, the local server stores the group information sent by users within the group. This information can be inserted into the group message list, allowing receiving users within the group to periodically retrieve the group message using long polling, thus improving the efficiency of information transmission between users and multiple users.
[0003] In the process of researching and practicing the prior art, the inventors of this application discovered that when the prior art broadcasts information through the group function, the number of users that the group function can accommodate is limited, and it cannot support the broadcasting of messages between a large number of users; and when transmitting messages, the messages need to be stored first, and the receiving users need to request to pull the messages, which consumes a lot of system storage resources and reduces the efficiency of message propagation. Summary of the Invention
[0004] This application provides a message broadcasting method, apparatus, device, storage medium, and computer program product that can expand the user capacity of a group to support a large number of users and broadcast received group messages in real time without storing group messages, thus saving system storage resources and improving message propagation efficiency.
[0005] This application provides a message broadcasting method, including:
[0006] Obtain the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users;
[0007] If it is detected that the target occupied capacity is greater than the current actual occupied capacity of the target group, then the server occupied by the target group is expanded according to the target occupied capacity to obtain an expanded server cluster.
[0008] Obtain the long connection information corresponding to each online group user in the target group, and bind each long connection information with the group identifier of the target group to obtain the online tag information corresponding to each online group user;
[0009] The online tag information corresponding to multiple online group users is distributed to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage.
[0010] Upon receiving a group message from an online group user, the group message is sent to multiple sub-servers that have been updated, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0011] Accordingly, embodiments of this application provide a message broadcasting device, including:
[0012] The first acquisition unit is used to acquire the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users.
[0013] An expansion unit is used to expand the server space occupied by the target group according to the target occupied capacity if it is detected that the target occupied capacity is greater than the current actual occupied capacity of the target group, so as to obtain an expanded server cluster.
[0014] The second acquisition unit is used to acquire the long connection information corresponding to each online group user in the target group, and bind each long connection information and the group identifier of the target group to obtain the online tag information corresponding to each online group user.
[0015] The allocation unit is used to allocate online tag information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the allocated online tag information, resulting in multiple sub-servers with updated storage.
[0016] The sending unit is configured to send the group message to the multiple sub-servers that have been updated after receiving the group message sent by the online group user, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0017] In some embodiments, the message broadcasting device further includes a storage unit for:
[0018] In response to a request from a target user to join a target group, obtain the target user's target long connection information;
[0019] Determine the target sub-server occupied by the target group;
[0020] The target long connection information is stored in the target sub-server.
[0021] In some embodiments, the storage unit is further configured to:
[0022] Identify the group type of the target group;
[0023] Based on the group type, determine the target hash key for the target user;
[0024] The target sub-server assigned to the target user when joining the target group is selected based on the target hash key.
[0025] In some embodiments, the storage unit is further configured to:
[0026] If the group type is identified as a preset large group, then a target hash key for the target user is generated based on the user identifier and the group identifier.
[0027] Identify the server cluster occupied by the target group;
[0028] Based on the target hash key, select the target sub-server corresponding to the target user when joining the target group from the server cluster corresponding to the target group.
[0029] In some implementations, the storage unit is further used for:
[0030] If the group type is identified as a preset subgroup, a target hash key for the target user is generated based on the group identifier.
[0031] In some embodiments, the message broadcasting device further includes a merging unit, which is also used for:
[0032] If it is detected that the target occupied capacity is less than the current actual occupied capacity of the target group, then the number of sub-servers corresponding to the actual occupied capacity is determined;
[0033] If multiple sub-servers are identified, the initial sub-server occupied by the target group is selected from the multiple sub-servers;
[0034] Obtain the long connection information of each online group user in the multiple sub-servers, and merge and store the long connection information of each online group user in the initial sub-server.
[0035] In some implementations, the first acquisition unit is configured to:
[0036] Obtain the list of group users corresponding to the target group, and find the update time of the long connection information corresponding to each group user in the list of group users;
[0037] Based on the update time of each long connection information, determine the current online interval duration of each group of users;
[0038] Users in groups whose online interval is less than a preset time threshold are identified as online group users, and the number of online group users in the target group is obtained.
[0039] Furthermore, this application also provides a computer device, including a processor and a memory, wherein the memory stores a computer program, and the processor is used to run the computer program in the memory to implement the steps in the message broadcasting method provided in this application.
[0040] Furthermore, embodiments of this application also provide a computer-readable storage medium storing a plurality of instructions adapted for loading by a processor to execute steps in any of the message broadcasting methods provided in embodiments of this application.
[0041] Furthermore, embodiments of this application also provide a computer program product, including computer instructions, which, when executed, implement the steps in any message broadcasting method provided in embodiments of this application.
[0042] This application embodiment can obtain the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users. If it is identified that the target capacity is greater than the current actual capacity occupied by the target group, the server occupied by the target group is expanded according to the target capacity to obtain an expanded server cluster. The long connection information corresponding to each online group user in the target group is obtained, and each long connection information is bound to the group identifier of the target group to obtain the online tag information corresponding to each online group user. The online tag information corresponding to multiple online group users is distributed to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information to obtain multiple sub-servers with updated storage. When a group message is received from an online group user, the group message is sent to the multiple sub-servers with updated storage, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information. Therefore, this solution expands the server capacity based on the target group's required server space and stores the online tagging information of online group users in the expanded server cluster. This distributes the target group and online group users across various sub-servers, thereby expanding the target group's user capacity and enabling the target group to support a large number of users. Furthermore, received group messages can be broadcast in real time without storing them or requiring the receiving end to request them, saving system storage resources and improving message propagation efficiency. Attached Figure Description
[0043] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 This is a schematic diagram of a message broadcasting system provided in an embodiment of this application;
[0045] Figure 2 This is a flowchart illustrating the steps of the message broadcasting method provided in the embodiments of this application;
[0046] Figure 3 This is a flowchart illustrating another step of the message broadcasting method provided in this application embodiment;
[0047] Figure 4 This is a schematic diagram of the architecture of the message broadcasting system provided in the embodiments of this application;
[0048] Figure 5 A timing flowchart illustrating the message broadcasting method provided in the application embodiment;
[0049] Figure 6 A schematic diagram of the server cluster architecture provided for the application embodiment;
[0050] Figure 7 This is a schematic diagram of the structure of the message broadcasting device provided in the embodiments of this application;
[0051] Figure 8 This is a schematic diagram of the structure of the computer device provided in the embodiments of this application. Detailed Implementation
[0052] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0053] This application provides a message broadcasting method, apparatus, device, storage medium, and computer program product. Specifically, this application will describe the message broadcasting apparatus from the perspective of a message broadcasting device, which can be integrated into a computer device, such as a server or a user terminal. The server can be a standalone 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 user terminal can be a smartphone, tablet, laptop, desktop computer, smart speaker, smartwatch, smart home appliance, vehicle terminal, smart voice interaction device, aircraft, 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 herein.
[0054] The message broadcasting method provided in this application is illustrated in the following embodiments:
[0055] For example, see Figure 1 This is a schematic diagram of a message broadcasting system provided in an embodiment of this application. The scenario includes a terminal or a server.
[0056] The terminal or server can obtain the number of online group users included in the target group and estimate the target capacity occupied by the target group on the server based on the number of online group users. If it is found that the target capacity is greater than the current actual capacity occupied by the target group, the server occupied by the target group is expanded according to the target capacity, resulting in an expanded server cluster. The long connection information corresponding to each online group user in the target group is obtained, and each long connection information is bound to the group identifier of the target group to obtain the online tag information corresponding to each online group user. The online tag information corresponding to multiple online group users is distributed to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage. When a group message is received from an online group user, the group message is sent to the multiple sub-servers with updated storage, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0057] The message broadcasting process can include estimating the target server capacity required by the target group, expanding the server capacity required by the target group, generating online tag information for online group users, evenly storing multiple online tag information across multiple sub-servers, sending group messages to each sub-server, and each sub-server sending group messages to online group users who have already stored online tag information.
[0058] The following sections provide detailed descriptions of each example. It should be noted that the order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0059] In this embodiment, the description will focus on a message broadcasting device, which can be integrated into a computer device such as a terminal or server. See also Figure 2 , Figure 2 This is a flowchart illustrating the steps of a message broadcasting method provided in this application embodiment. Taking the example of a message broadcasting device specifically integrated on a server, the specific process when the processor on the server executes the program corresponding to the message broadcasting method is as follows:
[0060] 101. Obtain the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users.
[0061] The target group can be a group containing multiple users, supporting message interaction between these users, such as text, images, and voice messages. For example, the target group can support the broadcasting of text, image, video, audio, voice, and other messages between multiple online users (corresponding terminals, such as web / Android / PC).
[0062] In this context, "online group user" refers to a group user within the target group who is currently online. Furthermore, "online group user" can also refer to a valid group user within the target group. For example, if a group user has been online recently (e.g., at a preset interval), then that group user is considered a valid group user. Conversely, if a group user has been offline for an extended period, and the interval between their last online time and current time exceeds the offline criterion (e.g., a preset interval), then that group user is considered an invalid group user.
[0063] It should be noted that, for invalid group users, this application embodiment can delete the invalid group users from the target group, thereby adjusting the group users of the target group to update and iterate the target group to ensure that the target group contains valid group users.
[0064] In some implementations, to determine the number of valid group users contained in the target group, valid online group users can be identified based on the online records (such as long-connection information) of each group user in the target group, thereby calculating the number of online group users. Specifically, the step "obtaining the number of online group users contained in the target group" may include:
[0065] Obtain the list of group users corresponding to the target group, and find the update time of the long connection information for each group user in the list; based on the update time of each long connection information, determine the current online interval of each group user; identify group users whose online interval is less than a preset time threshold as online group users, and obtain the number of online group users in the target group.
[0066] The group user list can be a list containing information about group users since the target group was created, such as including information about group users who joined the target group before the current time. Alternatively, the group user list can only include information about group users who have been online within a historical period; for example, it can only include information about group users who have had online records within the past month. The number of group user information entries included in the group user list reflects the total number of group users in the target group.
[0067] The long-connection information can be the connection information established when a user is online and establishes a connection with the backend, reflecting the user's online status. This information may include the user's latest online time, such as the time of their last online session or their current online time. Furthermore, it may include the access machine address (IP) information that the user (client) is connected to while online, such as the access machine address (IP) information that a group user connects to when entering a target group, so that subsequent broadcast messages can be sent to the group user corresponding to that long-connection information via the access machine corresponding to that access machine address.
[0068] The update time of this long-connection information is the validity period update time of the long-connection information. It should be noted that when group users in the target group are online, the validity period or time corresponding to this long-connection information will be updated in real time, such as every 0.01 seconds, 0.05 seconds, or 0.5 seconds, the long-connection information will be refreshed, for example, refreshing the latest online time of the corresponding group users. Thus, the refreshed long-connection information reflects the latest online time of the corresponding group users. It can be understood that the update time of the long-connection information is the refresh time, which is equal to or close to the latest online time of the group users.
[0069] The online interval duration refers to the time interval between the last online time of a group user and the current time. For example, if a group user is currently offline, and the last online time of this offline group user was 9:00 AM, meaning that the group user has been offline since 9:00 AM, and assuming the current time is 6:00 PM on the same day, then the online interval duration of this group user is 9 hours, or 540 minutes. The above is just an example, and the embodiments of this application do not limit this.
[0070] In this embodiment, to determine the number of online group users in the target group, effective group users online within a preset time period are used as examples to determine the number of effective group users, thereby obtaining the number of online group users in the target group. Specifically, the update time of the long connection information of each group user in the target group is obtained, and the online interval duration of the corresponding group user at the current time is determined by comparing the update time of the long connection information with the current time. Then, the online interval duration of each group user is compared with a preset time threshold (online interval duration threshold), such as setting the preset time threshold to 48 hours, 3 days, 5 days, etc., which is not limited here. Group users whose online interval duration is less than the preset time threshold are determined as online group users in the target group, thereby allowing the counting of the number of online group users.
[0071] Furthermore, to determine the backend server resources required by the target group when processing group message broadcasts, this embodiment of the application, after obtaining the number of online group users, can estimate the target backend server capacity required by the target group based on the number of online group users. This target capacity represents the current backend server resource requirements of the target group, such as the number of servers required. This allows for subsequent adjustments to the server resources used by the target group based on the target capacity, thereby ensuring that the target group achieves the expected efficiency when broadcasting / sending group messages.
[0072] Specifically, in this embodiment, the number of users that a single server (server-side) can handle when processing group messages can be pre-calculated. Based on this user capacity of a single server, a backend occupancy table corresponding to each group is established. For example, if a single server can handle 500 online group users, the target group's backend server occupancy is 1 unit when the number of online group users is 1-500, 2 units when the number is 500-1000, and so on. A mapping relationship between the number of online users in the target group and their backend server occupancy is established based on this data, and a backend occupancy table is generated based on this mapping. Furthermore, after obtaining the number of online group users in the target group, this embodiment can look up the backend occupancy table to determine the target occupancy capacity corresponding to the current number of online group users.
[0073] By using the above methods, the number of online group users in the target group can be obtained, which can determine the amount of backend server space required by the target group when processing group messages. This allows for adjustments to the backend server space used by the target group when the required space does not match the actual capacity occupied by the backend server.
[0074] 102. If the target occupied capacity is found to be greater than the current actual occupied capacity of the target group, the server occupied by the target group is expanded according to the target occupied capacity to obtain the expanded server cluster.
[0075] The actual occupied capacity can be the capacity or number of individual backend servers currently requested by the target group, such as requesting to occupy 1, 2 or more backend servers, depending on the actual situation.
[0076] This server cluster is a backend server composed of multiple distributed sub-servers. It supports the operation of a target group containing a large number of online users, handling tasks such as group message processing and information processing for online group users; specific requirements are not specified here. For example, if a single server is used as a sub-server, the server cluster can consist of multiple distributed servers.
[0077] It should be noted that when the number of online users in the target group is small, these users can be integrated into a single server, and the group messages can be processed by a single server, achieving the efficiency of broadcasting group messages. When the number of online users in the target group is large, the group messages can be processed by a server cluster containing multiple servers, improving the efficiency of broadcasting group messages. Therefore, this application embodiment can determine the target capacity based on the number of online users in the target group, and then adjust the resource usage of the target group on the backend server according to the target capacity, thereby improving the efficiency of group message processing and saving the target group's resource usage on the backend server.
[0078] To ensure that the backend server can process group messages in the current target group, such as broadcasting group messages among online group users with the current number of users, this application embodiment, after obtaining the target capacity occupied by the target group on the backend server, can identify the actual capacity currently occupied by the target group on the backend server, and compare the target capacity with the actual capacity to obtain the comparison result, so as to determine whether to adjust the target group, such as upgrading or downgrading the target group.
[0079] In this embodiment, the target group can be upgraded. This upgrade process includes two parts: first, expanding the server space occupied by the target group to obtain an expanded server cluster; second, distributing the online tagging information of online group users to the expanded server cluster. This achieves the upgrade of the target group, thereby increasing its user capacity.
[0080] Specifically, if the comparison result indicates that the target occupied capacity is greater than the actual occupied capacity, it is determined that the target group needs to be upgraded. This involves expanding the backend servers used by the target group, such as increasing the number of servers / servers used by the target group during runtime. For example, if the target occupied capacity is 5, but the actual occupied capacity is 2, the number of backend servers used by the target group during runtime will be expanded to 5, resulting in a server cluster used by the target group. This expanded server cluster contains multiple sub-servers corresponding to the target occupied capacity, so that the online tag information of online group users can be evenly stored across multiple sub-servers in the expanded server cluster, thus completing the upgrade of the target group.
[0081] In this embodiment, the target group can be downgraded. This downgrade process includes two parts: first, reducing or decreasing the target group's server load; second, merging and storing the online tagging information of all online group users into a single, adjusted server, or, if, after reducing the target group's server load, it still contains multiple sub-servers, then the online tagging information of all online group users is redistributed evenly across the multiple sub-servers. This achieves the upgrade of the target group, thereby reducing the number of users it can accommodate.
[0082] Specifically, when the target available capacity is less than the actual available capacity of the target group on the backend server, the number of servers currently occupied by the target group can be adjusted based on the target available capacity, such as reducing the amount of backend server space occupied by the target group during runtime. This adjustment process includes the following: if the target available capacity is found to be less than the actual available capacity of the target group, the number of sub-servers corresponding to the actual available capacity is determined; if multiple sub-servers are identified, an initial sub-server for the target group is selected from these multiple sub-servers; the long connection information of each online group user in the multiple sub-servers is obtained, and the long connection information of each online group user is merged and stored in the initial sub-server.
[0083] It should be noted that when the target occupied capacity is less than the actual occupied capacity, the number of sub-servers currently occupied by the target group is determined. When there are multiple occupied sub-servers, the sub-server allocated to the target group at its initial establishment, i.e., the initial sub-server, can be identified from these multiple sub-servers. Then, the long connection information of each online group user currently online in the target group is obtained, and the long connection information of each online group user from the multiple sub-servers is merged and stored in the initial sub-server.
[0084] Furthermore, when it is identified that the target occupied capacity is less than the actual occupied capacity, it is determined to downgrade the target group. The downgrade process of the target group may also include: determining the number corresponding to the target occupied capacity; if there are multiple numbers corresponding to the target occupied capacity, selecting multiple sub-servers corresponding to the target occupied capacity from the server cluster corresponding to the actual occupied capacity as the adjusted server cluster; then, obtaining the long connection information of online group users stored in each sub-server from the server cluster corresponding to the actual occupied capacity, and evenly distributing all the obtained long connection information to multiple sub-servers in the adjusted server cluster, thereby reducing the user capacity of the target group according to the actual number of online group users.
[0085] By using the above methods, after obtaining the target capacity occupied by the target group on the server, it can be determined whether to adjust the target group's usage of the background server based on the target capacity. If adjustment is needed, the background server occupied by the target group can be adjusted according to the target capacity to match the current usage demand, ensuring the broadcast efficiency of group messages of the target group, while controlling the amount of background server resources occupied by the target group.
[0086] 103. Obtain the long connection information corresponding to each online group user in the target group, and bind each long connection information with the group identifier of the target group to obtain the online tag information corresponding to each online group user.
[0087] The long-connection information indicates that a user is online. This information can be generated and updated by the backend access server to record the user's online status. Furthermore, this long-connection information is used to generate online tagging information for users in online groups, which is stored on the server occupied by the target group for subsequent message broadcasting.
[0088] The group identifier is the identifier corresponding to the target group, i.e., groupid. The corresponding target group can be found through this group identifier.
[0089] The online tagging information can be a marker indicating that a group user is online within a target group, signifying that the user is online after joining the target group. Specifically, this online tagging information is generated from the online group user's long-connection information and group identifier. That is, the group identifier of the online group user can be determined through the online tagging information, thereby identifying the target group the user has joined. Furthermore, this online tagging information can also determine the group user's online time, user information, and the access machine address accessed by the group user (or its client).
[0090] In order to upgrade the target group, this application embodiment expands the background server occupied by the target group and needs to generate online tag information corresponding to each online group user in the target group, so as to distribute the online tag information corresponding to each online group user evenly to multiple sub-servers in the expanded server cluster.
[0091] Specifically, the process of generating online tag information is as follows: Long-connection information for each online group user is obtained, and this information is bound to a group identifier. For example, a mapping relationship is established between long-connection information and group identifiers to obtain online tag information with this mapping relationship. This yields online tag information indicating that a group user is online after entering the target group. This online tag information is then stored in the corresponding sub-server, allowing the sub-server to identify online group users using this tag information.
[0092] Using the above methods, online tag information can be generated based on the long connection information and group identifier of online group users to indicate that the group user is online after entering the target group, so that the sub-service can identify the online group user who is online through the online tag information.
[0093] 104. Distribute the online tag information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage.
[0094] In this embodiment, after expanding the server space occupied by the target group, it is necessary to obtain the online tag information of each online group user in the target group and adjust the storage location of the online tag information of each online group user. For example, the online tag information of all online group users in the target group is evenly distributed to multiple sub-servers in the expanded server cluster, resulting in multiple sub-servers with updated storage. In this way, when the target group contains a large number of online group users, the online tag information of all online group users is evenly distributed to each sub-server in the server cluster, thereby completing the upgrade of the target group and expanding the user capacity of the target group.
[0095] 105. Upon receiving a group message from an online group user, the group message is sent to multiple sub-servers that have been updated, so that each sub-server broadcasts the group message to the online group users who have stored the online tag information.
[0096] In this embodiment, after upgrading the target group, upon receiving a group message from one or more online group users (clients) within the target group, the group identifier of the target group can be determined. Based on this group identifier, the sub-servers occupied by the target group are located, i.e., multiple sub-servers after the current storage update are searched, and the group message is sent to each of these updated sub-servers. This ensures that each updated sub-server receives the group message. Furthermore, each updated sub-server searches for the set of stored online tag information corresponding to the group identifier and sends the group message to the online group user corresponding to each online tag information in the set.
[0097] In some implementations, the step of "sending the group message to multiple sub-servers after storage update" may further include:
[0098] (1) In response to the target user’s request to join the target group, obtain the target user’s target long connection information;
[0099] (2) Determine the target sub-server occupied by the target group;
[0100] (3) Store the target long connection information to the target sub-server.
[0101] In this embodiment, since the target group can be upgraded or downgraded, it supports subsequent addition of target users to the target group, gradually expanding the number of users in the target group. The process of expanding the number of users in the target group is as follows: receiving a join request from a target user for the target group, and in response to the join request, obtaining the target user's target long connection information from the target access device connected to the target user, and determining the target sub-server occupied by the target group, so as to send the target long connection information to the target sub-server for storage. It should be noted that when the target group occupies multiple sub-servers, the target long connection information can be stored in only one of the sub-servers, such as selecting the target sub-server according to the storage order among the sub-servers to store the target long connection information.
[0102] In some implementations, the step "determining the target sub-server occupied by the target group" may include:
[0103] (2.1) Identify the group type of the target group;
[0104] (2.2) Determine the target hash key for the target user based on the group type;
[0105] (2.3) Select the target sub-server assigned to the target user when joining the target group based on the target hash key.
[0106] The group type can be the specification type of the target group, indicating its current specifications, such as the number of group users it can accommodate. Specifically, the group type is not limited to large groups and small groups; the target group type can be changed by upgrading or downgrading it. It should be noted that when the group type is a large group, the target group occupies a server cluster containing multiple sub-servers in the background; when the group type is a small group, the target group occupies a single sub-server cluster in the background.
[0107] The target sub-server can be a sub-server used by the target user to store relevant information (such as target long connection information or online tag information) when joining the target group, and the target sub-server can be a single target server.
[0108] Specifically, in order to determine the target sub-server in the background server occupied by the target group for storing the relevant information of the target user, the embodiments of this application can identify the group type of the target group and determine the relevant parameters for generating the target hash key of the target user according to the group type. Then, the target hash key is generated according to the relevant parameters. Subsequently, the target sub-server assigned to the target user when joining the target group is selected according to the target hash key, so that the relevant information of the target user can be stored in the target sub-server in the future.
[0109] Specifically, the parameters for generating the target hash key for the target user are determined based on the group type, and then the target hash key is generated based on these parameters, as detailed below:
[0110] In some implementations, when a target user sends a join request to a target group, the join request carries a group identifier and a user identifier corresponding to the target user. The step "Determine the target user's target hash key based on the group type" may include:
[0111] (2.2.a) If the group type is identified as a preset large group, then generate the target hash key of the target user based on the user identifier and the group identifier;
[0112] Then, based on the target hash key, the target sub-server assigned to the target user when joining the target group is selected, including: identifying the server cluster occupied by the target group; and selecting the target sub-server corresponding to the target user when joining the target group from the server cluster corresponding to the target group based on the target hash key.
[0113] In some implementations, the step "determine the target hash key for the target user based on the group type" may further include:
[0114] (2.2.b) If the group type is identified as a preset subgroup, then the target hash key of the target user is generated based on the group identifier.
[0115] It should be noted that, in the embodiments of this application, when selecting the target sub-server assigned to the target user when joining the target group based on the target hash key, the selection of the target sub-server can be based on hash (or hashing) consistency. No limitation is made here.
[0116] In this embodiment, the target group can be automatically upgraded and downgraded, enabling flexible adjustment of the number of users it can accommodate. Specifically, by determining the number of online users in the target group in real time, the target capacity of the backend server required by the target group is determined based on the number of users. Then, the target capacity is compared with the actual capacity currently occupied by the target group to determine whether to change the type of the target group, such as upgrading or downgrading, thereby adjusting the backend server space occupied by the target group. After adjusting the backend server space occupied by the target group, online tagging information for all currently online users in the target group is generated and distributed to the adjusted backend server for storage, thus completing the change to the target group and enabling it to support a very large number of online users.
[0117] Furthermore, upon receiving a group message from one or more online group users within the target group, the group message can be sent to the background server occupied by the target group (depending on the specific sub-server occupied). This allows the background server to forward the group message to the online group users corresponding to the online tag information. In this way, there is no need to store a large number of messages in the group locally, saving storage costs, and the group messages are pushed to online group users in real time, improving message broadcasting efficiency.
[0118] As can be seen from the above, the embodiments of this application can obtain the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users; if it is identified that the target capacity is greater than the current actual capacity occupied by the target group, the server occupied by the target group is expanded according to the target capacity, resulting in an expanded server cluster; the long connection information corresponding to each online group user in the target group is obtained, and each long connection information is bound to the group identifier of the target group, resulting in online tag information corresponding to each online group user; the online tag information corresponding to multiple online group users is distributed to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage; when a group message is received from an online group user, the group message is sent to the multiple sub-servers with updated storage, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0119] Therefore, this solution expands the server capacity based on the target group's required server space and stores the online tagging information of online group users in the expanded server cluster. This distributes the target group and online group users across various sub-servers, thereby expanding the target group's user capacity and enabling the target group to support a large number of users. Furthermore, received group messages can be broadcast in real time without storing them or requiring the receiving end to request them, saving system storage resources and improving message propagation efficiency.
[0120] Based on the method described in the above embodiments, the following examples will provide further detailed explanations.
[0121] This application takes message broadcasting as an example to further describe the message broadcasting method provided in this application.
[0122] Figure 3 This is a schematic flowchart of another step of the message broadcasting method provided in the embodiments of this application. Figure 4 This is a schematic diagram of the architecture of the message broadcasting system provided in the embodiments of this application. Figure 5 A timing flowchart illustrating the message broadcasting method provided in the application embodiment; Figure 6 This is a schematic diagram of the server cluster architecture provided in the embodiments of the application. For ease of understanding, this application embodiment combines... Figure 3-6 Describe it.
[0123] In this embodiment, the description will focus on a message broadcasting device, which can be integrated into a computer device such as a terminal and / or a server. For example, considering integration into a server, this server can refer to all backend servers, which may comprise multiple server clusters. These server clusters are not limited to access machines, user online servers, central control servers, group online servers, etc. When the processor on this server executes the program corresponding to the message broadcasting method, the specific flow of the message broadcasting method is as follows:
[0124] 201. The central control server responds to the target user's request to join the target group and obtains the target user's target long connection information.
[0125] The target long connection information indicates the target user's online status, which may include connection information when the target user establishes an information channel connection with the backend server, such as connection time, address information of the access machine with which the connection is established, online time, duration of continuous connection, and being in a continuous connection state.
[0126] The request to join the target group includes the user identifier of the target user and the group identifier of the target group.
[0127] 202. The central control server identifies the group type of the target group and determines the target hash key of the target user based on the group type.
[0128] The group type can be the specification type of the target group, indicating the current specifications of the target group, such as the number of group users it can accommodate. Specifically, the group type is not limited to large groups and small groups; the type of the target group can be changed by upgrading or downgrading the target group.
[0129] Specifically, when the target group's group type is a preset large group, a target hash key for the target user is generated based on the user identifier and the group identifier. Conversely, when the target group's group type is a preset small group, a target hash key for the target user is generated based on the group identifier.
[0130] 203. The central control server selects the target sub-server assigned to the target user when they join the target group based on the target hash key.
[0131] Specifically, when the target group's group type is a preset large group, the server cluster occupied by the target group can be identified, and the target sub-server corresponding to the target user when joining the target group can be selected from the server cluster corresponding to the target group based on the target hash key. Conversely, when the target group's group type is a preset small group, the target sub-server assigned to the target user when joining the target group is directly selected based on the target hash key.
[0132] For example, specific embodiments of this application may select a target sub-server based on hash (or hashing) consistency and the target hash key.
[0133] 204. The central control server generates online tag information based on the target long connection information and the group identifier of the target group, and sends the online tag information to the target sub-server to update the number of online group users in the target group.
[0134] The target sub-server is either the online server corresponding to the target group or a sub-server in the group's online server cluster.
[0135] For example, by binding the target long-connection information and the group identifier, a mapping relationship is established between the target long-connection information and the group identifier, thereby obtaining the target user's online tagging information. Then, this target user's online tagging information is sent to the target sub-server, i.e., the online server corresponding to the target group, so that the target sub-server stores the target user's online tagging information. This updates the online group user information list of the target group, thereby updating the number of online group users in the target group.
[0136] 205. The central control server obtains the number of online group users included in the target group and estimates the target capacity occupied by the target group on the server based on the number of online group users.
[0137] It should be noted that the online group user can be a valid group user who has been online recently. For example, if a group user has been online recently (e.g., at a preset interval), then the group user is determined to be a valid group user; conversely, if a group user has been offline for a long time, that is, if the online interval since the group user's last online time is longer than the online determination standard (e.g., a preset interval), then the group user is determined to be an invalid group user. It should also be noted that for invalid group users, this embodiment of the application can delete the invalid group user from the target group, thereby adjusting the group users of the target group to update and iterate the target group, ensuring that the target group contains valid group users.
[0138] In order to determine the number of valid group users in the target group, embodiments of this application can determine the valid online group users based on the online records of each group user in the target group (such as the update time of long connection information), and thus calculate the number of online group users.
[0139] This application embodiment can establish a background occupancy table corresponding to a group. Specifically, the number of users that a single backend server (server-side) can accommodate when processing group messages is pre-calculated. For example, taking a single server that can accommodate 500 online group users as an example, when the number of online group users is 1 to 500, the target group's occupancy on the backend server is 1; when the number of online group users is 500 to 1000, the target group's occupancy on the backend server is 2, and so on. Based on the above data, a mapping relationship between the number of online users of the target group and the occupancy on the backend server is established, and a background occupancy table is generated based on the data of this mapping relationship. Furthermore, after obtaining the number of online group users of the target group, this application embodiment can look up the background occupancy table to determine the target occupancy capacity corresponding to the current number of online group users.
[0140] 206. If the central control server detects that the target occupied capacity is greater than the current actual occupied capacity of the target group, it expands the server occupied by the target group according to the target occupied capacity, thus obtaining an expanded server cluster.
[0141] The server used by the target group is the online server corresponding to the target group, while the expanded server cluster contains multiple sub-servers corresponding to the target group.
[0142] The actual occupied capacity refers to the number of backend server instances currently requested by the target group, which can be 1, 2 or more, depending on the actual situation.
[0143] Specifically, in this embodiment, after obtaining the target capacity occupied by the target group on the backend server, the actual capacity currently occupied by the target group on the backend server can be identified, and the target capacity is compared with the actual capacity. When it is identified that the target capacity is greater than the actual capacity currently occupied by the target group, it indicates that the server occupied by the target group cannot support the group messages of the current number of online group users, and the target group needs to be upgraded.
[0144] The upgrade process can include two parts: first, expanding the server space used by the target group to obtain an expanded server cluster; second, distributing the online tagging information of online group users to the expanded server cluster. This achieves the upgrade of the target group, thereby increasing its user capacity.
[0145] 207. The central control server obtains the long connection information corresponding to each online group user in the target group, and generates online tag information corresponding to each online group user based on each long connection information and the group identifier.
[0146] In order to upgrade the target group, this application embodiment expands the background server occupied by the target group and needs to generate online tag information corresponding to each online group user in the target group, so as to distribute the online tag information corresponding to each online group user evenly to multiple sub-servers in the expanded server cluster.
[0147] The online tagging information can be a marker indicating that a group user is online within a target group, signifying that the user is online after joining the target group. Specifically, this online tagging information is generated from the online group user's long-connection information and group identifier. That is, the group identifier of the online group user can be determined through the online tagging information, thereby identifying the target group the user has joined. Furthermore, this online tagging information can also determine the group user's online time, user information, and the access machine address accessed by the group user (or its client).
[0148] Specifically, the process of generating online tag information on the central control server is as follows: The long connection information of each online group user is obtained, and this information is bound to a group identifier. For example, a mapping relationship is established between the long connection information and the group identifier to obtain online tag information with this mapping relationship. This yields online tag information indicating that a group user is online after entering the target group. This online tag information is then stored on the corresponding sub-server, allowing the sub-server to identify online group users using this online tag information.
[0149] 208. The central control server distributes the online tagging information corresponding to all online group users to multiple sub-servers in the server cluster.
[0150] To upgrade the target group and enable it to accommodate a large number of online group users, this embodiment of the application, after generating online tag information for each online group user, evenly distributes the online tag information of all online group users to multiple sub-servers in the expanded server cluster, so that each sub-server in the expanded server cluster stores the allocated online tag information.
[0151] 209. Each sub-server stores the assigned online tag information, resulting in multiple sub-servers with updated storage.
[0152] Specifically, after receiving the online tagging information for each online group user assigned by the central control server, each sub-server needs to store the online tagging information to update the storage of multiple sub-servers. In this way, when the target group contains a large number of online group users, the online tagging information of all online group users is evenly distributed across the sub-servers in the server cluster, thereby upgrading the target group and expanding its user capacity.
[0153] 210. The central control server receives group messages sent by online group users and broadcasts the group messages to online group users who have stored online tag information.
[0154] Specifically, after upgrading the target group, when the central control server receives a group message from one or more online group users (clients) within the target group, it can determine the group identifier of the target group. Based on this group identifier, it searches for the sub-servers occupied by the target group, that is, it searches for multiple sub-servers after the current storage update, and sends the group message to each of these updated sub-servers. This ensures that each updated sub-server receives the group message. Furthermore, each updated sub-server searches for the set of stored online tag information corresponding to the group identifier, determines the long connection information of each online group user in the set, and then determines the access machine connected to the online group user based on the long connection information. The server then sends the group information to the access machine, which broadcasts the group information to the corresponding online group users.
[0155] Furthermore, this embodiment also includes downgrading the target group. This downgrading process can include two parts: first, reducing or decreasing the target group's server load; second, merging and storing the online tagging information of all online group users into a single, adjusted server. Alternatively, if, after reducing the target group's server load, it still contains multiple sub-servers, then the online tagging information of all online group users is redistributed evenly across the multiple sub-servers. This achieves an upgrade of the target group to reduce the number of users it can accommodate.
[0156] It should be noted that when the target occupied capacity is less than the actual occupied capacity, the number of sub-servers currently occupied by the target group is determined. When there are multiple sub-servers occupied, the sub-server allocated to the target group when it was initially established can be determined from the multiple sub-servers, i.e., the initial sub-server. In this way, the long connection information of each online group user currently online in the target group can be obtained, and the long connection information of each online group user in the multiple sub-servers can be merged and stored in the initial sub-server.
[0157] Furthermore, regarding the implementation of broadcasting group messages for the downgraded target group, please refer to steps 201-211 above. The principle or implementation is the same or similar, and will not be repeated here.
[0158] To facilitate understanding of the embodiments of this application, in conjunction with Figure 4 , Figure 5 and Figure 6 The embodiments of this application will be described with specific application examples. Specifically, the application scenario of this example is a group message broadcasting system in a game community, which covers a large number of game-related groups (including a large number of small groups, some large groups, and super large groups) with text, audio, and other chat messages.
[0159] like Figure 4 The diagram shows the architecture of the message broadcasting system. Specifically, the broadcasting system includes: a remote dictionary server (Redis), a storage service server (cache server), a central control server, a logic server, a group online server, a user online server (user server), a gateway server, an access server, and group user terminals (terminals / APPs / mini-programs / web / PCs, etc.). The above system architecture specifically implements the following scenarios: (1) The group user terminal sends a heartbeat to the access server to establish a long connection between the group user terminal and the access server; (2) The group user terminal sends a short connection service to the gateway server so that the gateway server can request instructions from the logic server regarding joining the group, leaving the group, and message uplink; (3) The logic server uplinks the joining and leaving messages to the central control server; (4) The central control server reports the group information (joining the group, leaving the group, message uplink, etc.) to the storage service server (cache server). (5) The central control server responds to the group entry message and requests the group online server through consistent hashing to store the relevant information of the group entry user; (6) The group online server reports the number of group online users; (7) The central control server transmits the group message sent by the group user terminal to the group online server; (8) When the group online server receives the group information sent by the central control server, it broadcasts the group message to the access machine server; (9) The access machine sends the group information to other receiving users of the group.
[0160] For details, see Figure 4 , Figure 5 and Figure 6 The specific application scenarios for this application example are as follows:
[0161] 1. Users establish dual-channel long-lived connections with the access machine via TCP / WebSocket, maintain online status based on heartbeats, and save a copy of the user's long-lived connection information to the user's online server. Specifically, group users periodically send heartbeats to the server. If a heartbeat is sent to the user's online server via the access machine, it indicates that the user is online. If a group user does not send a heartbeat for an extended period (e.g., no heartbeat for 3.5 heartbeat cycles), it is considered a heartbeat timeout, the user is offline, and the user's online server will clear the user's information. With this channel, the backend server (group online server) can broadcast messages to all online users with established long-lived connections in the group in real time. This eliminates the need for local message storage, saving on storage cluster costs and message processing architecture complexity, and conserving server-side storage resources.
[0162] 2. When a user enters a group, the data is consistently hashed (or hashed) by the central control server to one of the servers in the group's online service cluster. Specifically, when the target group is a large group, a consistent hash is performed using the group identifier (groupid) and user identifier (userid) as the target hash key, and the target group and its corresponding users are distributed across the servers in the cluster. Furthermore, when the target group is a small group, a consistent hash is performed using the group identifier (groupid) as the target hash key, and the target group and its corresponding users are integrated into a single server in the cluster. The process of storing the target group and its corresponding users on the server involves saving the user's long-connection information and the corresponding group identifier in the group's online server.
[0163] Third, the central control server can automatically adjust the size of the target group based on the number of online users, thereby changing the type of the target group. For example, when the target group is a small group, all online users of the small group are integrated into a single server; when the target group is a large group, online users of the large group are distributed across corresponding servers. It should be noted that group upgrades or downgrades can be determined by heartbeats between the user client and the backend service to ascertain the online status, thereby determining the number of online users and deciding whether to upgrade or downgrade the group based on the number of online users.
[0164] Fourth, when a group message is sent to the target group, the group information is sent to the server where the target group is located by querying the server where the target group is located; then, the server where the target group is located iterates through the current online users of the target group and sends the group message to all online users.
[0165] Compared to existing technologies, this application example does not require storing user messages. When there are group messages, the server broadcasts them to all users in the corresponding group in real time, saving costs and simplifying the backend design. It supports very large groups, which are distributed across multiple machines, reducing the load on individual machines and making the broadcasting of large groups more efficient. When scaling up or down, the correspondence between users and groups is rebuilt in the new group service through heartbeats, without affecting the broadcasting of group messages.
[0166] As can be seen from the above, the embodiments of this application can obtain the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users; if it is identified that the target capacity is greater than the current actual capacity occupied by the target group, the server occupied by the target group is expanded according to the target capacity, resulting in an expanded server cluster; the long connection information corresponding to each online group user in the target group is obtained, and each long connection information is bound to the group identifier of the target group, resulting in online tag information corresponding to each online group user; the online tag information corresponding to multiple online group users is distributed to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage; when a group message is received from an online group user, the group message is sent to the multiple sub-servers with updated storage, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0167] Therefore, this solution expands the server capacity based on the target group's required server space and stores the online tagging information of online group users in the expanded server cluster. This distributes the target group and online group users across various sub-servers, thereby expanding the target group's user capacity and enabling the target group to support a large number of users. Furthermore, received group messages can be broadcast in real time without storing them or requiring the receiving end to request them, saving system storage resources and improving message propagation efficiency.
[0168] To better implement the above methods, this application also provides a message broadcasting device that can integrate a server.
[0169] For example, such as Figure 7 As shown, the message broadcasting device may include a first acquisition unit 401, an expansion unit 402, a second acquisition unit 403, an allocation unit 404, and a sending unit 405.
[0170] The first acquisition unit 401 is used to acquire the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users.
[0171] The expansion unit 402 is used to expand the server occupied by the target group according to the target occupied capacity if it is found that the target occupied capacity is greater than the current actual occupied capacity of the target group, so as to obtain the expanded server cluster.
[0172] The second acquisition unit 403 is used to acquire the long connection information corresponding to each online group user in the target group, and bind each long connection information and the group identifier of the target group to obtain the online tag information corresponding to each online group user.
[0173] The allocation unit 404 is used to allocate online tag information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the allocated online tag information, resulting in multiple sub-servers with updated storage.
[0174] The sending unit 405 is used to send the group message to multiple sub-servers after storing the updated group message when it receives a group message sent by an online group user, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information.
[0175] In some embodiments, the message broadcasting device further includes a storage unit for:
[0176] In response to a request from a target user to join a target group, obtain the target user's target long connection information; determine the target sub-server occupied by the target group; and store the target long connection information in the target sub-server.
[0177] In some embodiments, the storage unit is further configured to:
[0178] Identify the group type of the target group; determine the target hash key of the target user based on the group type; select the target sub-server assigned to the target user when joining the target group based on the target hash key.
[0179] In some embodiments, the storage unit is further configured to:
[0180] If the group type is identified as a preset large group, then the target hash key of the target user is generated based on the user identifier and the group identifier; the server cluster occupied by the target group is identified; and the target sub-server corresponding to the target user when joining the target group is selected from the server cluster corresponding to the target group based on the target hash key.
[0181] In some implementations, the storage unit is also used for:
[0182] If the group type is identified as a preset small group, the target hash key for the target user is generated based on the group identifier.
[0183] In some implementations, the message broadcasting device further includes a merging unit, which is also used for:
[0184] If the target occupied capacity is found to be less than the current actual occupied capacity of the target group, then the number of sub-servers corresponding to the actual occupied capacity is determined; if multiple sub-servers are found, then the initial sub-server occupied by the target group is selected from the multiple sub-servers; the long connection information of each online group user in the multiple sub-servers is obtained, and the long connection information of each online group user is merged and stored in the initial sub-server.
[0185] In some implementations, the first acquisition unit 401 is specifically used for:
[0186] Obtain the list of group users corresponding to the target group, and find the update time of the long connection information for each group user in the list; based on the update time of each long connection information, determine the current online interval of each group user; identify group users whose online interval is less than a preset time threshold as online group users, and obtain the number of online group users in the target group.
[0187] As can be seen from the above, in this embodiment of the application, the first acquisition unit 401 can acquire the number of online group users included in the target group, and estimate the target capacity occupied by the target group on the server based on the number of online group users; the expansion unit 402 is used to expand the server occupied by the target group according to the target capacity if it is identified that the target capacity is greater than the current actual capacity occupied by the target group, so as to obtain the expanded server cluster; the second acquisition unit 403 can acquire the long connection information corresponding to each online group user in the target group, and bind each long connection information and the group identifier of the target group to obtain the online tag information corresponding to each online group user; the allocation unit 404 can allocate the online tag information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the allocated online tag information, so as to obtain multiple sub-servers with updated storage; the sending unit 405 can send the group message to the multiple sub-servers with updated storage when it receives the group message sent by the online group user, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information. Therefore, this solution expands the server capacity based on the target group's required server space and stores the online tagging information of online group users in the expanded server cluster. This distributes the target group and online group users across various sub-servers, thereby expanding the target group's user capacity and enabling the target group to support a large number of users. Furthermore, received group messages can be broadcast in real time without storing them or requiring the receiving end to request them, saving system storage resources and improving message propagation efficiency.
[0188] This application also provides a computer device, such as... Figure 8As shown, it illustrates a structural schematic diagram of the computer device involved in the embodiments of this application, specifically:
[0189] The computer device may include components such as a processor 501 with one or more processing cores, a memory 502 with one or more computer-readable storage media, a power supply 503, and an input unit 504. Those skilled in the art will understand that... Figure 8 The computer device structure shown does not constitute a limitation on the computer device and may include more or fewer components than shown, or combine certain components, or have different component arrangements. Wherein:
[0190] The processor 501 is the control center of the computer device, connecting various parts of the computer device through various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 502, and by calling data stored in the memory 502. Optionally, the processor 501 may include one or more processing cores; preferably, the processor 501 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 501.
[0191] The memory 502 can be used to store software programs and modules. The processor 501 executes various functional applications and broadcasts messages by running the software programs and modules stored in the memory 502. The memory 502 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, application programs required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 502 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory 502 may also include a memory controller to provide the processor 501 with access to the memory 502.
[0192] The computer equipment also includes a power supply 503 that supplies power to the various components. Preferably, the power supply 503 can be logically connected to the processor 501 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system. The power supply 503 may also include one or more DC or AC power supplies, recharging systems, power fault detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0193] The computer device may also include an input unit 504, which can be used to receive input digital or character information and generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0194] Although not shown, the computer device may also include a display unit, etc., which will not be described in detail here. Specifically, in the embodiments of this application, the processor 501 in the computer device loads the executable files corresponding to the processes of one or more application programs into the memory 502 according to the following instructions, and the processor 501 runs the application programs stored in the memory 502 to realize various functions, as follows:
[0195] The system retrieves the number of online group users within the target group and estimates the target server capacity required by the target group based on this number. If the target capacity is found to be greater than the current actual capacity of the target group, the server capacity allocated to the target group is expanded accordingly, resulting in an expanded server cluster. The system also retrieves the long-connection information for each online group user within the target group and binds each long-connection information to the group identifier of the target group, obtaining online tag information for each online group user. This online tag information is then distributed among multiple sub-servers within the server cluster, with each sub-server storing the allocated online tag information, resulting in updated sub-servers. Upon receiving a group message from an online group user, the group message is sent to the updated sub-servers, allowing each sub-server to broadcast the group message to the online group user who has stored the online tag information.
[0196] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0197] Therefore, this solution can obtain the number of online group users included in the target group and estimate the target capacity occupied by the target group on the server based on the number of online group users. If the target capacity is found to be greater than the current actual capacity occupied by the target group, the server occupied by the target group is expanded according to the target capacity, resulting in an expanded server cluster. The solution obtains the long connection information corresponding to each online group user in the target group and binds each long connection information with the group identifier of the target group to obtain the online tag information corresponding to each online group user. The solution distributes the online tag information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online tag information, resulting in multiple sub-servers with updated storage. When a group message is received from an online group user, the group message is sent to the multiple sub-servers with updated storage, so that each sub-server broadcasts the group message to the online group user who has stored the online tag information. Therefore, this solution expands the server capacity based on the target group's required server space and stores the online tagging information of online group users in the expanded server cluster. This distributes the target group and online group users across various sub-servers, thereby expanding the target group's user capacity and enabling the target group to support a large number of users. Furthermore, received group messages can be broadcast in real time without storing them or requiring the receiving end to request them, saving system storage resources and improving message propagation efficiency.
[0198] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be performed by instructions, or by instructions controlling related hardware. These instructions can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0199] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions that can be loaded by a processor to execute steps in any of the message broadcasting methods provided in embodiments of this application. For example, the instructions can execute the following steps:
[0200] The system retrieves the number of online group users within the target group and estimates the target server capacity required by the target group based on this number. If the target capacity is found to be greater than the current actual capacity of the target group, the server capacity allocated to the target group is expanded accordingly, resulting in an expanded server cluster. The system also retrieves the long-connection information for each online group user within the target group and binds each long-connection information to the group identifier of the target group, obtaining online tag information for each online group user. This online tag information is then distributed among multiple sub-servers within the server cluster, with each sub-server storing the allocated online tag information, resulting in updated sub-servers. Upon receiving a group message from an online group user, the group message is sent to the updated sub-servers, allowing each sub-server to broadcast the group message to the online group user who has stored the online tag information.
[0201] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0202] The computer-readable storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0203] Since the instructions stored in the computer-readable storage medium can execute the steps of any of the message broadcasting methods provided in the embodiments of this application, the beneficial effects that any of the message broadcasting methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0204] The foregoing has provided a detailed description of a message broadcasting method, apparatus, device, storage medium, and computer program product provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A message broadcasting method, characterized by, It includes: Obtain the number of users of the online group users included in the target group, and estimate the target occupancy capacity of the target group for the server based on the number of users of the online group users; If it is recognized that the target occupancy capacity is greater than the current actual occupancy capacity of the target group, expand the server occupied by the target group according to the target occupancy capacity to obtain an expanded server cluster; Obtain the long connection information corresponding to each online group user in the target group, and bind each long connection information and the group identifier of the target group to obtain the online marking information corresponding to each online group user, where the online marking information is used for the sub-server in the server cluster to identify the online group users in the online state; Distribute the online marking information corresponding to multiple online group users to multiple sub-servers in the server cluster, so that each sub-server stores the allocated online marking information to obtain multiple sub-servers after storage update; When receiving a group message sent by the online group user, send the group message to the multiple sub-servers after storage update, so that each sub-server broadcasts the group message to the online group users who have stored the online marking information according to the stored online marking information.
2. The method of claim 1, wherein, Before sending the group message to the multiple sub-servers after storage update, it further includes: In response to a request from a target user to join a target group, obtain the target long connection information of the target user; Determine the target sub-server occupied by the target group; Store the target long connection information in the target sub-server.
3. The method according to claim 2, wherein The determining the target sub-server occupied by the target group includes: Identify the group type of the target group; Based on the group type, determine the target hash key of the target user; Select the target sub-server assigned to the target user when joining the target group according to the target hash key.
4. The method according to claim 3, wherein The request to join the target group carries a group identifier and the user identifier corresponding to the target user. Based on the group type, determining the target hash key of the target user includes: If it is recognized that the group type is a preset large group, generate the target hash key of the target user according to the user identifier and the group identifier; Then the selecting the target sub-server assigned to the target user when joining the target group according to the target hash key includes: Identify the server cluster occupied by the target group; Based on the target hash key, select the target sub-server corresponding to the target user when joining the target group from the server cluster corresponding to the target group.
5. The method according to claim 4, characterized in that, It further includes: If it is recognized that the group type is a preset small group, generate the target hash key of the target user according to the group identifier.
6. The method according to claim 1, wherein It further includes: If it is recognized that the target occupancy capacity is less than the current actual occupancy capacity of the target group, determine the number of sub-servers corresponding to the actual occupancy capacity; If it is recognized that the number of sub-servers is multiple, select the initial sub-server occupied by the target group from the multiple sub-servers; Obtain the long connection information of each online group user in multiple said sub-servers, and merge and store the long connection information of each online group user in the initial sub-server.
7. The method according to claim 1, wherein The obtaining of the number of online group users included in the target group includes: Obtain the group user list corresponding to the target group, and find the update time of the long connection information corresponding to each group user in the group user list; Based on the update time of each long connection information, determine the current online interval duration of each group user; Determine the group users with an online interval duration less than the preset duration threshold as online group users, and obtain the number of online group users in the target group.
8. A message broadcasting device, characterized in that It includes: A first obtaining unit, configured to obtain the number of online group users included in the target group, and estimate the target occupancy capacity of the target group for the server based on the number of online group users; An expansion unit, configured to, if it is recognized that the target occupancy capacity is greater than the current actual occupancy capacity of the target group, expand the server occupied by the target group according to the target occupancy capacity to obtain an expanded server cluster; A second obtaining unit, configured to obtain the long connection information corresponding to each online group user in the target group, and bind each long connection information and the group identifier of the target group to obtain the online marking information corresponding to each online group user, where the online marking information is used for the sub-servers in the server cluster to identify the online group users in the online state; A distribution unit, configured to distribute the online marking information corresponding to multiple said online group users to multiple sub-servers in the server cluster, so that each sub-server stores the distributed online marking information to obtain multiple sub-servers after storage update; A sending unit, configured to, when receiving a group message sent by the online group user, send the group message to the multiple sub-servers after storage update, so that each sub-server broadcasts the group message to the online group users that have stored the online marking information according to the stored online marking information.
9. A computer device, characterized in that, It includes a processor and a memory, the memory stores a computer program, and the processor is configured to run the computer program in the memory to implement the steps in the message broadcasting method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores multiple instructions, and the instructions are suitable for being loaded by a processor to execute the steps in the message broadcasting method according to any one of claims 1 to 7.
11. A computer program product, characterized in that, It includes computer instructions, and when the computer instructions are executed, the steps in any one of the message broadcasting methods according to claims 1 to 7 are implemented.