CN108418743B - Chat room message distribution method and device and electronic equipment - Google Patents

Chat room message distribution method and device and electronic equipment Download PDF

Info

Publication number
CN108418743B
CN108418743B CN201810039033.5A CN201810039033A CN108418743B CN 108418743 B CN108418743 B CN 108418743B CN 201810039033 A CN201810039033 A CN 201810039033A CN 108418743 B CN108418743 B CN 108418743B
Authority
CN
China
Prior art keywords
preset
chat
identification information
chat room
message
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201810039033.5A
Other languages
Chinese (zh)
Other versions
CN108418743A (en
Inventor
石鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing QIYI Century Science and Technology Co Ltd
Original Assignee
Beijing QIYI Century Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing QIYI Century Science and Technology Co Ltd filed Critical Beijing QIYI Century Science and Technology Co Ltd
Priority to CN201810039033.5A priority Critical patent/CN108418743B/en
Publication of CN108418743A publication Critical patent/CN108418743A/en
Application granted granted Critical
Publication of CN108418743B publication Critical patent/CN108418743B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/21Monitoring or handling of messages
    • H04L51/214Monitoring or handling of messages using selective forwarding
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/02Details
    • H04L12/16Arrangements for providing special services to substations
    • H04L12/18Arrangements for providing special services to substations for broadcast or conference, e.g. multicast
    • H04L12/1813Arrangements for providing special services to substations for broadcast or conference, e.g. multicast for computer conferences, e.g. chat rooms
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/16Threshold monitoring
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L51/00User-to-user messaging in packet-switching networks, transmitted according to store-and-forward or real-time protocols, e.g. e-mail
    • H04L51/06Message adaptation to terminal or network requirements
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1008Server selection for load balancing based on parameters of servers, e.g. available memory or workload
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1001Protocols in which an application is distributed across nodes in the network for accessing one among a plurality of replicated servers
    • H04L67/1004Server selection for load balancing
    • H04L67/1017Server selection for load balancing based on a round robin mechanism

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Multimedia (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

The embodiment of the invention provides a chat room message distribution method, a chat room message distribution device and electronic equipment, wherein the method comprises the following steps: determining the message concurrency amount of the received chat messages, and storing the received chat messages in a preset hash table when the message concurrency amount is larger than or equal to a preset concurrency amount threshold value; in a preset hash table, identifying chat messages meeting preset conditions, and storing chat room identification information corresponding to the identified chat messages meeting the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The method and the system can ensure the normal operation of the server under the condition that the concurrency of the chat messages is increased suddenly, and can reduce the delay of the server in sending the chat room messages.

Description

Chat room message distribution method and device and electronic equipment
Technical Field
The invention relates to the technical field of instant messaging, in particular to a chat room message distribution method, a chat room message distribution device and electronic equipment.
Background
With the rapid development of the internet, instant messaging has become an indispensable communication means in people's life, and has been widely used in leisure, entertainment and work at ordinary times. Chat rooms are favored as a new instant messaging approach. For a live chat room in an internet environment, each time a user sends a message, the message is first transmitted to a server and then distributed to each of the other users in the chat room via the server.
However, the inventor finds that the prior art has at least the following problems in the process of implementing the invention:
when the number of users in the live chat room is large and the users are concentrated in the live time period with high popularity, the message concurrence amount is easy to increase when the message is sent in the live chat room. When the concurrency of the messages sent in the live chat room is larger than the exit bandwidth of the server, the messages in the chat room are difficult to send out, so that the delay of the messages in the chat room is increased, and the experience of a user in the chat room is reduced.
Disclosure of Invention
The embodiment of the invention aims to provide a chat room message distribution method, a chat room message distribution device and electronic equipment, so as to ensure that a server can normally operate under the condition that the concurrent volume of chat messages is increased suddenly. The specific technical scheme is as follows:
in one aspect of the present invention, an embodiment of the present invention provides a chat room message distribution method, applied to a server, where the method includes:
determining the message concurrency of the received chat messages, and judging whether the message concurrency is greater than or equal to a preset concurrency threshold;
when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table;
recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed;
polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
Optionally, after determining whether the message concurrency is greater than or equal to the preset concurrency threshold, the method for distributing messages in a chat room according to the embodiment of the present invention further includes:
and when the message concurrency is smaller than a preset concurrency threshold, sending the received chat message to the corresponding user terminal.
Optionally, storing the received chat message in a preset hash table, including:
and aiming at each chat message, storing the chat message in a preset hash table by taking the chat room identification information to which the chat message belongs as a key word and the chat message as a key value corresponding to the key word.
Optionally, after storing the received chat message in a preset hash table, the chat room message distribution method according to the embodiment of the present invention further includes:
and identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
Optionally, the preset conditions are: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to the threshold value of the number of the messages in the preset chat room;
or the message pushing waiting time of any chat room is less than or equal to the preset waiting time threshold.
Optionally, storing, in a preset queue to be pushed, chat room identification information corresponding to the identified chat message meeting the preset condition, including:
the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction to obtain the mould-extracted chat room identification information;
and storing the obtained chat room identification information in a preset queue to be pushed.
Optionally, polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals, including:
polling the identification information of each chat room in a preset queue to be pushed according to a preset polling period and a preset parallelism;
and obtaining the chat messages corresponding to the identification information of each chat room from the preset hash table, and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
Optionally, sending the obtained chat message to the corresponding user terminal includes:
and serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
Optionally, before polling a preset queue to be pushed according to a preset polling period, the chat room message method according to the embodiment of the present invention further includes:
monitoring the load of the server in real time, and judging whether the load of the server is smaller than a preset load threshold value or not; wherein the load of the server comprises at least one of: the utilization rate of a processor, the memory occupancy rate and the bandwidth occupancy rate;
correspondingly, according to a preset polling cycle, polling a preset queue to be pushed, and according to chat room identification information in the preset queue to be pushed, obtaining chat messages corresponding to the chat room identification information from a preset hash table, and sending the obtained chat messages to corresponding user terminals, including:
when the load of the server is smaller than a preset load threshold value, polling a preset queue to be pushed according to a first preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals;
when the load of the server is greater than or equal to a preset load threshold value, polling a preset queue to be pushed according to a second preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
Optionally, after sending the obtained chat message to the corresponding user terminal, the method for distributing chat room messages according to the embodiment of the present invention further includes:
clearing the chat room identification information to be cleared stored in a preset queue to be pushed; the chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
In another aspect of the present invention, there is also provided a chat room message distribution apparatus applied to a server, including:
the judging module is used for determining the message concurrency amount of the received chat messages and judging whether the message concurrency amount is larger than or equal to a preset concurrency amount threshold value or not;
the storage module is used for storing the received chat messages in a preset hash table when the message concurrency is greater than or equal to a preset concurrency threshold;
the identification module is used for identifying the chat messages which are stored in the preset hash table and meet the preset conditions, and storing the chat room identification information corresponding to the identified chat messages which meet the preset conditions in a preset queue to be pushed;
and the polling sending module is used for polling the preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from the preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to the corresponding user terminals.
Optionally, an apparatus for distributing chat room messages in an embodiment of the present invention further includes:
and the first sending module is used for sending the received chat message to the corresponding user terminal when the message concurrency is smaller than a preset concurrency threshold.
Optionally, the storage module is specifically configured to:
and aiming at each chat message, storing the chat message in a preset hash table by taking the chat room identification information to which the chat message belongs as a key word and the chat message as a key value corresponding to the key word.
Optionally, an apparatus for distributing chat room messages in an embodiment of the present invention further includes:
and the second sending module is used for identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
Optionally, the preset conditions are: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to the threshold value of the number of the messages in the preset chat room;
or the message pushing waiting time of any chat room is less than or equal to the preset waiting time threshold.
Optionally, the identification module is specifically configured to:
the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction to obtain the mould-extracted chat room identification information; and storing the obtained chat room identification information in a preset queue to be pushed.
Optionally, the polling transmission module includes:
the polling submodule is used for polling the identification information of each chat room in the preset queue to be pushed according to the preset polling period and the preset parallelism;
and the sending submodule is used for acquiring the chat messages corresponding to the identification information of each chat room from the preset hash table and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
Optionally, the polling sending module is specifically configured to:
and serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
Optionally, an apparatus for distributing chat room messages in an embodiment of the present invention further includes:
the load monitoring module is used for monitoring the load of the server in real time and judging whether the load of the server is smaller than a preset load threshold value or not; wherein the load of the server comprises at least one of: the utilization rate of a processor, the memory occupancy rate and the bandwidth occupancy rate;
correspondingly, the polling sending module is specifically configured to:
when the load of the server is smaller than a preset load threshold value, polling a preset queue to be pushed according to a first preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals;
when the load of the server is greater than or equal to a preset load threshold value, polling a preset queue to be pushed according to a second preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
Optionally, an apparatus for distributing chat room messages in an embodiment of the present invention further includes:
the clearing module is used for clearing the chat room identification information to be cleared stored in the preset queue to be pushed after the polling sending module sends the obtained chat message to the corresponding user terminal; the chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
In another aspect of the present invention, there is also provided an electronic device, including a processor, a communication interface, a memory and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and a processor for implementing any one of the above chat room message distribution methods when executing the program stored in the memory.
In yet another aspect of the present invention, there is also provided a computer-readable storage medium having stored therein instructions which, when run on a computer, cause the computer to perform any one of the chat room message distribution methods described above.
In yet another aspect of the present invention, there is also provided a computer program product including instructions which, when run on a computer, cause the computer to perform any one of the chat room message distribution methods described above.
The embodiment of the invention provides a chat room message distribution method, a chat room message distribution device and electronic equipment, wherein the message concurrency of received chat messages is determined, and whether the message concurrency is greater than or equal to a preset concurrency threshold value is judged; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced. Of course, it is not necessary for any product or method of practicing the invention to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below.
Fig. 1 is a schematic structural diagram of a chat system to which a chat room message distribution method according to an embodiment of the present invention is applied;
fig. 2 is a flow chart of a first implementation of a chat room message distribution method according to an embodiment of the present invention;
fig. 3 is a flow chart of a second implementation of a chat room message distribution method according to an embodiment of the present invention;
fig. 4 is a flow chart of a third implementation of a chat room message distribution method according to an embodiment of the present invention;
fig. 5 is a flow chart of a fourth implementation manner of a chat room message distribution method according to an embodiment of the present invention;
fig. 6 is a flowchart of a fifth implementation manner of a chat room message distribution method according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a preset queue to be pushed in a chat room message distribution method according to an embodiment of the present invention;
fig. 8 is a flowchart of a sixth implementation manner of a chat room message distribution method according to an embodiment of the present invention;
fig. 9 is a flowchart of a seventh implementation manner of a chat room message distribution method according to an embodiment of the present invention;
fig. 10 is a flowchart of an eighth implementation manner of a chat room message distribution method according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a chat room message distribution apparatus according to an embodiment of the present invention;
fig. 12 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be described below with reference to the drawings in the embodiments of the present invention.
In order to solve the problems in the prior art, embodiments of the present invention provide a method, an apparatus, and an electronic device for distributing a chat message, so as to ensure that a server can operate normally when a concurrency amount of the chat message increases suddenly.
First, a chat room message distribution method according to an embodiment of the present invention may be applied to a server, where the server may establish network connection with a plurality of user terminals, for example, as shown in fig. 1, which is a schematic structural diagram of a chat system to which the chat room message distribution method according to the embodiment of the present invention is applied, and the chat system may include: a server 101, a first user terminal 102, a second user terminal 103, an nth user terminal 104, etc. Server 101 may include chat room 1, chat room 2, chat room 3, chat room m, and the like.
The n user terminals may send messages to any one of m chat rooms in the server 101, after receiving the chat messages sent by the n user terminals, the server 101 may determine a message concurrency amount of the chat messages, and when the message concurrency amount is greater than or equal to a preset concurrency amount threshold, store the received chat messages in a preset hash table. Then, the server 101 may identify the chat messages meeting the preset condition stored in the preset hash table, and store the chat room identification information corresponding to the identified chat messages meeting the preset condition in the preset queue to be pushed. And finally, polling the preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. Therefore, the normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, the chat messages have high throughput, and the delay of the server for sending the chat room messages is reduced.
In the following, a chat room message distribution method according to an embodiment of the present invention is described, as shown in fig. 2, which is a flowchart of a first implementation manner of a chat room message distribution method according to an embodiment of the present invention, where the method may include:
s210, determining the message concurrency of the received chat messages, and judging whether the message concurrency is greater than or equal to a preset concurrency threshold.
Wherein the preset concurrency threshold may be a threshold preset empirically. For example, the concurrency level threshold may be set according to network bandwidth occupancy, processor processing speed, and the like.
In some examples, multiple chat rooms may be provided in the server so that the user terminal may send messages to any one chat room to enable the user to chat in that chat room. When a user terminal sends a message to any chat room in a server, a message distribution device applying the chat room message distribution method according to the embodiment of the present invention may receive a chat message sent by the user terminal, and therefore, the message distribution device may perform statistics on the message concurrency amount of the chat messages when receiving chat messages sent by a plurality of user terminals at the same time, so as to determine the message concurrency amount of the received chat messages, and then may determine whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold.
And S220, when the message concurrency is greater than or equal to the preset concurrency threshold, storing the received chat messages in a preset hash table.
In some examples, the message distribution apparatus described above may be preset with a hash table, where the hash table is used to store the chat messages sent by the user terminal to the corresponding chat room according to the chat room identification information, for example, the hash table may store chat message 1 sent by the user terminal to chat room 1, and may also store chat message 2 sent by the user terminal to chat room 2.
Specifically, in order to prevent the load pressure of the server from being too large due to the sudden increase of the concurrency amount of the chat messages sent by the user terminal, when the message concurrency amount is greater than or equal to the preset concurrency amount threshold, the received chat messages may be stored in the preset hash table.
In an optional embodiment of the present invention, on the basis of the chat room message distribution method shown in fig. 2, in S220, when the received chat message is stored in the preset hash table, the chat room identification information to which the chat message belongs may be used as a keyword, and the chat message is used as a key value corresponding to the keyword, for each chat message, and the chat message is stored in the preset hash table. For example, as shown in table 1, in order to store the preset hash table of the chat messages, in table 1, the chat room identification information "chat room 1", "chat room 2", "chat room 3", and the like may be used as a key, and the chat message 1, the chat message 2, the chat message x, and the like corresponding to the chat room identification information "chat room 1" may be used as a key corresponding to the "chat room 1" and stored in the preset hash table.
Table 1 preset hash table for storing chat messages
Figure GDA0002617394560000091
And S230, recognizing the chat messages which are stored in the preset hash table and meet the preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed.
The preset condition may be a condition that can effectively identify the chat message stored in the preset hash table.
In some examples, the message distribution apparatus may be preset with a preset queue to be pushed, and the preset queue to be pushed may be used to store the chat room identification information.
Specifically, after storing the received chat messages in the preset hash table through the above steps, the message distribution apparatus may identify the chat messages meeting the preset condition in the preset hash table. And then storing the chat room identification information corresponding to the identified chat messages meeting the preset conditions in a preset queue to be pushed.
In an optional embodiment of the present invention, on the basis of the chat room message distribution method shown in fig. 2, the preset condition in S230 may be: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to the threshold value of the number of the messages in the preset chat room; or the message pushing waiting time of any chat room is less than or equal to the preset waiting time threshold.
For example, assuming that the total number of chat messages stored in the preset hash table and corresponding to chat room 1 is x, and is less than or equal to the threshold of the number of preset chat room messages, the identification information "chat room 1" of chat room 1 may be stored in the preset queue to be pushed.
Through the step, the chat room identification information corresponding to the chat message meeting the preset condition is stored in the preset queue to be pushed, so that the message distribution device can reduce the sending of the chat message to the corresponding user terminal and reduce the load pressure of the server when the concurrency of the chat message is large.
S240, polling the preset queue to be pushed according to a preset polling cycle, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
Wherein the preset polling period may be a polling period preset empirically.
Specifically, after the chat room identification information corresponding to the chat message meeting the preset condition is stored in the preset queue to be pushed, in this step, the message distribution device may poll the preset queue to be pushed according to a preset polling period. After polling any chat room identification information, the chat message corresponding to the chat room identification information can be obtained from the preset hash table according to the chat room identification information, and then the chat message corresponding to the chat room identification information is sent to the corresponding user terminal.
The embodiment of the invention provides a chat room message distribution method, which determines the message concurrency amount of received chat messages and judges whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold value; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced.
In an optional embodiment of the present invention, in order to send a received chat message to a user terminal in time, in S210, after determining whether a message concurrency is greater than or equal to a preset concurrency threshold, an optional embodiment is further provided in the embodiment of the present invention, and as shown in fig. 3, the optional embodiment is a flowchart of a second embodiment of a chat room message distribution method according to the embodiment of the present invention, where the method further includes:
and S250, when the message concurrency is smaller than a preset concurrency threshold, sending the received chat message to the corresponding user terminal.
Specifically, when the message distribution device determines that the message concurrency of the received chat messages is smaller than the preset concurrency threshold, it indicates that the load pressure of the chat messages simultaneously sent by the user terminals on the server is low, and the received chat messages can be directly sent to the corresponding user terminals, so that the corresponding user terminals can receive the chat messages in time.
In an optional embodiment of the present invention, in order to send a received chat message to a user terminal in time, in S220, after storing the received chat message in a preset hash table, the embodiment of the present invention further provides a possible implementation manner, and as shown in fig. 4, the method is a flowchart of a third implementation manner of a chat room message distribution method according to the embodiment of the present invention, and the method may further include:
and S260, identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
Specifically, after storing the received chat messages in the preset hash table, the message distribution device may further identify the chat messages that do not satisfy the preset conditions in the preset hash table, and then send the chat messages that do not satisfy the preset conditions to the corresponding user terminals, so that the user terminals can timely receive the chat messages that do not satisfy the preset conditions, thereby reducing the delay time for sending the chat messages and improving the user experience of the user terminals.
In a possible implementation manner of the embodiment of the present invention, on the basis of the chat room message distribution method shown in fig. 2, as shown in fig. 5, which is a flowchart of a fourth implementation manner of the chat room message distribution method shown in the embodiment of the present invention, storing, in S230, chat room identification information corresponding to the identified chat message that meets the preset condition in a preset queue to be pushed, may include:
s231, the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction, and the mould extraction chat room identification information is obtained.
Wherein the chat room identification information may be identification information composed of numbers, for example, the identification information of chat room 1 may be "15201".
In some examples, in order to reduce the occupation of space and facilitate storage when the chat room identification information is stored in the preset queue to be pushed, the chat room identification information corresponding to the identified chat message meeting the preset condition may be modulo when the chat room identification information is stored, and then the modulo chat room identification information is stored in the preset queue to be pushed.
For example, when the model of "15201" of chat room 1 is extracted, "15201% 10" is obtained, and the extracted identification information of chat room 1 is "1".
And S232, storing the obtained chat room identification information in a preset queue to be pushed.
In some examples, after the chat room identification information is modulo, the correspondence between the chat room identification information and the modulo chat room identification information may be stored, so that the corresponding chat room identification information may be obtained in the subsequent step according to the modulo chat room identification information.
Correspondingly, S240 polls the preset queue to be pushed according to the preset polling cycle, and obtains the chat message corresponding to each chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sends the obtained chat message to the corresponding user terminal, which may specifically include:
polling the extracted chat room identification information in the preset queue to be pushed according to a preset polling period, acquiring corresponding chat room identification information according to the extracted chat room identification information, acquiring chat messages corresponding to the chat room identification information from a preset hash table, and sending the acquired chat messages to corresponding user terminals.
Specifically, when the message distribution device polls the preset queue to be pushed according to the preset polling period, the device can poll to obtain the modulo chat room identification information in the preset queue to be pushed. And then, acquiring corresponding chat session identification information according to the extracted chat room identification information, acquiring a chat message corresponding to the corresponding chat room identification information from a preset hash table according to the corresponding chat room identification information, and sending the acquired chat message to a corresponding user terminal.
In a possible implementation manner of the embodiment of the present invention, on the basis of the chat room message distribution method shown in fig. 2, as shown in fig. 6, which is a flowchart of a fifth implementation manner of the chat message distribution method shown in fig. 2, S240 polls a preset queue to be pushed according to a preset polling cycle, acquires, from a preset hash table, a chat message corresponding to each piece of chat room identification information according to chat room identification information in the preset queue to be pushed, and sends the acquired chat message to a corresponding user terminal, where the method may include:
and S241, polling the identification information of each chat room in the preset queue to be pushed according to the preset polling period and the preset parallelism.
Specifically, in order to further reduce the delay of the chat messages on the premise of ensuring the normal operation of the server, when the message distribution device performs polling in the preset queue to be pushed according to the preset polling period, the message distribution device may poll the identification information of each chat room in the preset queue to be pushed with the preset parallelism.
In some examples, the preset parallelism may be an integer multiple of the number of processor cores, for example, the preset parallelism may be 2 times the number of processor cores.
For example, as shown in fig. 7, which is a schematic diagram of a preset queue to be pushed in a chat room message distribution method according to an embodiment of the present invention, in fig. 7, the preset parallelism is 4, and may include a preset queue to be pushed 1, a preset queue to be pushed 2, a preset queue to be pushed 3, and a preset queue to be pushed 4. The preset queue to be pushed 1 can store chat room identification information of 10001-19999, the preset queue to be pushed 2 can store chat room identification information of 20001-29999, the preset queue to be pushed 3 can store chat room identification information of 30001-39999, and the preset queue to be pushed 4 can store chat room identification information of 40001-49999.
The message distribution apparatus described above can simultaneously acquire chat room identification information "10001", "20001", "30001", and "40001" at time t 1. At time t2 when the preset polling period ends, chat room identification information "10002", "20002", "30002", and "40002" are acquired at the same time.
And S242, obtaining the chat messages corresponding to the identification information of each chat room from the preset hash table, and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
Specifically, after obtaining the chat room identification information from the preset queue to be pushed, the message distribution device may obtain the chat message corresponding to the chat room identification information from the preset hash table, and then send the chat message corresponding to the chat room identification information to the corresponding user terminal.
For example, after chat room identification information "10001", "20001", "30001", and "40001" are simultaneously acquired at time t1, a chat message corresponding to chat room identification information "10001", a chat message corresponding to chat room identification information "20001", a chat message corresponding to chat room identification information "30001", and a chat message corresponding to chat room identification information "40001" may be acquired from a preset hash table, respectively. Then, the chat message corresponding to the chat room identification information "10001" is transmitted to the user terminal corresponding to the chat room identification information "10001", and the chat message corresponding to the chat room identification information "20001" is transmitted to the user terminal corresponding to the chat room identification information "20001".
Through the steps, the delay of the chat messages can be further reduced on the premise of ensuring the normal operation of the server, the user experience of the user terminal is improved, and the throughput of the server can also be improved.
In a possible implementation manner of the embodiment of the present invention, in order to reduce occupation of bandwidth and confidentiality of a chat message when sending the chat message, on the basis of the chat room message distribution method shown in fig. 2, as shown in fig. 8, which is a flowchart of a sixth implementation method of the chat message distribution method of the embodiment of the present invention, in S240, when sending the obtained chat message to a corresponding user terminal, the method specifically includes:
and S240a, serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
In some examples, in serializing the retrieved chat message, the retrieved chat message may be serialized by a protocol buffer method. After the obtained chat messages are serialized, the chat messages can be compressed, and the occupation of bandwidth when the chat messages are sent is reduced.
Specifically, when the serialized chat messages are compressed, the chat messages may be compressed by using a gzip compression method, or may be compressed by using a zip compression method.
In a possible implementation manner of the embodiment of the present invention, in order to implement pushing chat messages in different manners when the server loads are different and improve flexibility of applying the chat room message distribution method according to the embodiment of the present invention, on the basis of the chat room message distribution method shown in fig. 2, as shown in fig. 9, which is a flowchart of a seventh implementation manner of the chat room message distribution method according to the embodiment of the present invention, before polling the preset queue to be pushed according to the preset polling period at S240, the chat room message distribution method according to the embodiment of the present invention may further include:
and S270, monitoring the load of the server in real time, and judging whether the load of the server is smaller than a preset load threshold value.
Wherein the load of the server comprises at least one of: processor utilization, memory occupancy, and bandwidth occupancy. The preset load threshold may be a load threshold that is empirically preset.
Specifically, before polling the preset queue to be pushed, the message distribution device may monitor the load of the server in real time, and determine whether the load of the server is smaller than a preset load threshold. Therefore, the duration of the polling period can be adjusted according to the load of the server, and the flexibility of the chat room message distribution method is improved.
Correspondingly, S240, according to a preset polling cycle, polling the preset queue to be pushed, and according to the chat room identification information in the preset queue to be pushed, obtaining the chat message corresponding to each chat room identification information from the preset hash table, and sending the obtained chat message to the corresponding user terminal, may include:
s240b, when the load of the server is smaller than the preset load threshold, polling the preset queue to be pushed according to the first preset polling cycle, and according to the chat room identification information in the preset queue to be pushed, obtaining the chat message corresponding to each chat room identification information from the preset hash table, and sending the obtained chat message to the corresponding user terminal.
Wherein the first preset polling period may be smaller than the second preset polling period.
Specifically, when the load of the server is smaller than the preset load threshold, it is indicated that the current load of the server is smaller, and the preset queue to be pushed may be polled according to a first preset polling period. The time interval of polling the preset queue to be pushed by the message distribution device is shortened, the chat messages are sent to the corresponding user terminals in time, and the delay of the chat messages is reduced.
S240c, when the load of the server is greater than or equal to the preset load threshold, polling the preset queue to be pushed according to a second preset polling cycle, and according to the chat room identification information in the preset queue to be pushed, obtaining the chat message corresponding to each chat room identification information from the preset hash table, and sending the obtained chat message to the corresponding user terminal.
Specifically, when the load of the server is greater than or equal to the preset load threshold, it indicates that the current load of the server is large, and if the first preset polling period is still adopted, the load of the server may be further increased. Therefore, in order to reduce the load of the server when the load of the server is large, the message distribution apparatus may poll the preset queue to be pushed according to a second preset polling period.
In a possible implementation manner of the embodiment of the present invention, in order to reduce occupation of a server space, on the basis of the chat room message distribution method shown in fig. 2, an embodiment of the present invention further provides a possible implementation manner, as shown in fig. 10, which is a flowchart of an eighth implementation manner of the chat room message distribution method according to the embodiment of the present invention, and after sending the obtained chat message to a corresponding user terminal, the chat room message distribution method according to the embodiment of the present invention may further include:
s280, cleaning the chat room identification information to be cleaned stored in the preset queue to be pushed.
The chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
Specifically, when part of the chat room identification information exists in the preset queue to be pushed but does not exist in the preset hash table, it indicates that the message distribution device has already sent the chat message corresponding to the part of the chat room identification information to the corresponding user terminal, and the part of the chat room identification information stored in the preset queue to be pushed is expired chat room identification information, and occupies the storage space of the server, so that the part of the chat room identification information can be cleaned.
In some examples, the message distribution apparatus may be provided with a timing module, where the timing module may perform timing in a "day" period, and after the timing is finished, may instruct the message distribution apparatus to clean the chat room identification information to be cleaned stored in the preset queue to be pushed, so as to reduce occupation of a server space.
Through the steps, the occupied space of the server can be reduced, the load pressure of the server is further reduced, and the storage space of the server is saved.
Corresponding to the above method embodiment, an embodiment of the present invention further provides a chat room message distribution apparatus, as shown in fig. 11, which is a schematic structural diagram of a chat room message distribution apparatus according to an embodiment of the present invention, and the apparatus may include:
a determining module 1110, configured to determine a message concurrency amount of a received chat message, and determine whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold;
the storage module 1120 is configured to store the received chat message in a preset hash table when the message concurrency is greater than or equal to a preset concurrency threshold;
the identifying module 1130 is configured to identify the chat messages meeting the preset conditions stored in the preset hash table, and store the chat room identification information corresponding to the identified chat messages meeting the preset conditions in a preset queue to be pushed;
the polling sending module 1140 is configured to poll a preset queue to be pushed according to a preset polling period, obtain a chat message corresponding to each chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and send the obtained chat message to a corresponding user terminal.
The chat room message distribution device provided by the embodiment of the invention determines the message concurrency amount of the received chat messages and judges whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold value; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced.
Specifically, the chat room message distribution apparatus according to the embodiment of the present invention may further include:
and the first sending module is used for sending the received chat message to the corresponding user terminal when the message concurrency is smaller than a preset concurrency threshold.
Specifically, the storage module 1120 is specifically configured to:
and aiming at each chat message, storing the chat message in a preset hash table by taking the chat room identification information to which the chat message belongs as a key word and the chat message as a key value corresponding to the key word.
Specifically, the chat room message distribution apparatus according to the embodiment of the present invention may further include:
and the second sending module is used for identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
Specifically, the preset conditions are as follows: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to the threshold value of the number of the messages in the preset chat room;
or the message pushing waiting time of any chat room is less than or equal to the preset waiting time threshold.
Specifically, the identifying module 1130 is specifically configured to:
the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction to obtain the mould-extracted chat room identification information; and storing the obtained chat room identification information in a preset queue to be pushed.
Specifically, the polling transmission module 1140 may include:
the polling submodule is used for polling the identification information of each chat room in the preset queue to be pushed according to the preset polling period and the preset parallelism;
and the sending submodule is used for acquiring the chat messages corresponding to the identification information of each chat room from the preset hash table and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
Specifically, the polling transmission module 1140 is specifically configured to:
and serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
Specifically, the chat room message distribution apparatus according to the embodiment of the present invention may further include:
the load monitoring module is used for monitoring the load of the server in real time and judging whether the load of the server is smaller than a preset load threshold value or not; wherein the load of the server comprises at least one of: the utilization rate of a processor, the memory occupancy rate and the bandwidth occupancy rate;
specifically, the polling transmission module 1140 is specifically configured to:
when the load of the server is smaller than a preset load threshold value, polling a preset queue to be pushed according to a first preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals;
when the load of the server is greater than or equal to a preset load threshold value, polling a preset queue to be pushed according to a second preset polling period, acquiring chat messages corresponding to the chat room identification information from a preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
Specifically, the chat room message distribution apparatus according to the embodiment of the present invention may further include:
the clearing module is used for clearing the chat room identification information to be cleared stored in the preset queue to be pushed after the polling sending module sends the obtained chat message to the corresponding user terminal; the chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
An embodiment of the present invention further provides an electronic device, as shown in fig. 12, including a processor 1210, a communication interface 1220, a memory 1230 and a communication bus 1240, where the processor 1210, the communication interface 1220 and the memory 1230 complete mutual communication through the communication bus 1240,
a memory 1230 for storing computer programs;
the processor 1210, when executing the programs stored in the memory 1230, performs the following steps:
determining the message concurrency of the received chat messages, and judging whether the message concurrency is greater than or equal to a preset concurrency threshold;
when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table;
recognizing the chat messages which are stored in the preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages meeting the preset conditions in a preset queue to be pushed;
polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
The electronic device provided by the embodiment of the invention determines the message concurrency amount of the received chat message and judges whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold value; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, and includes a Central Processing Unit (CPU), a Network Processor (NP), and the like; the device can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component.
In yet another embodiment of the present invention, there is also provided a computer-readable storage medium having stored therein instructions, which when run on a computer, cause the computer to perform a chat room message distribution method as described in any of the above embodiments.
The computer-readable storage medium provided by the embodiment of the invention determines the message concurrency amount of the received chat messages and judges whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold value; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced.
In yet another embodiment of the present invention, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform a chat room message distribution method as described in any of the above embodiments.
The computer program product containing the instructions provided by the embodiment of the invention determines the message concurrency amount of the received chat messages and judges whether the message concurrency amount is greater than or equal to a preset concurrency amount threshold value; when the message concurrency is greater than or equal to a preset concurrency threshold value, storing the received chat messages in a preset hash table; recognizing the chat messages which are stored in a preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages which meet the preset conditions in a preset queue to be pushed; polling a preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from a preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals. The normal operation of the server can be ensured under the condition that the concurrency of the chat messages is increased suddenly, and the delay of the server for sending the chat room messages is reduced.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the invention to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored in a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that incorporates one or more of the available media. The usable medium may be a magnetic medium (e.g., floppy Disk, hard Disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., Solid State Disk (SSD)), among others.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (19)

1. A chat room message distribution method, applied to a server, the method comprising:
determining the message concurrency of the received chat messages, and judging whether the message concurrency is greater than or equal to a preset concurrency threshold;
when the message concurrency is greater than or equal to the preset concurrency threshold, storing the received chat message in a preset hash table;
recognizing the chat messages which are stored in the preset hash table and meet preset conditions, and storing the chat room identification information corresponding to the recognized chat messages meeting the preset conditions in a preset queue to be pushed, wherein the preset conditions are as follows: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to a preset chat room message number threshold value; or the message push waiting time of any chat room is less than or equal to the preset waiting time threshold;
and polling the preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from the preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
2. The method of claim 1, wherein after the determining whether the message concurrency is greater than or equal to a preset concurrency threshold, the method further comprises:
and when the message concurrency is smaller than the preset concurrency threshold, sending the received chat message to the corresponding user terminal.
3. The method of claim 1, wherein storing the received chat message in a preset hash table comprises:
and aiming at each chat message, storing the chat message in a preset hash table by taking the chat room identification information to which the chat message belongs as a key word and the chat message as a key value corresponding to the key word.
4. The method of claim 1, wherein after storing the received chat message in a preset hash table, the method further comprises:
and identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
5. The method according to claim 1, wherein the storing the chat room identification information corresponding to the identified chat message meeting the preset condition in a preset queue to be pushed comprises:
the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction to obtain the mould-extracted chat room identification information;
and storing the obtained chat room identification information in a preset queue to be pushed.
6. The method of claim 1, wherein polling the preset queue to be pushed according to a preset polling cycle, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals, comprises:
polling the identification information of each chat room in the preset queue to be pushed according to a preset polling period and a preset parallelism;
and obtaining the chat messages corresponding to the identification information of each chat room from the preset hash table, and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
7. The method according to any one of claims 1-6, wherein sending the obtained chat message to a corresponding user terminal comprises:
serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
8. The method of claim 1, wherein prior to said polling said predetermined pending push queue according to a predetermined polling period, said method further comprises:
monitoring the load of the server in real time, and judging whether the load of the server is smaller than a preset load threshold value or not; wherein the load of the server comprises at least one of: the utilization rate of a processor, the memory occupancy rate and the bandwidth occupancy rate;
correspondingly, the polling the preset queue to be pushed according to the preset polling cycle, and acquiring the chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to the corresponding user terminal, includes:
when the load of the server is smaller than the preset load threshold value, polling the preset queue to be pushed according to a first preset polling period, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals;
when the load of the server is greater than or equal to the preset load threshold value, polling the preset queue to be pushed according to a second preset polling cycle, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
9. The method of claim 1, wherein after sending the obtained chat message to the corresponding user terminal, the method further comprises:
clearing the chat room identification information to be cleared stored in the preset queue to be pushed; and the chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
10. A chat room message distribution apparatus, applied to a server, the apparatus comprising:
the judging module is used for determining the message concurrency of the received chat messages and judging whether the message concurrency is greater than or equal to a preset concurrency threshold value;
the storage module is used for storing the received chat messages in a preset hash table when the message concurrency is greater than or equal to the preset concurrency threshold;
the identification module is used for identifying the chat messages which are stored in the preset hash table and meet the preset conditions, and storing the identified chat room identification information corresponding to the chat messages which meet the preset conditions in a preset queue to be pushed, wherein the preset conditions are as follows: in the preset hash table, the total number of the chat messages corresponding to any chat room is less than or equal to a preset chat room message number threshold value; or the message push waiting time of any chat room is less than or equal to the preset waiting time threshold;
and the polling sending module is used for polling the preset queue to be pushed according to a preset polling period, acquiring chat messages corresponding to the identification information of each chat room from the preset hash table according to the identification information of the chat rooms in the preset queue to be pushed, and sending the acquired chat messages to the corresponding user terminals.
11. The apparatus of claim 10, further comprising:
and the first sending module is used for sending the received chat message to the corresponding user terminal when the message concurrency is smaller than the preset concurrency threshold.
12. The apparatus of claim 10, wherein the storage module is specifically configured to:
and aiming at each chat message, storing the chat message in a preset hash table by taking the chat room identification information to which the chat message belongs as a key word and the chat message as a key value corresponding to the key word.
13. The apparatus of claim 10, further comprising:
and the second sending module is used for identifying the chat messages which are stored in the preset hash table and do not meet the preset conditions, and sending the chat messages which do not meet the preset conditions to the corresponding user terminals.
14. The apparatus according to claim 10, wherein the identification module is specifically configured to:
the chat room identification information corresponding to the identified chat messages meeting the preset conditions is subjected to mould extraction to obtain the mould-extracted chat room identification information; and storing the obtained chat room identification information in a preset queue to be pushed.
15. The apparatus of claim 10, wherein the polling transmission module comprises:
the polling submodule is used for polling the identification information of each chat room in the preset queue to be pushed according to a preset polling period and a preset parallelism degree;
and the sending submodule is used for acquiring the chat messages corresponding to the identification information of each chat room from the preset hash table and sending the chat messages corresponding to any chat room identification information to the user terminal corresponding to the chat room identification information.
16. The apparatus according to any one of claims 10 to 15, wherein the polling transmission module is specifically configured to:
serializing and compressing the obtained chat messages to obtain compressed chat messages, and sending the compressed chat messages to corresponding user terminals.
17. The apparatus of claim 10, further comprising:
the load monitoring module is used for monitoring the load of the server in real time and judging whether the load of the server is smaller than a preset load threshold value or not; wherein the load of the server comprises at least one of: the utilization rate of a processor, the memory occupancy rate and the bandwidth occupancy rate;
correspondingly, the polling sending module is specifically configured to:
when the load of the server is smaller than the preset load threshold value, polling the preset queue to be pushed according to a first preset polling period, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals;
when the load of the server is greater than or equal to the preset load threshold value, polling the preset queue to be pushed according to a second preset polling cycle, acquiring chat messages corresponding to the chat room identification information from the preset hash table according to the chat room identification information in the preset queue to be pushed, and sending the acquired chat messages to corresponding user terminals.
18. The apparatus of claim 10, further comprising:
the clearing module is used for clearing the chat room identification information to be cleared stored in the preset queue to be pushed after the polling sending module sends the obtained chat message to the corresponding user terminal; and the chat room identification information to be cleaned is chat room identification information which does not exist in the preset hash table.
19. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing mutual communication by the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-9 when executing a program stored in the memory.
CN201810039033.5A 2018-01-16 2018-01-16 Chat room message distribution method and device and electronic equipment Active CN108418743B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810039033.5A CN108418743B (en) 2018-01-16 2018-01-16 Chat room message distribution method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810039033.5A CN108418743B (en) 2018-01-16 2018-01-16 Chat room message distribution method and device and electronic equipment

Publications (2)

Publication Number Publication Date
CN108418743A CN108418743A (en) 2018-08-17
CN108418743B true CN108418743B (en) 2020-10-02

Family

ID=63125728

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810039033.5A Active CN108418743B (en) 2018-01-16 2018-01-16 Chat room message distribution method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN108418743B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109347647A (en) * 2018-12-21 2019-02-15 北京云中融信网络科技有限公司 Group message distribution method and device
CN111416765A (en) * 2020-03-20 2020-07-14 北京字节跳动网络技术有限公司 Interactive message processing method and device
CN112073207B (en) * 2020-11-16 2021-02-09 广州易方信息科技股份有限公司 Method, device and computer equipment for reducing message bandwidth of chat room
CN114598894A (en) * 2020-12-03 2022-06-07 北京字节跳动网络技术有限公司 Interactive message processing method, device, equipment and medium
CN113316026A (en) * 2021-05-24 2021-08-27 康键信息技术(深圳)有限公司 Barrage message processing method, device, equipment and storage medium
CN113839853B (en) * 2021-08-24 2023-02-28 云智联网络科技(北京)有限公司 High-concurrency chat room message distribution method and device

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102291324A (en) * 2011-06-28 2011-12-21 北京神州泰岳软件股份有限公司 Highly concurrent service request processing method
CN104408088A (en) * 2014-11-11 2015-03-11 北京奇虎科技有限公司 Control method and device for concurrent requests
US20150235289A1 (en) * 2012-05-17 2015-08-20 Leo Jeremias Computer system and methods for chat enabled online search
CN106534905A (en) * 2016-12-09 2017-03-22 武汉斗鱼网络科技有限公司 Method and system for intercommunication between video bullet screen live platform and bullet screen of third-party platform
CN107231350A (en) * 2017-05-24 2017-10-03 北京潘达互娱科技有限公司 A kind of message treatment method and device
US20180004575A1 (en) * 2016-06-29 2018-01-04 Amazon Technologies, Inc. Adjusting variable limit on concurrent code executions

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102291324A (en) * 2011-06-28 2011-12-21 北京神州泰岳软件股份有限公司 Highly concurrent service request processing method
US20150235289A1 (en) * 2012-05-17 2015-08-20 Leo Jeremias Computer system and methods for chat enabled online search
CN104408088A (en) * 2014-11-11 2015-03-11 北京奇虎科技有限公司 Control method and device for concurrent requests
US20180004575A1 (en) * 2016-06-29 2018-01-04 Amazon Technologies, Inc. Adjusting variable limit on concurrent code executions
CN106534905A (en) * 2016-12-09 2017-03-22 武汉斗鱼网络科技有限公司 Method and system for intercommunication between video bullet screen live platform and bullet screen of third-party platform
CN107231350A (en) * 2017-05-24 2017-10-03 北京潘达互娱科技有限公司 A kind of message treatment method and device

Also Published As

Publication number Publication date
CN108418743A (en) 2018-08-17

Similar Documents

Publication Publication Date Title
CN108418743B (en) Chat room message distribution method and device and electronic equipment
CN108390856B (en) DDoS attack detection method and device and electronic equipment
CN109495378B (en) Method, device, server and storage medium for detecting abnormal account
CN104980472A (en) Network traffic control method and device
WO2021237433A1 (en) Message pushing method and apparatus, and electronic device and computer-readable medium
CN111541555A (en) Group chat optimization method and related product
CN110022335B (en) Data packet transmitting method, device, server and computer readable storage medium
CN111538572A (en) Task processing method, device, scheduling server and medium
CN108200543B (en) Short message sending method and device
CN109788326B (en) Video resource pre-pushing method, device and system
CN112702259A (en) Delayed message pushing method and device and message middleware
CN110875983B (en) Method, device, equipment and medium for evaluating terminal service quality
CN108156086B (en) Policy rule issuing method and device
CN113835905B (en) Message queue load balancing method and device, electronic equipment and medium
CN112019589B (en) Multi-level load balancing data packet processing method
CN108243155B (en) Method and device for sending communication information
CN111148159A (en) Data transmission method, device, equipment and computer readable storage medium
CN107465743B (en) Method and device for processing request
CN108966160B (en) Short message processing method and device and computer readable storage medium
CN110557324A (en) unread IM message processing method and device
CN113750517B (en) Keyboard operation data transmission method and device and keyboard operation execution method and device
CN113810486B (en) Internet of things platform docking method and device, electronic equipment and storage medium
CN117294578B (en) Communication method, system, computer equipment and storage medium
CN115242735B (en) Real-time voice stream slice analysis method, system and computer equipment
CN111641698B (en) Data statistical method, system, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant