Playback record processing method and related device
By sending the user's playback record message to the Pulsar message queue and performing aggregation processing, routing it to the message consumer based on the key-shared subscription model, the problem of high write pressure caused by playback record processing in the prior art is solved, and the more Low database write frequency and higher processing efficiency.
Patent Information
- Application Number
- CN202111646052.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-29
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2041-12-29
AI Technical Summary
In the prior art, the user's playback record processing adopts two methods: heartbeat reporting and playback event reporting, resulting in a very large amount of service requests for playback record, resulting in excessive writing pressure on back-end data services and databases.
By obtaining the user's playback record message and sending it to the message subscription system Pulsar, it is stored in the message queue in chronological order in the current time window. Aggregation processing is performed for the same set of play record messages to form a play record aggregate message. Based on the key-shared subscription model, the aggregated messages are routed to multiple message consumers, using the user's unique identity as the key.
By aggregating the recording messages, the number of writes to the database is reduced and the writing pressure of back-end data services and databases is reduced. At the same time, concurrent writes to the database by the same user are avoided, row lock competition is reduced, and write pressure is reduced.
Smart Images

Figure CN114302186B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of video, and in particular to a playback recording processing method and a related device. Background Art
[0002] Currently, user playback records are processed in two ways: user heartbeat reporting and user playback event reporting. The result of these two methods is that the service request volume for playback records is very large, which is a typical scenario of more writes and less reads, and the write pressure on the backend data service and database is very high. Summary of the invention
[0003] In view of the above problems, the present invention provides a playback record processing method and related devices that overcome the above problems or at least partially solve the above problems.
[0004] In a first aspect, a playback record processing method includes:
[0005] Get the user's video playback record information;
[0006] Sending each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order;
[0007] For any group of the play record messages, the following steps are performed: according to the time sequence of the play record messages in the message queue, aggregating multiple play record messages of the same group within the current time window to obtain a play record aggregate message, wherein the play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes multiple play record messages;
[0008] Based on the key-shared subscription mode, each of the play record aggregate messages is routed to multiple message consumers, wherein each of the play record aggregate messages uses the unique identifier of the corresponding user as the corresponding key in the key-shared subscription mode.
[0009] In combination with the first aspect, in some optional implementations, routing each of the playback record aggregation messages to multiple message consumers based on the key-shared subscription mode includes:
[0010] Based on the key-shared subscription mode, the play record aggregate messages with the same key are routed to the same message consumer, and the play record aggregate messages with different keys are routed to different message consumers.
[0011] In combination with the first aspect, in some optional implementations, aggregating multiple play record messages of the same group in the current time window to obtain a play record aggregate message according to the time sequence of each play record message in the message queue includes:
[0012] According to the time sequence of the play record messages in the message queue, the latest play record message in the same group within the current time window is used as the corresponding play record aggregate message.
[0013] In combination with the first aspect, in some optional implementations, obtaining a user's playback record message for a video includes:
[0014] Obtaining heartbeat data reported by the user, wherein the heartbeat data is request data sent by the user regarding video playback progress;
[0015] The heartbeat data is verified, and if the verification passes, a corresponding play record message is generated according to the heartbeat data, thereby obtaining the play record message.
[0016] In a second aspect, a playback record processing device includes: a message obtaining unit, a message queue unit, an aggregation unit, and a message routing unit;
[0017] The message obtaining unit is used to obtain the user's playback record message for the video;
[0018] The message queue unit is used to send each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order;
[0019] The aggregation unit is used to perform, for any group of the play record messages: according to the time sequence of each of the play record messages in the message queue, aggregating multiple play record messages of the same group in the current time window to obtain a play record aggregation message, wherein the play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes multiple play record messages;
[0020] The message routing unit is used to route each of the play record aggregate messages to multiple message consumers based on a key-shared subscription mode, wherein each of the play record aggregate messages uses a unique identifier of a corresponding user as a corresponding key in the key-shared subscription mode.
[0021] In conjunction with the second aspect, in some optional implementations, the message routing unit includes: a message routing subunit;
[0022] The message routing subunit is used to route the play record aggregation messages with the same key to the same message consumer based on the key-shared subscription mode, and to route the play record aggregation messages with different keys to different message consumers.
[0023] In conjunction with the second aspect, in certain optional embodiments, the polymerization unit includes: a polymerization subunit;
[0024] The aggregation subunit is used to use the latest playback record message in the same group within the current time window as the corresponding playback record aggregation message according to the time sequence of the playback record messages in the message queue.
[0025] In conjunction with the second aspect, in some optional implementations, the message obtaining unit includes: a heartbeat data subunit and a message generating subunit;
[0026] The heartbeat data subunit is used to obtain the heartbeat data reported by the user, wherein the heartbeat data is the request data sent by the user regarding the video playback progress;
[0027] The message generation subunit is used to verify the heartbeat data, and if the verification passes, generate a corresponding play record message according to the heartbeat data, thereby obtaining the play record message.
[0028] In a third aspect, a computer-readable storage medium stores a program, and when the program is executed by a processor, the playback record processing method described in any one of the above items is implemented.
[0029] In a fourth aspect, an electronic device comprises at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; and the processor is used to call program instructions in the memory to execute any one of the playback record processing methods described above.
[0030] By means of the above technical scheme, the playback record processing method and related device provided by the present invention can obtain the playback record message of the user for the video; send each of the playback record messages to the message subscription system pulsar, so that each of the playback record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order; for any group of the playback record messages, all execute: according to the time sequence of each of the playback record messages in the message queue, a plurality of the playback record messages of the same group in the current time window are aggregated to obtain a playback record aggregate message, wherein the playback record messages of the same user for the same video are divided into the same group, and the playback record messages of different users or different videos are divided into different groups, and each group of the playback record messages includes a plurality of the playback record messages; based on the key-shared subscription mode, each of the playback record aggregate messages is routed to multiple message consumers, wherein each of the playback record aggregate messages uses the unique identifier of the corresponding user as the corresponding key in the key-shared subscription mode. It can be seen from this that the present invention can aggregate multiple playback record messages of the user into one, thereby reducing the number of writes to the database and reducing the write pressure of the back-end data service and database. At the same time, by routing the playback record aggregation messages of the same user to the same message consumer, concurrent writing to the database by the same user is avoided, row lock competition is avoided, and the writing pressure on the back-end data service and database is reduced to a certain extent.
[0031] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0033] Figure 1 The present invention provides a flowchart of a playback record processing method;
[0034] Figure 2 The present invention provides a signaling diagram of a playback record processing method;
[0035] Figure 3 The present invention provides a schematic structural diagram of a playback and recording processing device;
[0036] Figure 4 A schematic structural diagram of an electronic device provided by the present invention is shown. DETAILED DESCRIPTION
[0037] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0038] like Figure 1 As shown, the present invention provides a playback record processing method, including: S100, S200, S300 and S400;
[0039] S100, obtaining a user's video playback record message;
[0040] Optionally, the execution subject of the present invention can obtain the playback record messages of multiple users for multiple videos, one user can correspond to multiple videos, and one video can correspond to multiple playback record messages. For example, the present invention can obtain multiple playback record messages of Zhang San for video 1, and can also obtain multiple playback record messages of Zhang San for video 2, and can also obtain multiple playback record messages of Li Si for video 1, and the present invention does not limit this.
[0041] Optionally, in combination with actual conditions, a specific user may have multiple play records for the same video, but generally only the last play record has reference value. Therefore, the present invention can obtain multiple play record messages to facilitate subsequent aggregation and find play records with reference value.
[0042] Optionally, the present invention does not limit the process of obtaining the user's video playback record message, and any feasible method belongs to the protection scope of the present invention. Figure 1 In the embodiment shown, in some optional embodiments, the S100 includes: step 1.1 and step 1.2;
[0043] Step 1.1, obtaining the heartbeat data reported by the user, wherein the heartbeat data is the request data sent by the user regarding the video playback progress;
[0044] Step 1.2: verify the heartbeat data. If the verification passes, generate a corresponding play record message according to the heartbeat data, thereby obtaining the play record message.
[0045] Optionally, any user may send request data about the video playback progress to the server at fixed time intervals to report the user's viewing progress, and the present invention does not impose any limitation on this.
[0046] Optionally, the process of verifying the heartbeat data belongs to the prior art in this field, and the present invention will not elaborate on this. For details, please refer to the relevant description in this field.
[0047] Optionally, if the check fails, the heartbeat data is not processed, and a notification of check failure or check error may be returned to the user, which is not limited in the present invention.
[0048] Optionally, the present invention does not limit the process of generating a corresponding play record message according to the heartbeat data. For example, required information is extracted from the heartbeat data, and the extracted information is packaged into a corresponding play record message according to a preset packaging method, and one heartbeat data corresponds to one play record message.
[0049] S200, sending each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order;
[0050] Optionally, Pulsar is a distributed message publishing / subscribing delivery platform, which is a well-known technology in the art. The present invention will not elaborate on this in detail. Please refer to the relevant description of the field for details.
[0051] The present invention can partition pulsar. Different partitions correspond to different time windows, and each time window has multiple message queue channels, so as to concurrently receive playback record messages of different users and improve efficiency.
[0052] Optionally, the play record messages of the same user are sent to the same message queue channel and stored in chronological order, which is not limited in the present invention.
[0053] Optionally, the present invention does not impose any specific restrictions on the division of time windows, and can be divided according to actual needs. For example, 5 minutes is used as a time window, and 1 hour is divided into 12 time windows, so that the playback record messages in each time window can be processed in units of time windows later.
[0054] S300, for any group of the play record messages, executing: according to the time sequence of the play record messages in the message queue, aggregating multiple play record messages of the same group within the current time window to obtain a play record aggregate message;
[0055] The play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes a plurality of the play record messages;
[0056] Optionally, as mentioned above, the same user may have multiple play record messages for the same video in the same time window. However, generally speaking, the latest play record message in the time window has reference value, that is, it is the most effective. Therefore, the play record messages can be grouped and processed, and the play record messages of the same user for the same video can be divided into the same group, and the multiple play record messages in each group can be aggregated to obtain a play record aggregate message, so as to discard invalid play record messages, thereby reducing the number of messages, and then reducing the number of times the messages are subsequently written to the database.
[0057] Optionally, the present invention does not limit the specific process of polymerization, and any feasible method belongs to the protection scope of the present invention. Figure 1 In the illustrated implementation, in certain optional implementations, the S300 includes: according to the time sequence of each of the play record messages in the message queue, taking the latest play record message in the same group within the current time window as the corresponding play record aggregate message.
[0058] Optionally, the latest play record message of a specific group within the current time window is used as the corresponding play record aggregation message, or the corresponding play record aggregation message is generated according to the latest play record message to achieve aggregation, which is more in line with actual conditions and has better effects.
[0059] S400, based on the key-shared subscription mode, routing the playback record aggregation message to multiple message consumers;
[0060] Among them, each of the playback record aggregate messages uses the unique identifier of the corresponding user as the corresponding key in the key-shared subscription mode.
[0061] Optionally, the key-shared subscription mode is a well-known technology in the art, which is not described in detail in the present invention. For details, please refer to the relevant description in the art.
[0062] Optionally, message consumers and keys are also well-known concepts in the key-shared subscription model. For details, please refer to the description of concepts such as message consumers, message producers, and keys in the key-shared subscription model.
[0063] Optionally, in the key-shared subscription mode, different objects are distinguished by keys. Here, the objects may be users. By using the user's unique identifier as the corresponding key, different users can be accurately distinguished, so that the playback record aggregation messages of different users can be provided to the corresponding message consumers for consumption.
[0064] Optionally, taking Mango TV as an example, Mango TV sets corresponding user IDs for different users as the unique identifier of the user within Mango TV. The present invention can use the user ID as the corresponding key, and the present invention does not limit this.
[0065] Optionally, the playback record aggregate message is routed to a corresponding message consumer so that the message consumer can consume the corresponding playback record aggregate message. The message consumer can update its own stored data related to the playback record according to the playback record aggregate message, and can also update the data in a storage unit such as a database or memory of the message consumer.
[0066] Optionally, the present invention does not limit the manner in which the play record aggregate message is routed to multiple message consumers. Figure 1 In the illustrated implementation, in certain optional implementations, the S400 includes: based on the key-shared subscription mode, routing the play record aggregate messages with the same key to the same message consumer, and routing the play record aggregate messages with different keys to different message consumers.
[0067] Optionally, in practice, a user can log in and watch videos on multiple clients, and the server generally adopts a distributed approach, that is, different clients may correspond to different servers, which easily leads to the same user writing the same video to the database concurrently on different servers, causing row lock contention, and thus affecting the processing capacity of the playback records. Therefore, by routing the playback record aggregation message with the same key to the same message consumer, no matter which client the user is watching, the corresponding playback record aggregation message will only be written to the database through one service, thereby avoiding row lock contention.
[0068] Optionally, row lock contention is a well-known concept in the art, and please refer to the relevant description in the art for details.
[0069] Optionally, in order to further clarify the solution of the present invention, the present invention provides the following Figure 2 The signaling diagram shown in the figure is used to illustrate the scheme of the present invention as a whole. Figure 2 The consumer in the message is the message consumer mentioned in this article, and DB is the storage unit mentioned in this article.
[0070] like Figure 3 As shown, the present invention provides a playback record processing device, comprising: a message obtaining unit 100, a message queue unit 200, an aggregation unit 300 and a message routing unit 400;
[0071] The message obtaining unit 100 is used to obtain the user's playback record message for the video;
[0072] The message queue unit 200 is used to send each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order;
[0073] The aggregation unit 300 is used to perform, for any group of the play record messages, the following steps: according to the time sequence of the play record messages in the message queue, aggregating multiple play record messages of the same group in the current time window to obtain a play record aggregation message, wherein the play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes multiple play record messages;
[0074] The message routing unit 400 is used to route each of the play record aggregate messages to multiple message consumers based on a key-shared subscription mode, wherein each of the play record aggregate messages uses a unique identifier of a corresponding user as a corresponding key in the key-shared subscription mode.
[0075] Combination Figure 3 In the illustrated implementation, in certain optional implementations, the message routing unit 400 includes: a message routing subunit;
[0076] The message routing subunit is used to route the play record aggregation messages with the same key to the same message consumer based on the key-shared subscription mode, and to route the play record aggregation messages with different keys to different message consumers.
[0077] Combination Figure 3 In the illustrated embodiment, in certain optional embodiments, the polymerization unit 300 includes: a polymerization subunit;
[0078] The aggregation subunit is used to use the latest playback record message in the same group within the current time window as the corresponding playback record aggregation message according to the time sequence of the playback record messages in the message queue.
[0079] Combination Figure 3 In the illustrated implementation, in certain optional implementations, the message obtaining unit 100 includes: a heartbeat data subunit and a message generating subunit;
[0080] The heartbeat data subunit is used to obtain the heartbeat data reported by the user, wherein the heartbeat data is the request data sent by the user regarding the video playback progress;
[0081] The message generation subunit is used to verify the heartbeat data, and if the verification passes, generate a corresponding play record message according to the heartbeat data, thereby obtaining the play record message.
[0082] The present invention provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, any of the above-mentioned playback record processing methods is implemented.
[0083] like Figure 4 As shown, the present invention provides an electronic device 70, which includes at least one processor 701, and at least one memory 702 and a bus 703 connected to the processor 701; wherein the processor 701 and the memory 702 communicate with each other through the bus 703; the processor 701 is used to call the program instructions in the memory 702 to execute any of the above-mentioned playback record processing methods.
[0084] In this application, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0085] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0086] The above description of the disclosed embodiments enables one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
[0087] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A playback record processing method, characterized in that: include: Get the user's video playback record information; Send each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order, the message subscription system pulsar is partitioned, different partitions correspond to different time windows, and each time window has multiple message queue channels; For any group of the play record messages, the following steps are performed: according to the time sequence of the play record messages in the message queue, aggregating multiple play record messages of the same group within the current time window to obtain a play record aggregate message, wherein the play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes multiple play record messages; Based on the key-shared subscription mode, the play record aggregate messages with the same key are routed to the same message consumer, and the play record aggregate messages with different keys are routed to different message consumers, wherein each play record aggregate message uses the unique identifier of the corresponding user as the corresponding key in the key-shared subscription mode.
2. The method according to claim 1, characterized in that: The step of aggregating a plurality of the play record messages of the same group within the current time window to obtain a play record aggregate message according to the time sequence of the play record messages in the message queue includes: According to the time sequence of the play record messages in the message queue, the latest play record message in the same group within the current time window is used as the corresponding play record aggregate message.
3. The method according to claim 1, characterized in that The obtaining of the user's video playback record message includes: Obtaining heartbeat data reported by the user, wherein the heartbeat data is request data sent by the user regarding video playback progress; The heartbeat data is verified, and if the verification passes, a corresponding play record message is generated according to the heartbeat data, thereby obtaining the play record message.
4. A playback and recording processing device, characterized in that: include: Message acquisition unit, message queue unit, aggregation unit and message routing unit; The message obtaining unit is used to obtain the user's playback record message for the video; The message queue unit is used to send each of the play record messages to the message subscription system pulsar, so that each of the play record messages is sequentially stored in the message queue of the current time window of the message subscription system pulsar in chronological order. The message subscription system pulsar is partitioned, and different partitions correspond to different time windows. Each time window has multiple message queue channels; The aggregation unit is used to perform, for any group of the play record messages: according to the time sequence of each of the play record messages in the message queue, aggregating multiple play record messages of the same group in the current time window to obtain a play record aggregation message, wherein the play record messages of the same user for the same video are divided into the same group, and the play record messages of different users or different videos are divided into different groups, and each group of the play record messages includes multiple play record messages; The message routing unit is used to route each of the play record aggregate messages to multiple message consumers based on a key-shared subscription mode, wherein each of the play record aggregate messages uses a unique identifier of a corresponding user as a corresponding key in the key-shared subscription mode; The message routing unit comprises: a message routing subunit; The message routing subunit is used to route the play record aggregation messages with the same key to the same message consumer based on the key-shared subscription mode, and to route the play record aggregation messages with different keys to different message consumers.
5. The device according to claim 4, characterized in that The polymerization unit comprises: a polymerization subunit; The aggregation subunit is used to use the latest playback record message in the same group within the current time window as the corresponding playback record aggregation message according to the time sequence of the playback record messages in the message queue.
6. The device according to claim 4, characterized in that The message obtaining unit comprises: a heartbeat data subunit and a message generating subunit; The heartbeat data subunit is used to obtain the heartbeat data reported by the user, wherein the heartbeat data is the request data sent by the user regarding the video playback progress; The message generation subunit is used to verify the heartbeat data, and if the verification passes, generate a corresponding play record message according to the heartbeat data, thereby obtaining the play record message.
7. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the playback record processing method according to any one of claims 1 to 3 is implemented.
8. An electronic device, characterized in that: The electronic device includes at least one processor, and at least one memory and a bus connected to the processor; wherein the processor and the memory communicate with each other via the bus; the processor is used to call program instructions in the memory to execute the playback record processing method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Method, device and system for keeping synchronous watching record among multiple film watching devices
CN103731682A