CN108418743A - A kind of chatroom message distributing method, device and electronic equipment - Google Patents

A kind of chatroom message distributing method, device and electronic equipment Download PDF

Info

Publication number
CN108418743A
CN108418743A CN201810039033.5A CN201810039033A CN108418743A CN 108418743 A CN108418743 A CN 108418743A CN 201810039033 A CN201810039033 A CN 201810039033A CN 108418743 A CN108418743 A CN 108418743A
Authority
CN
China
Prior art keywords
chat messages
default
chatroom
identification information
queue
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.)
Granted
Application number
CN201810039033.5A
Other languages
Chinese (zh)
Other versions
CN108418743B (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

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)
  • Multimedia (AREA)
  • Computer Hardware Design (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

An embodiment of the present invention provides a kind of chatroom message distributing method, device and electronic equipments, wherein this method includes:The chat messages received are stored in default Hash table by the message concurrency for determining the chat messages received when message concurrency is greater than or equal to default concurrency threshold value;In default Hash table, identification meets the chat messages of preset condition, and the corresponding chatroom identification information storage of the chat messages for meeting preset condition that will identify that is in default queue to be pushed;According to default polling cycle, poll presets queue to be pushed, according to the chatroom identification information preset in queue to be pushed, the chat messages corresponding with each chatroom identification information are obtained from default Hash table, and acquired chat messages are sent to corresponding user terminal.It can realize in the case where chat messages concurrency is uprushed, ensure server normal operation, and the delay that server sends chatroom message can be reduced.

Description

A kind of chatroom message distributing method, device and electronic equipment
Technical field
The present invention relates to instant messaging fields, more particularly to a kind of chatroom message distributing method, device and electricity Sub- equipment.
Background technology
With the high speed development of internet, indispensable communication means during instant messaging has become for people's lives, flat When amusement and recreation and work in be obtained for and be widely applied.Chatroom is received as a kind of emerging instant communication mode People favor.For the live streaming chatroom under internet environment, user often sends a piece of news, which can all be initially transmitted to Server, other each users being then distributed in the chatroom via the server.
However, inventor has found in the implementation of the present invention, at least there are the following problems for the prior art:
When the user of live streaming chatroom is relatively more, and the temperature relatively high live streaming period is concentrated on, chatroom is being broadcast live When middle transmission message, it is easy so that the concurrency of message increases.When the concurrency that the message sent in chatroom is broadcast live is more than clothes When the outlet bandwidth of business device, the message of chatroom can be made to be difficult to send, so that the delay of the message of chatroom increases Greatly, the experience of the user of chatroom is reduced.
Invention content
The embodiment of the present invention is designed to provide a kind of chatroom message distributing method, device and electronic equipment, with reality In the case that present chat messages concurrency is uprushed, ensure that server being capable of normal operation.Specific technical solution is as follows:
In the one side that the present invention is implemented, an embodiment of the present invention provides a kind of chatroom message distributing method, applications In server, this method includes:
It determines the message concurrency of the chat messages received, and judges whether message concurrency is greater than or equal to and preset simultaneously Hair amount threshold value;
When message concurrency is greater than or equal to default concurrency threshold value, the chat messages received are stored in default Kazakhstan In uncommon table;
Identification is stored in the chat messages for meeting preset condition in default Hash table, and the satisfaction identified is preset The corresponding chatroom identification information storage of chat messages of condition is in presetting queue to be pushed;
According to default polling cycle, poll presets queue to be pushed, and is marked according to the chatroom preset in queue to be pushed Know information, the chat messages corresponding with each chatroom identification information is obtained from default Hash table, and acquired chat is disappeared Breath is sent to corresponding user terminal.
Optionally, after judging whether message concurrency is greater than or equal to default concurrency threshold value, the embodiment of the present invention A kind of chatroom message distributing method, further include:
When message concurrency is less than default concurrency threshold value, it is whole that the chat messages received are sent to corresponding user End.
Optionally, the chat messages received are stored in default Hash table, including:
Disappeared with the chat using the chatroom identification information belonging to the chat messages as keyword for every chat messages Breath is key assignments corresponding with the keyword, which is stored in default Hash table.
Optionally, after the chat messages received are stored in default Hash table, one kind of the embodiment of the present invention Chatroom message distributing method further includes:
Identification is stored in the chat messages for being unsatisfactory for preset condition in default Hash table, will be unsatisfactory for chatting for preset condition Its message is sent to corresponding user terminal.
Optionally, preset condition is:In default Hash table, the corresponding chat messages total number in any chatroom is less than or waits In default chatroom message bar number threshold value;
Alternatively, the message push waiting time of any chatroom is less than or equal to default waiting time threshold value.
Optionally, by the corresponding chatroom identification information storage of the chat messages for meeting preset condition identified pre- If in queue to be pushed, including:
By the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified, after obtaining modulus Chatroom identification information;
By the chatroom identification information storage after modulus in presetting queue to be pushed.
Optionally, according to default polling cycle, poll presets queue to be pushed, and according to chatting in default queue to be pushed Its room identification information obtains the chat messages corresponding with each chatroom identification information from default Hash table, and will be acquired Chat messages are sent to corresponding user terminal, including:
According to default polling cycle, to preset each chatroom identification information in the default queue to be pushed of degree of parallelism poll;
From default Hash table, the chat messages corresponding with each chatroom identification information are obtained, and will be with any chatroom Chat messages corresponding to identification information, are sent to the user terminal corresponding with the chatroom identification information.
Optionally, acquired chat messages are sent to corresponding user terminal includes:
Acquired chat messages are serialized and compressed, obtain compressed chat messages, and will be compressed Chat messages are sent to corresponding user terminal.
Optionally, according to default polling cycle, before poll presets queue to be pushed, one kind of the embodiment of the present invention is chatted Its room message approach further includes:
The load of real-time monitoring server, and judge whether the load of server is less than default load threshold;Wherein, it services The load of device includes at least one of following:Processor utilization rate, memory usage and bandwidth usage;
Correspondingly, according to default polling cycle, poll presets queue to be pushed, and according to chatting in default queue to be pushed Its room identification information obtains the chat messages corresponding with each chatroom identification information from default Hash table, and will be acquired Chat messages are sent to corresponding user terminal, including:
When the load of server is less than default load threshold, according to the first default polling cycle, poll is default to be waited pushing Queue, and according to the chatroom identification information preset in queue to be pushed, obtain from default Hash table and identified with each chatroom The corresponding chat messages of information, and acquired chat messages are sent to corresponding user terminal;
When the load of server is greater than or equal to default load threshold, according to the second default polling cycle, poll is default Queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained and each chat from default Hash table Chat messages corresponding to room identification information, and acquired chat messages are sent to corresponding user terminal.
Optionally, after acquired chat messages are sent to corresponding user terminal, the one of the embodiment of the present invention Chatroom message distributing method is planted, further includes:
Cleaning is stored in the chatroom identification information for clearance preset in queue to be pushed;Wherein, chatroom mark for clearance It is the chatroom identification information being not present in default Hash table to know information.
At the another aspect that the present invention is implemented, a kind of chatroom message distribution device is additionally provided, is applied to server, it should Device includes:
Judgment module, the message concurrency for determining the chat messages received, and judge whether message concurrency is big In or equal to default concurrency threshold value;
Memory module, for when message concurrency is greater than or equal to default concurrency threshold value, the chat received to be disappeared Breath is stored in default Hash table;
Identification module, the chat messages for meeting preset condition being stored in for identification in default Hash table, and will be known The corresponding chatroom identification information storage of the chat messages for meeting preset condition not gone out is in presetting queue to be pushed;
Poll sending module, for according to default polling cycle, poll to preset queue to be pushed, and waits pushing according to default Chatroom identification information in queue obtains the chat messages corresponding with each chatroom identification information from default Hash table, and Acquired chat messages are sent to corresponding user terminal.
Optionally, a kind of chatroom message distribution device of the embodiment of the present invention further includes:
First sending module, the chat messages for when message concurrency is less than default concurrency threshold value, will receive It is sent to corresponding user terminal.
Optionally, memory module is specifically used for:
Disappeared with the chat using the chatroom identification information belonging to the chat messages as keyword for every chat messages Breath is key assignments corresponding with the keyword, which is stored in default Hash table.
Optionally, a kind of chatroom message distribution device of the embodiment of the present invention further includes:
Second sending module, the chat messages for being unsatisfactory for preset condition being stored in for identification in default Hash table will The chat messages for being unsatisfactory for preset condition are sent to corresponding user terminal.
Optionally, preset condition is:In default Hash table, the corresponding chat messages total number in any chatroom is less than or waits In default chatroom message bar number threshold value;
Alternatively, the message push waiting time of any chatroom is less than or equal to default waiting time threshold value.
Optionally, identification module is specifically used for:
By the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified, after obtaining modulus Chatroom identification information;By the chatroom identification information storage after modulus in presetting queue to be pushed.
Optionally, poll sending module, including:
Poll submodule, for according to default polling cycle, being preset with default degree of parallelism poll each in queue to be pushed Chatroom identification information;
Sending submodule, for from default Hash table, obtaining the chat messages corresponding with each chatroom identification information, and By the chat messages corresponding with any chatroom identification information, it is sent to the user terminal corresponding with the chatroom identification information.
Optionally, poll sending module is specifically used for:
Acquired chat messages are serialized and compressed, obtain compressed chat messages, and will be compressed Chat messages are sent to corresponding user terminal.
Optionally, a kind of chatroom message distribution device of the embodiment of the present invention further includes:
Load monitoring module, is used for the load of real-time monitoring server, and it is default to judge whether the load of server is less than Load threshold;Wherein, the load of server includes at least one of following:Processor utilization rate, memory usage and bandwidth occupancy Rate;
Correspondingly, poll sending module, is specifically used for:
When the load of server is less than default load threshold, according to the first default polling cycle, poll is default to be waited pushing Queue, and according to the chatroom identification information preset in queue to be pushed, obtain from default Hash table and identified with each chatroom The corresponding chat messages of information, and acquired chat messages are sent to corresponding user terminal;
When the load of server is greater than or equal to default load threshold, according to the second default polling cycle, poll is default Queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained and each chat from default Hash table Chat messages corresponding to room identification information, and acquired chat messages are sent to corresponding user terminal.
Optionally, a kind of chatroom message distribution device of the embodiment of the present invention further includes:
Cleaning modul, for poll sending module by acquired chat messages be sent to corresponding user terminal it Afterwards, cleaning is stored in the chatroom identification information for clearance preset in queue to be pushed;Wherein, chatroom identification information for clearance For the chatroom identification information being not present in default Hash table.
At the another aspect that the present invention is implemented, a kind of electronic equipment, including processor, communication interface, storage are additionally provided Device and communication bus, wherein processor, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes a kind of any of the above-described chatroom message Distribution method.
At the another aspect that the present invention is implemented, a kind of computer readable storage medium is additionally provided, it is described computer-readable Instruction is stored in storage medium, when run on a computer so that computer executes a kind of any of the above-described chat Room message distributing method.
At the another aspect that the present invention is implemented, the embodiment of the present invention additionally provides a kind of computer program production comprising instruction Product, when run on a computer so that computer executes a kind of any of the above-described chatroom message distributing method.
A kind of chatroom message distributing method, device and electronic equipment provided in an embodiment of the present invention have been connect by determination The message concurrency of the chat messages of receipts, and judge whether message concurrency is greater than or equal to default concurrency threshold value;In message When concurrency is greater than or equal to default concurrency threshold value, the chat messages received are stored in default Hash table;Identification is deposited Store up the chat messages for meeting preset condition in default Hash table, and the chat messages for meeting preset condition that will be identified Corresponding chatroom identification information storage is in presetting queue to be pushed;According to default polling cycle, poll presets team to be pushed Row, and according to the chatroom identification information preset in queue to be pushed, obtain from default Hash table and believe with each chatroom mark Corresponding chat messages are ceased, and acquired chat messages are sent to corresponding user terminal.It may be implemented in chat messages In the case that concurrency is uprushed, ensure server normal operation, and reduces the delay that server sends chatroom message.When So, it implements any of the products of the present invention or method must be not necessarily required to reach all the above advantage simultaneously.
Description of the drawings
In order to more clearly explain the embodiment of the invention or the technical proposal in the existing technology, to embodiment or will show below There is attached drawing needed in technology description to be briefly described.
Fig. 1 is that a kind of chatroom message distributing method of the embodiment of the present invention is applied to the structural schematic diagram of chat system;
Fig. 2 is a kind of flow chart of the first embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 3 is a kind of flow chart of second of embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 4 is a kind of flow chart of the third embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 5 is a kind of flow chart of the 4th kind of embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 6 is a kind of flow chart of the 5th kind of embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 7 is the default queue schematic diagram to be pushed in a kind of chatroom message distributing method of the embodiment of the present invention;
Fig. 8 is a kind of flow chart of the 6th kind of embodiment of chatroom message distributing method of the embodiment of the present invention;
Fig. 9 is a kind of flow chart of the 7th kind of embodiment of chatroom message distributing method of the embodiment of the present invention;
Figure 10 is a kind of flow chart of the 8th kind of embodiment of chatroom message distributing method of the embodiment of the present invention;
Figure 11 is a kind of structural schematic diagram of chatroom message distribution device of the embodiment of the present invention;
Figure 12 is the structural schematic diagram of a kind of electronic equipment of the embodiment of the present invention.
Specific implementation mode
Following will be combined with the drawings in the embodiments of the present invention, and technical solution in the embodiment of the present invention is described.
It is of the existing technology in order to solve the problems, such as, an embodiment of the present invention provides a kind of chatroom message distributing method, Device and electronic equipment ensure that server being capable of normal operation to realize in the case where chat messages concurrency is uprushed.
First, a kind of chatroom message distributing method of the embodiment of the present invention can be applied to server, which can To establish network connection with multiple user terminals, for example, as shown in Figure 1, a kind of chatroom message for the embodiment of the present invention is divided Forwarding method is applied to the structural schematic diagram of chat system, which may include:Server 110, the first user terminal 120, second user terminal 130, n-th user terminal 140 etc..Wherein, may include in server 110 chatroom 1, chatroom 2, Chatroom 3, chatroom m etc..
Above-mentioned n user terminal can send message to any one chatroom in m chatroom in server 110, Server 110 is after receiving the chat messages that above-mentioned n user terminal is sent, it may be determined that the message of chat messages is concurrent The chat messages received are stored in default Hash table by amount when message concurrency is greater than or equal to default concurrency threshold value In.Then, server 110 can identify the chat messages for meeting preset condition being stored in default Hash table, and will be known The corresponding chatroom identification information storage of the chat messages for meeting preset condition not gone out is in presetting queue to be pushed.Finally, According to default polling cycle, poll presets queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, from It obtains the chat messages corresponding with each chatroom identification information in default Hash table, and acquired chat messages is sent to pair The user terminal answered.So as to realize in the case where chat messages concurrency is uprushed, ensure server normal operation, to chatting Its message has high-throughput, and reduces the delay that server sends chatroom message.
In the following, a kind of chatroom message distributing method to the embodiment of the present invention is introduced, as shown in Fig. 2, being this hair A kind of flow chart of the first embodiment of chatroom message distributing method of bright embodiment, this method may include:
S210, determines the message concurrency of the chat messages received, and judges whether message concurrency is greater than or equal to Default concurrency threshold value.
Wherein, which can be rule of thumb pre-set threshold value.For example, can be according to Netowrk tape Concurrency threshold value is arranged in wide occupancy, processor processing speed etc..
In some instances, multiple chatrooms can be set in the server, so that user terminal can be to any one Chatroom sends message, to realize that user chats in the chatroom.When user terminal is to any of server When chatroom sends message, it can be connect using a kind of message distribution device of chatroom message distributing method of the embodiment of the present invention The chat messages of user terminal transmission are received, therefore, above-mentioned message distribution device can receive multiple user terminals at the same time When the chat messages of transmission, the message concurrency of chat messages is counted, may thereby determine that the chat having received disappears The message concurrency of breath, then may determine that whether the message concurrency is greater than or equal to default concurrency threshold value.
The chat messages received are stored in by S220 when message concurrency is greater than or equal to default concurrency threshold value In default Hash table.
In some instances, it can be previously provided with Hash table in above-mentioned message distribution device, the Hash table is for pressing According to the chat messages that chatroom identification information storage user terminal is sent to corresponding chatroom, for example, can be deposited in the Hash table The chat messages 1 that storage user terminal is sent to chatroom 1, can also store the chat messages that user terminal is sent to chatroom 2 2。
Specifically, the concurrency for the chat messages that user terminal is sent in order to prevent uprushes and causes the load pressure of server It is excessive, when message concurrency is greater than or equal to default concurrency threshold value, the chat messages received can be stored in default In Hash table.
In a kind of optional embodiment of the embodiment of the present invention, a kind of chatroom message distributing method shown in Fig. 2 On the basis of, in S220, when the chat messages received are stored in default Hash table, every chat messages can be directed to, with Chatroom identification information belonging to the chat messages is keyword, will with the chat messages for key assignments corresponding with the keyword The chat messages are stored in default Hash table.For example, as shown in table 1, to store the default Hash table of chat messages, in table 1 In, chatroom identification information " chatroom 1 ", " chatroom 2 ", " chatroom 3 " etc. can be regard as keyword, will be marked with chatroom The corresponding chat messages 1 of information " chatroom 1 ", chat messages 2, chat messages x etc. are known as key corresponding with " chatroom 1 " Value, is stored in default Hash table.
Table 1 stores the default Hash table of chat messages
S230, identification is stored in the chat messages for meeting preset condition in default Hash table, and expires what is identified The corresponding chatroom identification information storage of chat messages of sufficient preset condition is in presetting queue to be pushed.
Wherein, above-mentioned preset condition can effectively be known to the chat messages being stored in default Hash table Other condition.
In some instances, it can be previously provided in above-mentioned message distribution device and preset queue to be pushed, this is default Queue to be pushed can be used for storing chatroom identification information.
Specifically, through the above steps, it is above-mentioned after the chat messages received are stored in default Hash table Message distribution device can identify the chat messages for meeting preset condition in default Hash table.Then the satisfaction that will identify that is pre- If the corresponding chatroom identification information storage of the chat messages of condition is in presetting queue to be pushed.
In a kind of optional embodiment of the embodiment of the present invention, a kind of chatroom message distributing method shown in Fig. 2 On the basis of, the preset condition in S230 can be:In default Hash table, the corresponding chat messages total number in any chatroom is less than Or equal to default chatroom message bar number threshold value;It is preset alternatively, the message push waiting time of any chatroom is less than or equal to Waiting time threshold value.
For example, it is assumed that the chat messages sum corresponding with chatroom 1 being stored in default Hash table has x items, be less than or Equal to default chatroom message bar number threshold value, then the identification information " chatroom 1 " of chatroom 1 can be stored in preset and wait pushing In queue.
By this step, the corresponding chatroom identification information storage of the chat messages for meeting preset condition is waited pushing away default It send in queue, above-mentioned message distribution device can be made when chat messages concurrency is larger, reduction sends chat messages To corresponding user terminal, the load pressure of server is reduced.
S240, according to default polling cycle, poll presets queue to be pushed, and according to the chat preset in queue to be pushed Room identification information obtains the chat messages corresponding with each chatroom identification information from default Hash table, and acquired is chatted Its message is sent to corresponding user terminal.
Wherein, which can be rule of thumb pre-set polling cycle.
Specifically, the corresponding chatroom identification information storage of the chat messages for meeting preset condition is waited pushing default After in queue, in this step, above-mentioned message distribution device can be according to default polling cycle, to presetting queue to be pushed It is polled.It, can be according to the chatroom identification information, from default Hash table after being polled to any chatroom identification information The chat messages corresponding with the chatroom identification information are obtained, then send out the chat messages corresponding with the chatroom identification information It send to corresponding user terminal.
A kind of chatroom message distributing method provided in an embodiment of the present invention, by determining disappearing for the chat messages received Concurrency is ceased, and judges whether message concurrency is greater than or equal to default concurrency threshold value;It is greater than or equal in message concurrency When default concurrency threshold value, the chat messages received are stored in default Hash table;Identification is stored in default Hash table The chat messages for meeting preset condition, and the corresponding chatroom of the chat messages for meeting preset condition identified is identified Information storage is in presetting queue to be pushed;According to default polling cycle, poll presets queue to be pushed, and waits pushing away according to default The chatroom identification information in queue is sent, the chat messages corresponding with each chatroom identification information are obtained from default Hash table, And acquired chat messages are sent to corresponding user terminal.It may be implemented the case where chat messages concurrency is uprushed Under, ensure server normal operation, and reduce the delay that server sends chatroom message.
In a kind of optional embodiment of the embodiment of the present invention, in order to which the chat messages received are sent in time User terminal judges whether message concurrency is greater than or equal to after default concurrency threshold value in S210, and the embodiment of the present invention is also A kind of optional embodiment is provided, as shown in figure 3, for a kind of chatroom message distributing method second of the embodiment of the present invention The flow chart of kind embodiment, this method can also include:
The chat messages received are sent to corresponding by S250 when message concurrency is less than default concurrency threshold value User terminal.
Specifically, being preset when above-mentioned message distribution device is less than in the message concurrency for the chat messages for judging to have received When concurrency threshold value, then illustrates user terminal while the chat messages load pressure caused by server sent is smaller, it can be with The chat messages received are directly sent to corresponding user terminal, so that corresponding user terminal can receive in time To the chat messages.
In a kind of optional embodiment of the embodiment of the present invention, in order to which the chat messages received are sent in time User terminal, in S220, after the chat messages received are stored in default Hash table, the embodiment of the present invention additionally provides A kind of possible realization method, as shown in figure 4, for a kind of the third implementation of chatroom message distributing method of the embodiment of the present invention The flow chart of mode, this method can also include:
S260, identification are stored in the chat messages for being unsatisfactory for preset condition in default Hash table, will be unsatisfactory for default item The chat messages of part are sent to corresponding user terminal.
Specifically, the chat messages received are after being stored in default Hash table by above-mentioned message distribution device, The chat messages for being unsatisfactory for preset condition can also be identified in default Hash table, and then the chat for being unsatisfactory for preset condition disappears Breath is sent to corresponding user terminal, so that user terminal, which can timely receive this, is unsatisfactory for chatting for preset condition Its message reduces the delay time that chat messages are sent, improves the user experience of user terminal.
In a kind of possible realization method of the embodiment of the present invention, a kind of chatroom message distribution side shown in Fig. 2 On the basis of method, as shown in figure 5, a kind of stream of the 4th kind of embodiment of chatroom message distributing method for the embodiment of the present invention Cheng Tu waits the corresponding chatroom identification information storage of the chat messages for meeting preset condition identified default in S230 It pushes in queue, may include:
S231 obtains the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified Chatroom identification information after modulus.
Wherein, the identification information which can be made of number, for example, the mark letter of chatroom 1 Breath can be " 15201 ".
In some instances, chatroom identification information storage is being preset when pushing in queue to space in order to reduce It occupies, and facilitates storage, it can be when storing the chatroom identification information, the chat for meeting preset condition to being identified The corresponding chatroom identification information modulus of message, then by the chatroom identification information storage after modulus in default queue to be pushed In.
For example, when the identification information " 15201 " to chatroom 1 carries out modulus, it can be " 15201%10 ", obtain modulus The identification information of chatroom 1 afterwards is " 1 ".
S232, by the chatroom identification information storage after modulus in presetting queue to be pushed.
It in some instances, can be to chatroom identification information and modulus after carrying out modulus to chatroom identification information The correspondence of chatroom identification information afterwards is stored, to be marked according to the chatroom after modulus in subsequent step Acquisition of information is known to corresponding chatroom identification information.
Correspondingly, S240, according to default polling cycle, poll presets queue to be pushed, and according to default queue to be pushed In chatroom identification information, obtain chat messages corresponding with each chatroom identification information from default Hash table, and by institute The chat messages of acquisition are sent to corresponding user terminal, can specifically include:
According to default polling cycle, the default chatroom identification information after pushing the modulus in queue of poll, according to taking Chatroom identification information after mould obtains corresponding chatroom identification information, and is obtained and each chatroom from default Hash table Acquired chat messages are sent to corresponding user terminal by chat messages corresponding to identification information.
Specifically, above-mentioned message distribution device is being polled according to default polling cycle to presetting queue to be pushed When, the default chatroom identification information after pushing the modulus in queue can be got with poll.Then after can be according to modulus Chatroom identification information, get corresponding chat can identification information, further according to the corresponding chatroom identification information, from pre- If obtaining the chat messages corresponding with the corresponding chatroom identification information in Hash table, and accessed chat messages are sent To corresponding user terminal.
In a kind of possible realization method of the embodiment of the present invention, a kind of chatroom message distribution side shown in Fig. 2 On the basis of method, as shown in fig. 6, a kind of flow of the 5th kind of embodiment of chat messages distribution method for the embodiment of the present invention Figure, S240, according to default polling cycle, poll presets queue to be pushed, and is marked according to the chatroom preset in queue to be pushed Know information, the chat messages corresponding with each chatroom identification information is obtained from default Hash table, and acquired chat is disappeared Breath is sent to corresponding user terminal, may include:
S241 is identified according to default polling cycle with presetting each chatroom in the default queue to be pushed of degree of parallelism poll Information.
Specifically, in order under the premise of ensureing server normal operation, the delay of chat messages is further decreased, it is above-mentioned Message distribution device according to default polling cycle it is default be polled in push queue when, can be with default degree of parallelism Poll presets each chatroom identification information in queue to be pushed.
In some instances, above-mentioned default degree of parallelism can be the integral multiple of processor check figure, for example, default degree of parallelism Can be 2 times of processor check figure.
For example, as shown in fig. 7, for the default team to be pushed in a kind of chatroom message distributing method of the embodiment of the present invention Intention is listed, in the figure 7, it is 4 to preset degree of parallelism, may include default queue 1 push, default queue 2 to be pushed, presets and wait for It pushes queue 3 and presets queue 4 to be pushed.Wherein, chatroom identification information " 10001 can be stored by presetting in queue 1 to be pushed ~19999 ", chatroom identification information " 20001~29999 " can be stored by presetting in queue 2 to be pushed, and preset queue to be pushed Chatroom identification information " 30001~39999 " can be stored in 3, chatroom mark letter can be stored by presetting in queue 4 to be pushed It ceases " 40001~49999 ".
Above-mentioned message distribution device can obtain chatroom identification information " 10001 ", " 20001 " simultaneously at the t1 moment " 30001 " and " 40001 ".At the t2 moment that default polling cycle terminates, at the same obtain chatroom identification information " 10002 ", " 20002 " " 30002 " and " 40002 ".
S242 obtains the chat messages corresponding with each chatroom identification information, and will be chatted with any from default Hash table Chat messages corresponding to its room identification information, are sent to the user terminal corresponding with the chatroom identification information.
Specifically, above-mentioned message distribution device from default after getting chatroom identification information in pushing queue, It can obtain the chat messages corresponding with the chatroom identification information from default Hash table, then will be identified with the chatroom Information corresponds to chat messages and is sent to corresponding user terminal.
For example, obtaining chatroom identification information " 10001 ", " 20001 " " 30001 " and " 40001 " simultaneously at the t1 moment Afterwards, chat messages corresponding with chatroom identification information " 10001 " and chatroom can be obtained respectively from default Hash table The corresponding chat messages of identification information " 20001 ", chat messages corresponding with chatroom identification information " 30001 " and with chat The corresponding chat messages of room identification information " 40001 ".It then will chat messages hair corresponding with chatroom identification information " 10001 " It send to and with chatroom identification information " 10001 " corresponding user terminal, corresponding with chatroom identification information " 20001 " will chat Its message is sent to user terminal corresponding with chatroom identification information " 20001 ".
By this step, the delay of chat messages can be further decreased under the premise of ensureing server normal operation, The user experience for improving user terminal, can also improve the handling capacity of server.
In a kind of possible realization method of the embodiment of the present invention, bandwidth is accounted for when sending chat messages to reduce With and to chat messages secrecy, on the basis of a kind of chatroom message distributing method shown in Fig. 2, as shown in figure 8, being The flow chart of the 6th kind of implementation of a kind of chat messages distribution method of the embodiment of the present invention, in S240, will be acquired Chat messages when being sent to corresponding user terminal, can specifically include:
S240a is serialized and is compressed to acquired chat messages, obtain compressed chat messages, will be compressed Chat messages afterwards are sent to corresponding user terminal.
In some instances, when being serialized to acquired chat messages, protocol buffer can be passed through Method serializes acquired chat messages.It, can be again to this after being serialized to acquired chat messages Chat messages are compressed, and the occupancy to bandwidth when sending the chat messages is reduced.
Specifically, when being compressed to the chat messages after serializing, can be compressed using gzip compress modes, It can also be compressed using zip compress modes.
In a kind of possible realization method of the embodiment of the present invention, in order to be realized to chat in server load difference Message is pushed in different ways, improves a kind of the flexible of the chatroom message distributing method for applying the embodiment of the present invention Property, on the basis of a kind of chatroom message distributing method shown in Fig. 2, as shown in figure 9, one kind for the embodiment of the present invention is chatted The flow chart of its 7th kind of embodiment of room message distributing method, in S240, according to default polling cycle, poll is default to be waited pushing Before queue, a kind of chatroom message distributing method of the embodiment of the present invention can also include:
S270, the load of real-time monitoring server, and judge whether the load of server is less than default load threshold.
Wherein, the load of server includes at least one of following:Processor utilization rate, memory usage and bandwidth occupancy Rate.Default load threshold can be rule of thumb pre-set load threshold.
Specifically, above-mentioned message distribution device can monitor in real time before being polled to default queue to be pushed The load of server, and judge whether the load of server is less than default load threshold.So as to according to the load of server The duration of polling cycle is adjusted, a kind of the flexible of the chatroom message distributing method for applying the embodiment of the present invention is improved Property.
Correspondingly, S240, according to default polling cycle, poll presets queue to be pushed, and according to default queue to be pushed In chatroom identification information, obtain chat messages corresponding with each chatroom identification information from default Hash table, and by institute The chat messages of acquisition are sent to corresponding user terminal, may include:
S240b, when the load of server is less than default load threshold, according to the first default polling cycle, poll is default Queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained and each chat from default Hash table Chat messages corresponding to room identification information, and acquired chat messages are sent to corresponding user terminal.
Wherein, which can be less than the second default polling cycle.
Specifically, when the load of server is less than default load threshold, illustrate that server present load is smaller, it can be by It is polled according to the first default polling cycle to presetting queue to be pushed.To shorten, above-mentioned message distribution device poll is default to be waited pushing away The time interval of queue is sent, chat messages are sent to corresponding user terminal in time, reduces the delay of chat messages.
S240c, when the load of server is greater than or equal to default load threshold, according to the second default polling cycle, wheel Ask preset queue push, and according to preset queue push in chatroom identification information, from default Hash table acquisition and Chat messages corresponding to each chatroom identification information, and acquired chat messages are sent to corresponding user terminal.
Specifically, when the load of server is greater than or equal to default load threshold, illustrate that server present load is larger, If still using the first default polling cycle, the load of server may be further increased.Therefore, in order in the negative of server The load of server is reduced when carrying larger, above-mentioned message distribution device can be waited for according to the second default polling cycle default Push queue is polled.
In a kind of possible realization method of the embodiment of the present invention, in order to reduce the occupancy to server space, in Fig. 2 Shown on the basis of a kind of chatroom message distributing method, the embodiment of the present invention additionally provides a kind of possible realization method, As shown in Figure 10, it is a kind of flow chart of the 8th kind of embodiment of chatroom message distributing method of the embodiment of the present invention, is inciting somebody to action Acquired chat messages are sent to after corresponding user terminal, a kind of chatroom message distribution side of the embodiment of the present invention Method can also include:
S280, cleaning are stored in the chatroom identification information for clearance preset in queue to be pushed.
Wherein, chatroom identification information for clearance is the chatroom identification information being not present in default Hash table.
Specifically, when part chatroom identification information is not present in presetting queue to be pushed, and in default Hash table In the presence of, then illustrate above-mentioned message distribution device, by chat messages corresponding to the part chatroom identification information It is sent to corresponding user terminal, it is expired chat that this, which is stored in the part chatroom identification information preset in queue to be pushed, Room identification information occupies the memory space of server, therefore, can clear up the part chatroom identification information.
In some instances, above-mentioned message distribution device can be provided with timing module, which can be with " day " is to carry out timing in the period, after timing, can indicate that the message distribution device presets queue to be pushed to being stored in In chatroom identification information for clearance cleared up, to reduce to the occupancy of server space.
By this step, it is possible to reduce to the space hold of server, further decrease server load pressure, save clothes Business device memory space.
Corresponding to above method embodiment, the embodiment of the present invention additionally provides a kind of chatroom message distribution device, such as schemes It is a kind of structural schematic diagram of chatroom message distribution device of the embodiment of the present invention shown in 11, which may include:
Judgment module 1110, the message concurrency for determining the chat messages received, and judge that message concurrency is It is no to be greater than or equal to default concurrency threshold value;
Memory module 1120, for when message concurrency is greater than or equal to default concurrency threshold value, being chatted what is received Its message is stored in default Hash table;
Identification module 1130, the chat messages for meeting preset condition being stored in for identification in default Hash table, and will The corresponding chatroom identification information storage of the chat messages for meeting preset condition identified is in presetting queue to be pushed;
Poll sending module 1140, for according to default polling cycle, poll to preset queue to be pushed, and is waited for according to default The chatroom identification information in queue is pushed, the chat corresponding with each chatroom identification information is obtained from default Hash table and is disappeared Breath, and acquired chat messages are sent to corresponding user terminal.
A kind of chatroom message distribution device provided in an embodiment of the present invention, by determining disappearing for the chat messages received Concurrency is ceased, and judges whether message concurrency is greater than or equal to default concurrency threshold value;It is greater than or equal in message concurrency When default concurrency threshold value, the chat messages received are stored in default Hash table;Identification is stored in default Hash table The chat messages for meeting preset condition, and the corresponding chatroom of the chat messages for meeting preset condition identified is identified Information storage is in presetting queue to be pushed;According to default polling cycle, poll presets queue to be pushed, and waits pushing away according to default The chatroom identification information in queue is sent, the chat messages corresponding with each chatroom identification information are obtained from default Hash table, And acquired chat messages are sent to corresponding user terminal.It may be implemented the case where chat messages concurrency is uprushed Under, ensure server normal operation, and reduce the delay that server sends chatroom message.
Specifically, a kind of chatroom message distribution device of the embodiment of the present invention, can also include:
First sending module, the chat messages for when message concurrency is less than default concurrency threshold value, will receive It is sent to corresponding user terminal.
Specifically, memory module 1120, is specifically used for:
Disappeared with the chat using the chatroom identification information belonging to the chat messages as keyword for every chat messages Breath is key assignments corresponding with the keyword, which is stored in default Hash table.
Specifically, a kind of chatroom message distribution device of the embodiment of the present invention, can also include:
Second sending module, the chat messages for being unsatisfactory for preset condition being stored in for identification in default Hash table will The chat messages for being unsatisfactory for preset condition are sent to corresponding user terminal.
Specifically, preset condition is:In default Hash table, the corresponding chat messages total number in any chatroom is less than or waits In default chatroom message bar number threshold value;
Alternatively, the message push waiting time of any chatroom is less than or equal to default waiting time threshold value.
Specifically, identification module 1130, is specifically used for:
By the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified, after obtaining modulus Chatroom identification information;By the chatroom identification information storage after modulus in presetting queue to be pushed.
Specifically, poll sending module 1140, may include:
Poll submodule, for according to default polling cycle, being preset with default degree of parallelism poll each in queue to be pushed Chatroom identification information;
Sending submodule, for from default Hash table, obtaining the chat messages corresponding with each chatroom identification information, and By the chat messages corresponding with any chatroom identification information, it is sent to the user terminal corresponding with the chatroom identification information.
Specifically, poll sending module 1140, is specifically used for:
Acquired chat messages are serialized and compressed, obtain compressed chat messages, and will be compressed Chat messages are sent to corresponding user terminal.
Specifically, a kind of chatroom message distribution device of the embodiment of the present invention, can also include:
Load monitoring module, is used for the load of real-time monitoring server, and it is default to judge whether the load of server is less than Load threshold;Wherein, the load of server includes at least one of following:Processor utilization rate, memory usage and bandwidth occupancy Rate;
Specifically, poll sending module 1140, is specifically used for:
When the load of server is less than default load threshold, according to the first default polling cycle, poll is default to be waited pushing Queue, and according to the chatroom identification information preset in queue to be pushed, obtain from default Hash table and identified with each chatroom The corresponding chat messages of information, and acquired chat messages are sent to corresponding user terminal;
When the load of server is greater than or equal to default load threshold, according to the second default polling cycle, poll is default Queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained and each chat from default Hash table Chat messages corresponding to room identification information, and acquired chat messages are sent to corresponding user terminal.
Specifically, a kind of chatroom message distribution device of the embodiment of the present invention, can also include:
Cleaning modul, for poll sending module by acquired chat messages be sent to corresponding user terminal it Afterwards, cleaning is stored in the chatroom identification information for clearance preset in queue to be pushed;Wherein, chatroom identification information for clearance For the chatroom identification information being not present in default Hash table.
The embodiment of the present invention additionally provides a kind of electronic equipment, as shown in figure 12, including processor 1210, communication interface 1220, memory 1230 and communication bus 1240, wherein processor 1210, communication interface 1220, memory 1230 pass through communication Bus 1240 completes mutual communication,
Memory 1230, for storing computer program;
Processor 1210 when for executing the program stored on memory 1230, realizes following steps:
It determines the message concurrency of the chat messages received, and judges whether message concurrency is greater than or equal to and preset simultaneously Hair amount threshold value;
When message concurrency is greater than or equal to default concurrency threshold value, the chat messages received are stored in default Kazakhstan Uncommon table;
Identification is stored in the chat messages for meeting preset condition in default Hash table, and the satisfaction identified is preset item The corresponding chatroom identification information storage of chat messages of part is in presetting queue to be pushed;
According to default polling cycle, poll presets queue to be pushed, and is marked according to the chatroom preset in queue to be pushed Know information, the chat messages corresponding with each chatroom identification information is obtained from default Hash table, and acquired chat is disappeared Breath is sent to corresponding user terminal.
A kind of electronic equipment provided in an embodiment of the present invention, by determining the message concurrency of the chat messages received, And judge whether message concurrency is greater than or equal to default concurrency threshold value;It is greater than or equal to default concurrency in message concurrency When threshold value, the chat messages received are stored in default Hash table;It is default that identification is stored in the satisfaction in default Hash table The chat messages of condition, and the corresponding chatroom identification information storage of the chat messages for meeting preset condition identified is existed It presets in queue to be pushed;According to default polling cycle, poll presets queue to be pushed, and according in default queue to be pushed Chatroom identification information obtains the chat messages corresponding with each chatroom identification information from default Hash table, and will be acquired Chat messages be sent to corresponding user terminal.It may be implemented in the case where chat messages concurrency is uprushed, ensure service Device normal operation, and reduce the delay that server sends chatroom message.
The communication bus that above-mentioned electronic equipment is mentioned can be Peripheral Component Interconnect standard (Peripheral Component Interconnect, abbreviation PCI) bus or expanding the industrial standard structure (Extended Industry Standard Architecture, abbreviation EISA) bus etc..The communication bus can be divided into address bus, data/address bus, controlling bus etc.. For ease of indicating, only indicated with a thick line in figure, it is not intended that an only bus or a type of bus.
Communication interface is for the communication between above-mentioned electronic equipment and other equipment.
Memory may include random access memory (Random Access Memory, abbreviation RAM), can also include Nonvolatile memory (non-volatile memory), for example, at least a magnetic disk storage.Optionally, memory may be used also To be at least one storage device for being located remotely from aforementioned processor.
Above-mentioned processor can be general processor, including central processing unit (Central Processing Unit, Abbreviation CPU), network processing unit (Network Processor, abbreviation NP) etc.;It can also be digital signal processor (Digital Signal Processing, abbreviation DSP), application-specific integrated circuit (Application Specific Integrated Circuit, abbreviation ASIC), field programmable gate array (Field-Programmable Gate Array, Abbreviation FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hardware components.
In another embodiment provided by the invention, a kind of computer readable storage medium is additionally provided, which can It reads to be stored with instruction in storage medium, when run on a computer so that computer executes any institute in above-described embodiment A kind of chatroom message distributing method stated.
A kind of computer readable storage medium provided in an embodiment of the present invention, by determining disappearing for the chat messages received Concurrency is ceased, and judges whether message concurrency is greater than or equal to default concurrency threshold value;It is greater than or equal in message concurrency When default concurrency threshold value, the chat messages received are stored in default Hash table;Identification is stored in default Hash table The chat messages for meeting preset condition, and the corresponding chatroom of the chat messages for meeting preset condition identified is identified Information storage is in presetting queue to be pushed;According to default polling cycle, poll presets queue to be pushed, and waits pushing away according to default The chatroom identification information in queue is sent, the chat messages corresponding with each chatroom identification information are obtained from default Hash table, And acquired chat messages are sent to corresponding user terminal.It may be implemented the case where chat messages concurrency is uprushed Under, ensure server normal operation, and reduce the delay that server sends chatroom message.
In another embodiment provided by the invention, a kind of computer program product including instruction is additionally provided, when it When running on computers so that computer executes any a kind of chatroom message distributing method in above-described embodiment.
A kind of computer program product including instruction provided in an embodiment of the present invention, by determining that the chat received disappears The message concurrency of breath, and judge whether message concurrency is greater than or equal to default concurrency threshold value;It is more than in message concurrency Or when equal to default concurrency threshold value, the chat messages received are stored in default Hash table;Identification is stored in default Kazakhstan The chat messages for meeting preset condition in uncommon table, and the corresponding chat of the chat messages for meeting preset condition that will be identified Room identification information storage is in presetting queue to be pushed;According to default polling cycle, poll presets queue to be pushed, and according to pre- If the chatroom identification information in queue to be pushed, the chat corresponding with each chatroom identification information is obtained from default Hash table Message, and acquired chat messages are sent to corresponding user terminal.It may be implemented to uprush in chat messages concurrency In the case of, ensure server normal operation, and reduce the delay that server sends chatroom message.
In the above-described embodiments, can come wholly or partly by software, hardware, firmware or its arbitrary combination real It is existing.When implemented in software, it can entirely or partly realize in the form of a computer program product.The computer program Product includes one or more computer instructions.When loading on computers and executing the computer program instructions, all or It partly generates according to the flow or function described in the embodiment of the present invention.The computer can be all-purpose computer, special meter Calculation machine, computer network or other programmable devices.The computer instruction can be stored in computer readable storage medium In, or from a computer readable storage medium to the transmission of another computer readable storage medium, for example, the computer Instruction can pass through wired (such as coaxial cable, optical fiber, number from a web-site, computer, server or data center User's line (DSL)) or wireless (such as infrared, wireless, microwave etc.) mode to another web-site, computer, server or Data center is transmitted.The computer readable storage medium can be any usable medium that computer can access or It is comprising data storage devices such as one or more usable mediums integrated server, data centers.The usable medium can be with It is magnetic medium, (for example, floppy disk, hard disk, tape), optical medium (for example, DVD) or semiconductor medium (such as solid state disk Solid State Disk (SSD)) etc..
It should be noted that herein, relational terms such as first and second and the like are used merely to a reality Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those Element, but also include other elements that are not explicitly listed, or further include for this process, method, article or equipment Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that There is also other identical elements in process, method, article or equipment including the element.
Each embodiment in this specification is all made of relevant mode and describes, identical similar portion between each embodiment Point just to refer each other, and each embodiment focuses on the differences from other embodiments.Especially for system reality For applying example, since it is substantially similar to the method embodiment, so description is fairly simple, related place is referring to embodiment of the method Part explanation.
The foregoing is merely illustrative of the preferred embodiments of the present invention, is not intended to limit the scope of the present invention.It is all Any modification, equivalent replacement, improvement and so within the spirit and principles in the present invention, are all contained in protection scope of the present invention It is interior.

Claims (21)

1. a kind of chatroom message distributing method, which is characterized in that it is applied to server, the method includes:
It determines the message concurrency of the chat messages received, and judges whether the message concurrency is greater than or equal to and preset simultaneously Hair amount threshold value;
When the message concurrency is greater than or equal to the default concurrency threshold value, the chat messages received are stored In default Hash table;
Identification is stored in the chat messages for meeting preset condition in the default Hash table, and the satisfaction identified is preset item The corresponding chatroom identification information storage of chat messages of part is in presetting queue to be pushed;
According to default polling cycle, queue to be pushed is preset described in poll, and according to the chat preset in queue to be pushed Room identification information obtains the chat messages corresponding with each chatroom identification information from the default Hash table, and will be acquired Chat messages be sent to corresponding user terminal.
2. according to the method described in claim 1, it is characterized in that, judging whether the message concurrency is more than or waits described After default concurrency threshold value, the method further includes:
When the message concurrency is less than the default concurrency threshold value, the chat messages received are sent to correspondence User terminal.
3. according to the method described in claim 1, it is characterized in that, it is described the chat messages received are stored in it is default In Hash table, including:
For every chat messages, using the chatroom identification information belonging to the chat messages as keyword, it is with the chat messages Key assignments corresponding with the keyword, which is stored in default Hash table.
4. according to the method described in claim 1, it is characterized in that, the chat messages received are stored in default Kazakhstan After in uncommon table, the method further includes:
Identification is stored in the chat messages that preset condition is unsatisfactory in the default Hash table, by the preset condition that is unsatisfactory for Chat messages are sent to corresponding user terminal.
5. according to the method described in claim 1, it is characterized in that, the preset condition is:It is any in the default Hash table The corresponding chat messages total number in chatroom is less than or equal to default chatroom message bar number threshold value;
Alternatively, the message push waiting time of any chatroom is less than or equal to default waiting time threshold value.
6. according to the method described in claim 1, it is characterized in that, described disappear the chat for meeting preset condition identified Corresponding chatroom identification information storage is ceased in presetting queue to be pushed, including:
By the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified, chatting after modulus is obtained Its room identification information;
By the chatroom identification information storage after the modulus in presetting queue to be pushed.
7. according to the method described in claim 1, it is characterized in that, described according to default polling cycle, preset and wait for described in poll Push queue, and according to it is described preset queue push in chatroom identification information, from the default Hash table obtain and Chat messages corresponding to each chatroom identification information, and acquired chat messages are sent to corresponding user terminal, including:
According to default polling cycle, to preset each chatroom identification information preset described in degree of parallelism poll in queue to be pushed;
From the default Hash table, the chat messages corresponding with each chatroom identification information are obtained, and will be chatted with any Chat messages corresponding to its room identification information, are sent to the user terminal corresponding with the chatroom identification information.
8. according to claim 1-7 any one of them methods, which is characterized in that described to be sent to acquired chat messages Corresponding user terminal includes:
Acquired chat messages are serialized and compressed, obtain compressed chat messages, and will be described compressed Chat messages are sent to corresponding user terminal.
9. according to the method described in claim 1, it is characterized in that, described according to default polling cycle, preset described in poll Before queue to be pushed, the method further includes:
The load of the server is monitored in real time, and judges whether the load of the server is less than default load threshold;Wherein, The load of the server includes at least one of following:Processor utilization rate, memory usage and bandwidth usage;
Correspondingly, it is described according to default polling cycle, queue push is preset described in poll, and according to the default team to be pushed Chatroom identification information in row obtains the chat messages corresponding with each chatroom identification information from the default Hash table, And acquired chat messages are sent to corresponding user terminal, including:
It is pre- described in poll according to the first default polling cycle when the load of the server is less than the default load threshold If queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained from the default Hash table The chat messages corresponding with each chatroom identification information are taken, and acquired chat messages are sent to corresponding user terminal;
When the load of the server is greater than or equal to the default load threshold, according to the second default polling cycle, poll It is described to preset queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, from the default Hash The chat messages corresponding with each chatroom identification information are obtained in table, and acquired chat messages are sent to corresponding user Terminal.
10. according to the method described in claim 1, it is characterized in that, acquired chat messages are sent to correspondence described User terminal after, the method further includes:
Cleaning is stored in the chatroom identification information for clearance preset in queue to be pushed;Wherein, the chat for clearance Room identification information is the chatroom identification information being not present in the default Hash table.
11. a kind of chatroom message distribution device, which is characterized in that be applied to server, described device includes:
Judgment module, the message concurrency for determining the chat messages received, and judge whether the message concurrency is big In or equal to default concurrency threshold value;
Memory module, for when the message concurrency is greater than or equal to the default concurrency threshold value, having been received described Chat messages be stored in default Hash table;
Identification module, the chat messages for meeting preset condition being stored in for identification in the default Hash table, and will be known The corresponding chatroom identification information storage of the chat messages for meeting preset condition not gone out is in presetting queue to be pushed;
Poll sending module is waited for for according to default polling cycle, presetting queue push described in poll, and according to described preset The chatroom identification information in queue is pushed, the chat corresponding with each chatroom identification information is obtained from the default Hash table Message, and acquired chat messages are sent to corresponding user terminal.
12. according to the devices described in claim 11, which is characterized in that described device further includes:
First sending module, for when the message concurrency is less than the default concurrency threshold value, having been received described Chat messages are sent to corresponding user terminal.
13. according to the devices described in claim 11, which is characterized in that the memory module is specifically used for:
For every chat messages, using the chatroom identification information belonging to the chat messages as keyword, it is with the chat messages Key assignments corresponding with the keyword, which is stored in default Hash table.
14. according to the devices described in claim 11, which is characterized in that described device further includes:
Second sending module, the chat messages for being unsatisfactory for preset condition being stored in for identification in the default Hash table will The chat messages for being unsatisfactory for preset condition are sent to corresponding user terminal.
15. according to the devices described in claim 11, which is characterized in that the preset condition is:In the default Hash table, appoint The corresponding chat messages total number in one chatroom is less than or equal to default chatroom message bar number threshold value;
Alternatively, the message push waiting time of any chatroom is less than or equal to default waiting time threshold value.
16. according to the devices described in claim 11, which is characterized in that the identification module is specifically used for:
By the corresponding chatroom identification information modulus of the chat messages for meeting preset condition identified, chatting after modulus is obtained Its room identification information;By the chatroom identification information storage after the modulus in presetting queue to be pushed.
17. according to the devices described in claim 11, which is characterized in that the poll sending module, including:
Poll submodule is used for according to default polling cycle, each in default queue to be pushed described in degree of parallelism poll to preset Chatroom identification information;
Sending submodule disappears for from the default Hash table, obtaining the chat corresponding with each chatroom identification information Breath, and by the chat messages corresponding with any chatroom identification information, it is sent to the user corresponding with the chatroom identification information Terminal.
18. according to claim 11-17 any one of them devices, which is characterized in that the poll sending module, it is specific to use In:
Acquired chat messages are serialized and compressed, obtain compressed chat messages, and will be described compressed Chat messages are sent to corresponding user terminal.
19. according to the devices described in claim 11, which is characterized in that described device further includes:
Load monitoring module, the load for monitoring the server in real time, and judge whether the load of the server is less than Default load threshold;Wherein, the load of the server includes at least one of following:Processor utilization rate, memory usage and Bandwidth usage;
Correspondingly, the poll sending module, is specifically used for:
It is pre- described in poll according to the first default polling cycle when the load of the server is less than the default load threshold If queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, obtained from the default Hash table The chat messages corresponding with each chatroom identification information are taken, and acquired chat messages are sent to corresponding user terminal;
When the load of the server is greater than or equal to the default load threshold, according to the second default polling cycle, poll It is described to preset queue to be pushed, and according to the chatroom identification information preset in queue to be pushed, from the default Hash The chat messages corresponding with each chatroom identification information are obtained in table, and acquired chat messages are sent to corresponding user Terminal.
20. according to the devices described in claim 11, which is characterized in that described device further includes:
Cleaning modul, for the poll sending module by acquired chat messages be sent to corresponding user terminal it Afterwards, cleaning is stored in the chatroom identification information for clearance preset in queue to be pushed;Wherein, the chatroom for clearance Identification information is the chatroom identification information being not present in the default Hash table.
21. a kind of electronic equipment, which is characterized in that including processor, communication interface, memory and communication bus, wherein processing Device, communication interface, memory complete mutual communication by communication bus;
Memory, for storing computer program;
Processor when for executing the program stored on memory, realizes any method and steps of claim 1-10.
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 true CN108418743A (en) 2018-08-17
CN108418743B 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)

Cited By (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
CN112073207A (en) * 2020-11-16 2020-12-11 广州易方信息科技股份有限公司 Method, device and computer equipment for reducing message bandwidth of chat room
CN113316026A (en) * 2021-05-24 2021-08-27 康键信息技术(深圳)有限公司 Barrage message processing method, device, equipment and storage medium
CN113839853A (en) * 2021-08-24 2021-12-24 云智联网络科技(北京)有限公司 High-concurrency chat room message distribution method and device
CN114598894A (en) * 2020-12-03 2022-06-07 北京字节跳动网络技术有限公司 Interactive message processing method, device, equipment and medium

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

Cited By (7)

* 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
CN112073207A (en) * 2020-11-16 2020-12-11 广州易方信息科技股份有限公司 Method, device and computer equipment for reducing message bandwidth of chat room
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
CN113839853A (en) * 2021-08-24 2021-12-24 云智联网络科技(北京)有限公司 High-concurrency chat room message distribution method and device

Also Published As

Publication number Publication date
CN108418743B (en) 2020-10-02

Similar Documents

Publication Publication Date Title
CN108418743A (en) A kind of chatroom message distributing method, device and electronic equipment
CN101252532B (en) Equipment and method for collocating Ethernet link polymerization terminal port
CN106230896A (en) A kind of information push method, Apparatus and system
CN115004673B (en) Message pushing method, device, electronic equipment and computer readable medium
CN106790696B (en) Message transmission method and device
TW200830792A (en) Adaptive polling for bursty wireless data traffic
CN108512727A (en) A kind of determination method and device of central processing unit utilization rate
CN114553799A (en) Multicast forwarding method, device, equipment and medium based on programmable data plane
CN108512743A (en) LAN instant messaging method of servicing, device and electronic equipment
US9392048B2 (en) Method, a system, a server, a device, a computer program and a computer program product for transmitting data in a computer network
De Araujo et al. A publish/subscribe system using causal broadcast over dynamically built spanning trees
CN103312586B (en) A kind of method of instant messaging, system and server
CN114679745A (en) Method, device, equipment and storage medium for terminating wireless sensing measurement process
CN101540722A (en) Method and device for configuring Ethernet trunk aggregation port
CN110597631B (en) Resource management method, monitoring server, proxy server, and storage medium
CN104486443A (en) Message pushing system and method
TW201438435A (en) A method of managing networked devices
CN102624625A (en) QoS (Quality of Service) fair scheduling method for large amount of users
CN101212421B (en) Email pushing method and system
CN108595370A (en) A kind of multi-core processor and message processing method
CN102025730A (en) Data transmission device based on HTTP protocol and implementation method thereof
CN112492019B (en) Message pushing method and device, electronic equipment and storage medium
CN113094002A (en) Message processing method and device, electronic equipment and computer medium
CN113490154A (en) Broadcast data transmission method, device, terminal equipment and storage medium
US8850029B2 (en) System, method, and computer program product for managing at least one aspect of a connection based on application behavior

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