Summary of the invention
The technical problem to be solved in the present invention is to provide the method, the equipment and system that between one kind of multiple viewing equipment, keep synchronously watching record, can respond in time and play reporting and obtaining of record.
The embodiment of the present invention provides the method that between one kind of multiple viewing equipment, record is synchronously watched in maintenance, comprising:
Receive the request of playing record that reports that client sends, described in report and in the request of playing record, carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type;
According to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, the number of described Message Queuing Middleware is at least two;
In described Message Queuing Middleware, be that a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record;
For described broadcasting record generates unique ID, the broadcasting record that carries described unique ID is stored in buffer memory and database.
Preferably, described according to the difference of user ID, before the described request that reports broadcasting to record is sent in the different Message Queuing Middleware of dividing in advance, also comprise:
The broadcasting record request that reports that is pc client by described client type is first kept in thread pool, uses hash to play record request to reporting in described thread pool carry out duplicate removal every the scheduled time.
Preferably, described is that described broadcasting record generates unique ID, is specially:
Use REDIS as distributed I D maker, for described broadcasting record generates the unique ID of the overall situation.
Preferably, also comprise:
Receive client send obtain play record request, described in obtain play record request in carry user ID, video ID and video type;
According to described user ID, from buffer memory, search the list of the video ID that user corresponding to this user ID watch; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again;
By the list of the described video ID that finds, from buffer memory, obtain the broadcasting record of video; If do not have described broadcasting record to obtain from database again in buffer memory;
Described broadcasting record is returned to client.
The embodiment of the present invention also provides between one kind of multiple viewing equipment the equipment that keeps synchronously watching record, comprising: report and play record request receiver module, report and play record request and divide module, play and record duplicate removal module, play Record ID generation module and memory module is recorded in broadcasting;
Described reporting play record request receiver module, for receiving the request of playing record that reports that client sends, described in report to play and carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type in record request;
Described reporting play record request division module, for according to the difference of user ID, by described, reports the request of playing record to send in the different Message Queuing Middleware of dividing in advance, and the number of described Message Queuing Middleware is at least two;
Duplicate removal module is recorded in described broadcasting, at described Message Queuing Middleware, is that a video only retains a record of playing, and that deletes that video ID and special edition ID repeat reports broadcasting record;
Described broadcasting Record ID generation module, is used to described broadcasting record to generate unique ID;
Memory module is recorded in described broadcasting, and the broadcasting record that carries described unique ID is stored in buffer memory and database.
Preferably, also comprise and report broadcasting record request duplicate removal module;
Described reporting play record request duplicate removal module, for the broadcasting record request that reports that is pc client by described client type, is first kept at thread pool, uses hash to play record request to reporting in described thread pool carry out duplicate removal every the scheduled time.
Preferably, described broadcasting Record ID generation module comprises that playing Record ID generates submodule, for using REDIS as distributed I D maker, for described broadcasting record generates the unique ID of the overall situation.
Preferably, also comprise: obtain and play record request receiver module, video ID list is searched module, play and record acquisition module and play record and return to module;
Described obtaining play record request receiver module, for receiving the request of playing record of obtaining that client sends, described in obtain in the request of playing record and carry user ID, video ID and video type;
Module is searched in described video ID list, for search the list of the video ID that user corresponding to this user ID watch from buffer memory according to described user ID; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again;
Acquisition module is recorded in described broadcasting, for the list of the described video ID by finding, obtains the broadcasting record of video from buffer memory; If do not have described broadcasting record to obtain from database again in buffer memory;
Described broadcasting record returns to module, for described broadcasting record is returned to client.
The embodiment of the present invention also provides the system that between one kind of multiple viewing equipment, record is synchronously watched in maintenance, comprising: client, server end;
Described client, for send the request of playing record that reports to described server end, described in report and in the request of playing record, carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type;
Described server end, for according to the difference of user ID, reports the request of playing record to send in the different Message Queuing Middleware of dividing in advance by described, and the number of described Message Queuing Middleware is at least two; In described Message Queuing Middleware, be that a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record; For described broadcasting record generates unique ID, the broadcasting record that carries described unique ID is stored in buffer memory and database.
10, the system that between multiple viewing equipment according to claim 9, record is synchronously watched in maintenance, it is characterized in that, described server end, according to the difference of user ID, before the described request that reports broadcasting to record is sent in the different Message Queuing Middleware of dividing in advance, also comprises:
The broadcasting record request that reports that is pc client by described client type is first kept in thread pool, uses hash to play record request to reporting in described thread pool carry out duplicate removal every the scheduled time.
11, according to the system that keeps between the multiple viewing equipment described in claim 9 or 10 synchronously watching record, it is characterized in that, described client, also for send the request of playing record of obtaining to described server end, described in obtain in the request of playing record and carry user ID, video ID and video type;
Described server end, also for searching the list of the video ID that user corresponding to this user ID watch from buffer memory according to described user ID; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again; By the list of the described video ID that finds, from buffer memory, obtain the broadcasting record of video; If do not have described broadcasting record to obtain from database again in buffer memory; Described broadcasting record is returned to client.
Compared with prior art, the present invention has the following advantages:
Between the multiple viewing equipment that the embodiment of the present invention provides, keep the method for synchronously watching record, according to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, can avoid like this reporting the queue of broadcasting record oversize, thereby the request of customer in response end is accelerated, in addition, for a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record, can reduce like this taking up room of buffer memory or database, and obtain the broadcasting record that can find quickly request when broadcasting is recorded in client, thereby accelerate the response of request.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the present invention's part embodiment, rather than whole embodiment.Based on the embodiment in the present invention, those of ordinary skills, not making the every other embodiment obtaining under creative work prerequisite, belong to the scope of protection of the invention.
For above-mentioned purpose of the present invention, feature and advantage can be become apparent more, below in conjunction with accompanying drawing, the specific embodiment of the present invention is described in detail.
Embodiment of the method one:
Referring to Fig. 1, this figure is embodiment of the method one schematic diagram that keeps synchronously watching record between multiple viewing equipment provided by the invention.
Between the multiple viewing equipment that the present embodiment provides, keep the method for synchronously watching record, comprise the following steps:
S101: receive the request of playing record that reports that client sends, described in report and in the request of playing record, carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type;
It should be noted that, when user uses client to watch video, need to report broadcasting record, play record and comprise video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
Wherein, current reproduction time refers to, and video that user watches is current has watched which second of which point etc.
Wherein, client type can be divided into pc client, and mobile client etc.Mobile client is for example cell-phone customer terminal, PAD client etc.
When user uses the client of PC end to watch video, viewing equipment can regularly report and watch record, for example, every two minutes, report once.When user uses client on mobile phone to watch video, when logging off, viewing equipment can record service end to cloud and report broadcasting record.
Wherein, described in video, special edition refers to the video set that has denominator, and for example certain TV play can be called a special edition, and the video of a TV play belongs in same special edition, but a video may belong to one or more special edition, also may not belong to any special edition.
First client will report broadcasting record request to send to LVS;
LVS will report broadcasting record request to be forwarded on a certain NGINX server according to load balancing.
NGINX, as reverse proxy, will report broadcasting record request to be forwarded to corresponding WEB end server.
S102: according to the difference of user ID, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance by described, the number of described Message Queuing Middleware is at least two;
It should be noted that, described Message Queuing Middleware can be realized by Memcacheq, also can be realized by other Message Queuing Middleware.
Specifically how according to the difference of user ID, to divide to report to play and be recorded in different Memcacheq queues, can set from origin, for example, when two different Memcacheq queues are set, what can be even number by user ID be placed in a Memcacheq queue, and what by user ID, be odd number is placed in another Memcacheq queue.
When three different Memcacheq queues are set, can utilize the algorithm (%3) of the remainder of asking 3, user ID is remmed to 3, is 0,1 and 2 to put into respectively first Memcacheq queue, second Memcacheq queue and the 3rd Memcacheq queue according to remainder.
Be understandable that, when having two Memcacheq queues, also can utilize user ID to rem to 2, remainder is 0 and 1 to put into two different Memcacheq queues, for example, remainder is 0 to put into first Memcacheq queue, and remainder is 1 to put into second Memcacheq queue.
For example user ID is 3438434, can utilize this numerical value to rem to 2.
Be understandable that, first server end can resolve the various information of playing in record request that report of client transmission, and this information comprises video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
It should be noted that, first will report the request of playing record to send in different Message Queuing Middlewares in the embodiment of the present invention, main is like this oversize in order to prevent reporting the request queue of broadcasting record, and server response is too slow.
Be understandable that, the concrete number of Message Queuing Middleware is not specifically limited in embodiments of the present invention, but two of minimum needs, and Message Queuing Middleware and prior art are as broad as long, do not have the effect that prevents that queue is oversize.
S103: in described Message Queuing Middleware, be that a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record;
Because the broadcasting record of reporting of user has a lot, for example, the video that user watches is a TV play, has seen now the 16th collection, and the broadcasting that the 1st collection-15 can be collected record is all deleted, and only retains the broadcasting record of the 16th collection.Because client does not wish to chase after while seeing a TV play, see and oneself play the multiple broadcasting records that have same portion TV play in record.
S104: for described broadcasting record generates unique ID, the broadcasting record that carries described unique ID is stored in buffer memory and database.
Between the multiple viewing equipment that the embodiment of the present invention provides, keep the method for synchronously watching record, according to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, can avoid like this reporting the queue of broadcasting record oversize, thereby the request of customer in response end is accelerated, in addition, for a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record, can reduce like this taking up room of buffer memory or database, and obtain the broadcasting record that can find quickly request when broadcasting is recorded in client, thereby accelerate the response of request.
Embodiment of the method two:
Referring to Fig. 2, this figure is embodiment of the method two schematic diagrames that keep synchronously watching record between multiple viewing equipment provided by the invention.
Due to when client is pc client, because pc client transmission rule is more random, easily there is a lot of repetitions, the very short request that reports broadcasting record interval time, for example, pc client sent and once reports the request of playing record every two minutes, just had so within an hour a large amount of broadcasting records that report.In the present embodiment in order to alleviate the pressure of server end, just send in different Message Queuing Middlewares after reporting the request duplicate removal of playing record at WEB end.
As an example of embodiment of the method two example, describe below.
S201 in the present embodiment is identical with the S101 in embodiment of the method one, does not repeat them here.
S202: judge that according to client type whether client is pc client, if not pc client, carries out S204; If pc client is carried out S203;
S203: the broadcasting record request that reports that is pc client by described client type is first kept in thread pool, is used hash to play record request to reporting in described thread pool every the scheduled time and carries out duplicate removal.
Specifically the mode of duplicate removal is, moves a thread pool that size can be expanded, and in thread pool, each thread has the obstruction queue of oneself, and each obstruction queue is used for preserving the request of playing record that reports of client.Each scheduled time of each thread reports the request of playing record described in going to take out in oneself obstruction queue, uses hash duplicate removal, then reporting after duplicate removal is play to record and carries out the processing of S204.
Particularly, first WEB end selects one not at the thread of operation in thread pool, by playing record from reporting of pc client, sends in the obstruction queue of this thread.
S204 is identical with the S102 in embodiment of the method one, does not repeat them here.
S205: first judge in Message Queuing Middleware whether effectively reporting user ID in the request of playing record and special edition ID whether effective; If effectively,, be that a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record;
S206: use REDIS as distributed ID maker, generate the unique ID of the overall situation for playing record, the broadcasting record that carries described unique ID is stored in buffer memory and database.
Owing to there being multiple servers reporting in processing messages queue middleware, play the request of recording, if generate the method for ID from increasing with ID in traditional database, can impact database, because when request amount is large, peak time the request increment having more than 1,000 per second, very large on the impact of database like this, database faces very large pressure.Therefore, in the present embodiment, adopt REDIS to come to generate unique ID for playing record.
Request in multiple servers while processing messages queue middlewares, can accelerate response speed, the request stacking while avoiding a server process like this.
The advantage of the method that the present embodiment provides is, reporting of pc client play before record request puts into Message Queuing Middleware, first reporting of pc client play to record request and carry out duplicate removal processing, because there is a lot of repetitions, very short request of the time interval in the broadcasting record request that reports that pc client sends, after deleting the request repeating, can alleviate the pressure of server end, thereby accelerate the response time.
It should be noted that, after broadcasting record client being reported at server end is preserved successfully, can return to whether successfully feedback message of preservation with JSON data.
Embodiment of the method three:
Embodiment of the method one and embodiment of the method two report to play with client and are recorded as example and are described, and introduce client obtain to play and be recorded as example and be described below in conjunction with accompanying drawing.
Referring to Fig. 3, this figure is embodiment of the method three schematic diagrames that keep synchronously watching record between multiple viewing equipment provided by the invention.
S301: receive client send obtain play record request, described in obtain play record request in carry user ID, video ID and video type;
It should be noted that, when user initiatively clicks video, explanation is to obtain broadcasting record, and now the client of viewing equipment sends from trend server end the request of playing record of obtaining.
S302: the list of searching the video ID that user corresponding to this user ID watch according to described user ID from buffer memory; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again;
S303: by the list of the described video ID that finds, obtain the broadcasting record of video from buffer memory; If do not have described broadcasting record to obtain from database again in buffer memory;
S304: described broadcasting record is returned to client.
It should be noted that, the embodiment of the present invention provides, and to obtain the method for playing record be on the basis based on embodiment of the method or embodiment of the method two, and server end receives and obtains the broadcasting record that finds this request correspondence after the request of playing record and return to client.
The method of synchronously watching record is provided between the multiple viewing equipment providing based on above embodiment, and the embodiment of the present invention also provides the equipment that keeps synchronously watching record between one kind of multiple viewing equipment, below in conjunction with accompanying drawing, describes in detail.
Referring to Fig. 4, this figure is apparatus embodiments one schematic diagram that keeps synchronously watching record between multiple viewing equipment provided by the invention.
Apparatus embodiments one:
Between the multiple viewing equipment that the embodiment of the present invention provides, the equipment of record is synchronously watched in maintenance, comprising: report and play recordrequest receiver module 400, report broadcasting recordrequest division module 500, broadcasting to recordduplicate removal module 600, broadcasting RecordID generation module 700 and broadcasting andrecord memory module 800;
Report and play recordrequest receiver module 400, for receiving the request of playing record that reports that client sends, described in report to play and carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type in record request;
It should be noted that, when user uses client to watch video, need to report broadcasting record, play record and comprise video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
Wherein, current reproduction time refers to, and video that user watches is current has watched which second of which point etc.
Wherein, client type can be divided into pc client, and mobile client etc.Mobile client is for example cell-phone customer terminal, PAD client etc.
When user uses the client of PC end to watch video, viewing equipment can regularly report and watch record, for example, every two minutes, report once.When user uses client on mobile phone to watch video, when logging off, viewing equipment can record service end to cloud and report broadcasting record.
Wherein, described in video, special edition refers to the video set that has denominator, and for example certain TV play can be called a special edition, and the video of a TV play belongs in same special edition, but a video may belong to one or more special edition, also may not belong to any special edition.
First client will report broadcasting record request to send to LVS;
LVS will report broadcasting record request to be forwarded on a certain NGINX server according to load balancing.
NGINX, as reverse proxy, will report broadcasting record request to be forwarded to corresponding WEB end server.
Report and play recordrequest division module 500, for according to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, the number of described Message Queuing Middleware is at least two;
Be understandable that, first server end can resolve the various information of playing in record request that report of client transmission, and this information comprises video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
It should be noted that, described Message Queuing Middleware can be realized by Memcacheq, also can be realized by other Message Queuing Middleware.
Specifically how according to the difference of user ID, to divide to report to play and be recorded in different Memcacheq queues, can set from origin, for example, when two different Memcacheq queues are set, what can be even number by user ID be placed in a Memcacheq queue, and what by user ID, be odd number is placed in another Memcacheq queue.
When three different Memcacheq queues are set, can utilize the algorithm (%3) of the remainder of asking 3, user ID is remmed to 3, is 0,1 and 2 to put into respectively first Memcacheq queue, second Memcacheq queue and the 3rd Memcacheq queue according to remainder.
Be understandable that, when having two Memcacheq queues, also can utilize user ID to rem to 2, remainder is 0 and 1 to put into two different Memcacheq queues, for example, remainder is 0 to put into first Memcacheq queue, and remainder is 1 to put into second Memcacheq queue.
For example user ID is 3438434, can utilize this numerical value to rem to 2.
It should be noted that, first will report the request of playing record to send in different Message Queuing Middlewares in the embodiment of the present invention, main is like this oversize in order to prevent reporting the request queue of broadcasting record, and server response is too slow.
Be understandable that, the concrete number of Message Queuing Middleware is not specifically limited in embodiments of the present invention, but two of minimum needs, and Message Queuing Middleware and prior art are as broad as long, do not have the effect that prevents that queue is oversize.
Duplicate removal module 600 is recorded in broadcasting, at described Message Queuing Middleware, is that a video only retains a record of playing, and that deletes that video ID and special edition ID repeat reports broadcasting record;
Because the broadcasting record of reporting of user has a lot, for example, the video that user watches is a TV play, has seen now the 16th collection, and the broadcasting that the 1st collection-15 can be collected record is all deleted, and only retains the broadcasting record of the 16th collection.Because client does not wish to chase after while seeing a TV play, see and oneself play the multiple broadcasting records that have same portion TV play in record.
Play RecordID generation module 700, be used to described broadcasting record to generate unique ID;
Memory module 800 is recorded in broadcasting, and the broadcasting record that carries described unique ID is stored in buffer memory and database.
Between the multiple viewing equipment that the embodiment of the present invention provides, keep synchronously watching the equipment of record, according to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, can avoid like this reporting the queue of broadcasting record oversize, thereby the request of customer in response end is accelerated, in addition, for a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record, can reduce like this taking up room of buffer memory or database, and obtain the broadcasting record that can find quickly request when broadcasting is recorded in client, thereby accelerate the response of request.
Apparatus embodiments two:
Referring to Fig. 5, this figure is apparatus embodiments two schematic diagrames that keep synchronously watching record between multiple viewing equipment provided by the invention.
Due to when client is pc client, because pc client transmission rule is more random, easily there is a lot of repetitions, the very short request that reports broadcasting record interval time, for example, pc client sent and once reports the request of playing record every two minutes, just had so within an hour a large amount of broadcasting records that report.In the present embodiment in order to alleviate the pressure of server end, just send in different Message Queuing Middlewares after reporting the request duplicate removal of playing record at WEB end.
As an example of apparatus embodiments two example, describe below.
The equipment that the present embodiment provides, also comprises reporting and plays record requestduplicate removal module 900;
Described reporting play record requestduplicate removal module 900, for the broadcasting record request that reports that is pc client by described client type, is first kept at thread pool, uses hash to play record request to reporting in described thread pool carry out duplicate removal every the scheduled time.
Specifically the mode of duplicate removal is, moves a thread pool that size can be expanded, and in thread pool, each thread has the obstruction queue of oneself, and each obstruction queue is used for preserving the request of playing record that reports of client.Each scheduled time of each thread reports the request of playing record described in going to take out in oneself obstruction queue, uses hash duplicate removal, then reporting after duplicate removal is play to record and carries out the processing of S204.
Particularly, first WEB end selects one not at the thread of operation in thread pool, by playing record from reporting of pc client, sends in the obstruction queue of this thread.
In the present embodiment, described broadcasting RecordID generation module 700 comprises that playing Record ID generates submodule 700a, for using REDIS as distributed I D maker, for described broadcasting record generates the unique ID of the overall situation.
Owing to there being multiple servers reporting in processing messages queue middleware, play the request of recording, if generate the method for ID from increasing with ID in traditional database, can impact database, therefore, in the present embodiment, adopt REDIS to come to generate unique ID for playing record.
The advantage of the equipment that the present embodiment provides is, reporting of pc client play before record request puts into Message Queuing Middleware, first reporting of pc client play to record request and carry out duplicate removal processing, because there is a lot of repetitions, very short request of the time interval in the broadcasting record request that reports that pc client sends, after deleting the request repeating, can alleviate the pressure of server end, thereby accelerate the response time.
It should be noted that, after broadcasting record client being reported at server end is preserved successfully, can return to whether successfully feedback message of preservation with JSON data.
Apparatus embodiments three:
Referring to Fig. 6, this figure is apparatus embodiments three schematic diagrames that keep synchronously watching record between multiple viewing equipment provided by the invention.
Embodiment of the method one and embodiment of the method two report to play with client and are recorded as example and are described, and introduce client obtain to play and be recorded as example and be described below in conjunction with accompanying drawing.
Between the multiple viewing equipment that the present embodiment provides, keep synchronously watching the equipment of record, also comprise: obtain and play recordrequest receiver module 100, video ID list is searchedmodule 200, play andrecord acquisition module 300 and play record and return tomodule 400;
Described obtaining play recordrequest receiver module 100, for receiving the request of playing record of obtaining that client sends, described in obtain in the request of playing record and carry user ID, video ID and video type;
It should be noted that, when user initiatively clicks video, explanation is to obtain broadcasting record, and now the client of viewing equipment sends from trend server end the request of playing record of obtaining.
Module 200 is searched in described video ID list, for search the list of the video ID that user corresponding to this user ID watch from buffer memory according to described user ID; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again;
Acquisition module 300 is recorded in described broadcasting, for the list of the described video ID by finding, obtains the broadcasting record of video from buffer memory; If do not have described broadcasting record to obtain from database again in buffer memory;
Described broadcasting record returns tomodule 400, for described broadcasting record is returned to client.
It should be noted that, the embodiment of the present invention provides, and to obtain the method for playing record be on the basis based on embodiment of the method or embodiment of the method two, and server end receives and obtains the broadcasting record that finds this request correspondence after the request of playing record and return to client.
Between one kind of multiple viewing equipment that provide based on above embodiment, keep synchronously watching the method and apparatus of record, the embodiment of the present invention also provides the system that between one kind of multiple viewing equipment, record is synchronously watched in maintenance, below in conjunction with accompanying drawing, is described in detail.
System embodiment one:
Referring to Fig. 7, this figure is system embodiment one schematic diagram that keeps synchronously watching record between multiple viewing equipment provided by the invention.
This enforcement provides the system that between one kind of multiple viewing equipment, record is synchronously watched in maintenance, comprising:client 1000,server end 2000;
Describedclient 1000, for sending to describedserver end 2000 request of playing record that reports, described in report and in the request of playing record, carry special edition ID under video ID, user ID, current reproduction time, video, video type and client type;
It should be noted that, when user usesclient sight 1000 to see video, need to report broadcasting record, play record and comprise video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
Wherein, current reproduction time refers to, and video that user watches is current has watched which second of which point etc.
Wherein, client type can be divided into pc client, and mobile client etc.Mobile client is for example cell-phone customer terminal, PAD client etc.
When user uses pc client to watch video, viewing equipment can regularly report and watch record, for example, every two minutes, report once.When user uses client on mobile phone to watch video, when logging off, viewing equipment can record service end to cloud and report broadcasting record.
Wherein, described in video, special edition refers to the video set that has denominator, and for example certain TV play can be called a special edition, and the video of a TV play belongs in same special edition, but a video may belong to one or more special edition, also may not belong to any special edition.
First client 1000 will report broadcasting record request to send to LVS;
LVS will report broadcasting record request to be forwarded on a certain NGINX server according to load balancing.
NGINX, as reverse proxy, will report broadcasting record request to be forwarded to corresponding WEB end server.
Describedserver end 2000, for according to the difference of user ID, reports the request of playing record to send in the different Message Queuing Middleware of dividing in advance by described, and the number of described Message Queuing Middleware is at least two; In described Message Queuing Middleware, be that a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record; For described broadcasting record generates unique ID, the broadcasting record that carries described unique ID is stored in buffer memory and database.
It should be noted that, described Message Queuing Middleware can be realized by Memcacheq, also can be realized by other Message Queuing Middleware.
Specifically how according to the difference of user ID, to divide to report to play and be recorded in different Memcacheq queues, can set from origin, for example, when two different Memcacheq queues are set, what can be even number by user ID be placed in a Memcacheq queue, and what by user ID, be odd number is placed in another Memcacheq queue.
When three different Memcacheq queues are set, can utilize the algorithm (%3) of the remainder of asking 3, user ID is remmed to 3, is 0,1 and 2 to put into respectively first Memcacheq queue, second Memcacheq queue and the 3rd Memcacheq queue according to remainder.
Be understandable that, when having two Memcacheq queues, also can utilize user ID to rem to 2, remainder is 0 and 1 to put into two different Memcacheq queues, for example, remainder is 0 to put into first Memcacheq queue, and remainder is 1 to put into second Memcacheq queue.
For example user ID is 3438434, can utilize this numerical value to rem to 2.
Be understandable that, first server end can resolve the various information of playing in record request that report of client transmission, and this information comprises video ID, user ID, current reproduction time.Special edition ID, video type and client type described in video;
It should be noted that, first will report the request of playing record to send in different Message Queuing Middlewares in the embodiment of the present invention, main is like this oversize in order to prevent reporting the request queue of broadcasting record, and server response is too slow.
Be understandable that, the concrete number of Message Queuing Middleware is not specifically limited in embodiments of the present invention, but two of minimum needs, and Message Queuing Middleware and prior art are as broad as long, do not have the effect that prevents that queue is oversize.
Because the broadcasting record of reporting of user has a lot, for example, the video that user watches is a TV play, has seen now the 16th collection, and the broadcasting that the 1st collection-15 can be collected record is all deleted, and only retains the broadcasting record of the 16th collection.Because client does not wish to chase after while seeing a TV play, see and oneself play the multiple broadcasting records that have same portion TV play in record.
Between the multiple viewing equipment that the embodiment of the present invention provides, keep the system of synchronously watching record, according to the difference of user ID, by described, report the request of playing record to send in the different Message Queuing Middleware of dividing in advance, can avoid like this reporting the queue of broadcasting record oversize, thereby the request of customer in response end is accelerated, in addition, for a video only retains a record of playing, that deletes that video ID and special edition ID repeat reports broadcasting record, can reduce like this taking up room of buffer memory or database, and obtain the broadcasting record that can find quickly request when broadcasting is recorded in client, thereby accelerate the response of request.
System embodiment two:
The system that the present embodiment provides, describedserver end 2000, according to the difference of user ID, before the described request that reports broadcasting to record is sent in the different Message Queuing Middleware of dividing in advance, also comprises:
The broadcasting record request that reports that is pc client by described client type is first kept in thread pool, uses hash to play record request to reporting in described thread pool carry out duplicate removal every the scheduled time.
Due to when client is pc client, because pc client transmission rule is more random, easily there is a lot of repetitions, the very short request that reports broadcasting record interval time, for example, pc client sent and once reports the request of playing record every two minutes, just had so within an hour a large amount of broadcasting records that report.In the present embodiment in order to alleviate the pressure of server end, just send in different Message Queuing Middlewares after reporting the request duplicate removal of playing record at WEB end.
Specifically the mode of duplicate removal is, moves a thread pool that size can be expanded, and in thread pool, each thread has the obstruction queue of oneself, and each obstruction queue is used for preserving the request of playing record that reports of client.Each scheduled time of each thread reports the request of playing record described in going to take out in oneself obstruction queue, uses hash duplicate removal.
Owing to there being multiple servers reporting in processing messages queue middleware, play the request of recording, if generate the method for ID from increasing with ID in traditional database, can impact database, therefore, in the present embodiment, adopt REDIS to come to generate unique ID for playing record.
The advantage of the system that the present embodiment provides is, reporting of pc client play before record request puts into Message Queuing Middleware, first reporting of pc client play to record request and carry out duplicate removal processing, because there is a lot of repetitions, very short request of the time interval in the broadcasting record request that reports that pc client sends, after deleting the request repeating, can alleviate the pressure of server end, thereby accelerate the response time.
It should be noted that, after broadcasting record client being reported at server end is preserved successfully, can return to whether successfully feedback message of preservation with JSON data.
Above embodiment reports to play with client and is recorded as example and is described, and introduces client below and obtains to play and be recorded as example and be described.
Describedclient 1000, also for sending to describedserver end 2000 request of playing record of obtaining, described in obtain in the request of playing record and carry user ID, video ID and video type;
Describedserver end 2000, also for searching the list of the video ID that user corresponding to this user ID watch from buffer memory according to described user ID; If search the list of the video ID watching less than user corresponding to this user ID in buffer memory searches from database again; By the list of the described video ID that finds, from buffer memory, obtain the broadcasting record of video; If do not have described broadcasting record to obtain from database again in buffer memory; Described broadcasting record is returned to client.
The method, apparatus and system that the above embodiment of the present invention provides, the comparatively fast request of customer in response end can realize user and play the synchronous of record between multiple terminals.
The above, be only preferred embodiment of the present invention, not the present invention done to any pro forma restriction.Although the present invention discloses as above with preferred embodiment, but not in order to limit the present invention.Any those of ordinary skill in the art, do not departing from technical solution of the present invention scope situation, all can utilize method and the technology contents of above-mentioned announcement to make many possible variations and modification to technical solution of the present invention, or be revised as the equivalent embodiment of equivalent variations.Therefore, every content that does not depart from technical solution of the present invention,, all still belongs in the scope of technical solution of the present invention protection any simple modification made for any of the above embodiments, equivalent variations and modification according to technical spirit of the present invention.