Real-time data pushing method and system based on database
By detecting data changes in the database and actively pushing them, and combining third-party services for real-time data updates, the problem of database pressure and untimely data push is solved, and users' real-time data updates and resource efficiency are improved.
Patent Information
- Application Number
- CN202410715910.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-04
- Publication Date
- 2024-08-30
AI Technical Summary
In the existing technology, when users subscribe to data, frequent database queries cause database performance to decrease, increase pressure, cause resource waste and untimely data push, and affect user experience.
By building the table corresponding to the product in the database, detecting data changes, and actively pushing business data to subscribers when changes occur, reducing the query pressure on the database, using third-party services such as RabbitMQ, ES, NATS and Kafka for data push, achieving Real-time data updates.
It simplifies the data update logic, reduces query pressure on the database, ensures that users can see changes in subscription data as soon as possible, improves user experience, and reduces server load.
Smart Images

Figure CN118568147A
Abstract
Description
Technical Field
[0001] The present application relates to the field of information processing technology, and in particular to a real-time data push method and system based on a database. Background Art
[0002] Data push refers to the process of getting the data subscribed by the user and the subsequent updated data from the server and pushing them to the user. Data push methods mainly include the following: 1. Webcast information push method; 2. Platform precision push method; 3. Front-end and back-end message push; 4. Message push data processing method; 5. Push technology; 6. System-level channel or comprehensive third-party channel push. These methods have their own characteristics and are suitable for different application scenarios and needs.
[0003] If the system wants to ensure that users can see the changes in the data they subscribe to at the first time, it needs to query the database regularly to check the changes in the data subscribed by users, and then push real-time data to the user's client. However, frequent scheduled queries on the database will seriously affect the database performance, put a lot of pressure on the database, and cause a waste of resources, which will cause the server to crash. It will also cause a lot of unnecessary data merging or re-acquisition operation logic. In more serious cases, it will cause the data subscribed by users to be displayed untimely, the data displayed to users will lag, the user experience will be poor, and the user's stock selection will be greatly affected. Summary of the invention
[0004] In order to at least to some extent overcome the problem in the related art that when pushing subscribed data to users, the pressure on the database will be increased, unnecessary logical operations will be caused, and data push will not be timely, the present application provides a real-time data push method and system based on a database.
[0005] The scheme of this application is as follows:
[0006] According to a first aspect of an embodiment of the present application, a real-time data push method based on a database is provided, comprising:
[0007] Build a table corresponding to the product in the database and store the business data of the product through the table;
[0008] When a product is subscribed, the business data corresponding to the product is obtained from the database and pushed to the subscriber;
[0009] Use probes to detect database instances and determine data changes in each table in the database.
[0010] When data changes occur in the table corresponding to a product, the changed business data corresponding to the product is obtained from the database and pushed to the subscriber.
[0011] Preferably, the subscriber includes: a third-party service and a client.
[0012] Preferably, the method further comprises:
[0013] After pushing business data to a third-party service, it is stored in the third-party service;
[0014] After pushing the business data to the client, the product is displayed directly on the client.
[0015] Preferably, the third-party services include at least: RabbitMQ, ES (Elasticsearch), NATS and Kafka;
[0016] The method further comprises:
[0017] Push business data to the third-party service RabbitMQ, and push business data to the client through the third-party service RabbitMQ;
[0018] Push business data to the third-party service ES, and push business data to the client based on the real-time search and analysis functions of the third-party service ES;
[0019] Push business data to the third-party service NATS, and push business data to the client based on the high scalability and Publish / Subscribe model of the third-party service NATS;
[0020] Push business data to the third-party service Kafka, and use the distributed publish-subscribe messaging system based on the third-party service Kafka to push business data to the client.
[0021] Preferably, the method further comprises:
[0022] Push the business data that needs to be pushed in the database managed by the current database instance to the corresponding database managed by the target database instance.
[0023] Preferably, the method further comprises:
[0024] Before pushing business data, check whether the business data to be pushed complies with the network green information regulations;
[0025] If it meets the requirements, data will be pushed;
[0026] If it does not match, the business data to be pushed will be recorded and the recorded business data will be processed.
[0027] Preferably, the method further comprises:
[0028] When a user browses a product page, determine the user's browsing time on the current product page;
[0029] If the user's browsing time on the current page is longer than the preset threshold, it is determined that the user has a subscription intention for the product corresponding to the current page, and a product subscription confirmation is initiated to the user;
[0030] After confirmation, subscribe the user to the product corresponding to the current page;
[0031] If the browsing time of the user on the current product page is not greater than the preset threshold, it is confirmed that the user has no subscription intention for the product corresponding to the current page.
[0032] Preferably, the method further comprises:
[0033] Obtain historical data on user subscription trends, and determine user preferences based on the historical data on user subscription trends;
[0034] Generate a product recommendation layout corresponding to the user based on the user's preferences on the product preview page.
[0035] Preferably, the business data of the product is stored in a table, including:
[0036] The business data of the product is stored through one table or a combination of multiple tables.
[0037] According to a second aspect of an embodiment of the present application, a real-time data push system based on a database is provided, comprising:
[0038] Processor and memory;
[0039] The processor and the memory are connected via a communication bus:
[0040] Wherein, the processor is used to call and execute the program stored in the memory;
[0041] The memory is used to store a program, and the program is at least used to execute a database-based real-time data push method as described in any one of the above items.
[0042] The technical solution provided by the present application may include the following beneficial effects: The database-based real-time data push method in the present application includes: constructing a table corresponding to the product in the database, and storing the business data of the product through the table; when the product is subscribed, obtaining the business data corresponding to the product in the database, and pushing the business data to the subscriber; detecting the database instance through a probe to determine the data changes of each table in the database; when the data changes in the table corresponding to the product, obtaining the changed business data corresponding to the product in the database, and pushing the changed business data to the subscriber.
[0043] The basic idea of database data probe detection is to change the frequent scheduled active query on the database to the database actively sending information data. The technical solution in this application detects the database instance through the probe to determine the data changes of each table in the database, and determines whether the product subscribed by the user has changed by monitoring the data changes in the table in the database. It simplifies the logic of data update and allows users to see the changes in their subscribed data at the first time. And there is no need to query the database regularly for changes in the user's subscribed data, which reduces the pressure on the database.
[0044] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0046] Figure 1 This is a flowchart of a real-time data push method based on a database provided by an embodiment of the present application;
[0047] Figure 2 It is a structural diagram of a real-time data push system based on a database provided by an embodiment of the present application.
[0048] Reference numerals: processor-21; memory-22. DETAILED DESCRIPTION
[0049] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0050] Figure 1 This is a flowchart of a real-time data push method based on a database provided by an embodiment of the present application, referring to Figure 1 , a real-time data push method based on a database, comprising:
[0051] S11: Build a table corresponding to the product in the database and store the business data of the product through the table;
[0052] It should be noted that the business data of products stored in tables include:
[0053] The business data of the product is stored through one table or a combination of multiple tables.
[0054] In this embodiment, the business data of a product usually corresponds to a table, or a combination of multiple tables. The update of the product is reflected in the update of the table. If the product corresponds to a combination of multiple tables, the update of one of the tables will also lead to the update of the product.
[0055] S12: When a product is subscribed, the business data corresponding to the product is obtained from the database, and the business data is pushed to the subscriber;
[0056] It should be noted that subscribers include: third-party services and clients.
[0057] Third-party services generally include: RabbitMQ, ES, NATS and Kafka.
[0058] S13: Use the probe to detect the database instance to determine the data changes of each table in the database;
[0059] S14: When data changes occur in the table corresponding to the product, the changed business data corresponding to the product is obtained from the database, and the changed business data is pushed to the subscriber.
[0060] It should be noted that the method also includes:
[0061] After pushing business data to a third-party service, it is stored in the third-party service;
[0062] After pushing the business data to the client, the product is displayed directly on the client.
[0063] It is understandable that the pushed business data can be stored in a third-party service or directly displayed on the user's client.
[0064] The method also includes:
[0065] Push business data to the third-party service RabbitMQ, and push business data to the client through the third-party service RabbitMQ;
[0066] Push business data to the third-party service ES, and push business data to the client based on the real-time search and analysis functions of the third-party service ES;
[0067] Push business data to the third-party service NATS, and push business data to the client based on the high scalability and Publish / Subscribe model of the third-party service NATS;
[0068] Push business data to the third-party service Kafka, and use the distributed publish-subscribe messaging system based on the third-party service Kafka to push business data to the client.
[0069] RabbitMQ is an open source message queue service software, an open source implementation of Advanced Message Queuing Protocol (AMQP) provided by LShift, written in Erlang, which is famous for its high performance, robustness and scalability. In this embodiment, the business data can be pushed to the third-party service RabbitMQ first, and then the third-party service RabbitMQ pushes the business data to the client.
[0070] ES is a distributed search and analysis engine at the core of the Elastic Stack. ES can provide near real-time search and analysis for all types of data. Whether it is structured or unstructured text, digital data or geospatial data, ES can efficiently store and index it in a way that supports fast search. In this embodiment, business data can be pushed to the third-party service ES first, and then the business data can be pushed to the client based on the real-time search and analysis function of the third-party service ES.
[0071] NATS is an open source, lightweight, high-performance messaging system based on the publish / subscribe model. In this embodiment, the lightweight and high-performance features of NATS can be fully utilized to first push the business data to the third-party service NATS, and then push the business data to the client based on the high scalability and Publish / Subscribe model of the third-party service NATS.
[0072] Kafka is an open source stream processing platform developed by the Apache Software Foundation and written in Scala and Java. Kafka is a high-throughput distributed publish-subscribe messaging system that can process all action stream data of consumers on a website. This action (web browsing, searching, and other user actions) is a key factor in many social functions on the modern network. These data are usually solved by processing logs and log aggregation due to throughput requirements. This is a viable solution for log data and offline analysis systems like Hadoop, but with the limitation of real-time processing. The purpose of Kafka is to unify online and offline message processing through Hadoop's parallel loading mechanism, and to provide real-time messages through clusters. In this embodiment, the business data can be pushed to the third-party service Kafka first, and the distributed publish-subscribe messaging system based on the third-party service Kafka pushes the business data to the client.
[0073] In actual practice, appropriate third-party services are selected according to the application scenarios of the products, so as to push business data by leveraging the different advantages of each third-party service.
[0074] It should be noted that the method also includes:
[0075] Push the business data that needs to be pushed in the database managed by the current database instance to the corresponding database managed by the target database instance.
[0076] It can be understood that in this embodiment, the business data to be pushed in the database managed by the current database instance is pushed to the corresponding database managed by the target database instance, so that data synchronization in databases managed by different database instances can be achieved.
[0077] For example:
[0078] The databases managed by the current database instance A are A1, A2, and A3.
[0079] The target database instance B manages databases B1, B2, and B3.
[0080] Among them, A1 and B1 have a corresponding relationship, and the business data stored in the two are the same. A2 and B2 have a corresponding relationship, and the business data stored in the two are the same. A3 and B3 have a corresponding relationship, and the business data stored in the two are the same.
[0081] When business data changes in database A1 managed by the current database instance A, the changed business data will not only be pushed to the subscriber, but also pushed to database B1 managed by the target database instance B to achieve synchronization between B1 and A1.
[0082] It should be noted that the method also includes:
[0083] Before pushing business data, check whether the business data to be pushed complies with the network green information regulations;
[0084] If it meets the requirements, data will be pushed;
[0085] If it does not match, the business data to be pushed will be recorded and the recorded business data will be processed.
[0086] It should be noted that the green information regulations on the Internet are existing green Internet access regulations mainly for teenagers. In this embodiment, an efficient website security filtering engine is combined to provide users with services for filtering illegal websites under the premise of safety and stability, providing teenagers with a clean Internet sky. It does not require any modification, setting or installation of software on the user side, but makes a fundamental interception of harmful websites on the telecommunications backbone network, automatically filters many bad contents on the Internet, and blocks most of the bad websites in the world. The database of its system will also be updated every day, automatically searching and blocking newly added bad websites. For general family users, the content control function of the green Internet access service provides parents with an effective means to ensure that teenagers do not come into contact with bad network information.
[0087] It should be noted that the method also includes:
[0088] When a user browses a product page, determine the user's browsing time on the current product page;
[0089] If the user's browsing time on the current page is longer than the preset threshold, it is determined that the user has a subscription intention for the product corresponding to the current page, and a product subscription confirmation is initiated to the user;
[0090] After confirmation, subscribe the user to the product corresponding to the current page;
[0091] If the browsing time of the user on the current product page is not greater than the preset threshold, it is confirmed that the user has no subscription intention for the product corresponding to the current page.
[0092] Furthermore, the method also includes:
[0093] Obtain historical data on user subscription trends, and determine user preferences based on the historical data on user subscription trends;
[0094] Generate a product recommendation layout corresponding to the user based on the user's preferences on the product preview page.
[0095] In this embodiment, it is also determined whether the user is interested in the page information browsed based on the browsing time of the user on the current page. If the user is interested, the updated data of the topic is pushed to the user. If the browsing time of the user on the current page is longer than 5 seconds, it is confirmed that the user has a subscription tendency to the product corresponding to the current page, and a product subscription confirmation is initiated to the user; after the confirmation is passed, the user is subscribed to the product corresponding to the current page. If the browsing time of the user on the current product page is 1-5 seconds, it is confirmed that the user has no subscription tendency to the product corresponding to the current page.
[0096] Subsequently, historical data on user subscription tendencies is obtained, and user preferences are determined based on the historical data on user subscription tendencies; a product recommendation layout corresponding to the user is generated based on the user preferences on the product preview page.
[0097] The technical solution in this embodiment takes into account the interests of users and provides users with customized product recommendation pages, which can not only improve user experience, but also reduce useless work of the server and improve system work efficiency.
[0098] It is understandable that the basic idea of database data probe detection is to change the frequent scheduled active query on the database to the database actively sending information data. In the technical solution of this embodiment, the probe detects the database instance, determines the data changes of each table in the database, and determines whether the product subscribed by the user has changed by monitoring the data changes of the table in the database, which replaces the method of directly querying the database in the prior art. The technical means have changed from the method of obtaining data to the method of receiving data. Assuming that the data is queried once every 5 minutes in the prior art, there may be several or thousands of data or no data updates during the query period. After adopting this technical solution, as long as there is a data update, it can be detected, and then the updated data will be pushed to the third-party service or client in real time. If there is no data, it will not be pushed. This can reduce useless waste of resources and no processing will be performed when there is no data.
[0099] Take client browsing of news as an example. For example, a client product contains multiple news column modules. When a customer uses the client to browse a news column, if he wants to know whether the news column data has been updated, he needs to exit the currently browsed news column and then re-enter to refresh, which will cause unnecessary traffic loss and redundant logical operations.
[0100] The technical solution in this embodiment detects the database instance through a probe to determine the data changes of each table in the database, and determines whether the product subscribed by the user has changed by monitoring the data changes in the table in the database. The database establishes a long connection with the server, and pushes the changed data to the third-party service or client in real time. If there is no data, no push will be made. In this way, no processing will be performed if there is no data change. This simplifies the logic of data update and allows users to see the changes in their subscribed data at the first time.
[0101] Embodiment 2
[0102] A real-time data push system based on a database, comprising:
[0103] Processor 21 and memory 22;
[0104] The processor 21 and the memory 22 are connected via a communication bus:
[0105] The processor 21 is used to call and execute the program stored in the memory 22;
[0106] The memory 22 is used to store programs, and the programs are at least used to execute a real-time data push method based on a database as described in the above embodiment.
[0107] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0108] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0109] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0110] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0111] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0112] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0113] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0114] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0115] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in the field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A real-time data push method based on a database, characterized in that: include: Build a table corresponding to the product in the database and store the business data of the product through the table; When a product is subscribed, the business data corresponding to the product is obtained from the database and pushed to the subscriber; Use probes to detect database instances and determine data changes in each table in the database. When data changes occur in the table corresponding to a product, the changed business data corresponding to the product is obtained from the database and pushed to the subscriber.
2. The method according to claim 1, characterized in that The subscribers include: third-party services and clients.
3. The method according to claim 2, characterized in that The method further comprises: After pushing business data to a third-party service, it is stored in the third-party service; After pushing the business data to the client, the product is displayed directly on the client.
4. The method according to claim 1, characterized in that The third-party services include at least: RabbitMQ, ES, NATS and Kafka; The method further comprises: Push business data to the third-party service RabbitMQ, and push business data to the client through the third-party service RabbitMQ; Push business data to the third-party service ES, and push business data to the client based on the real-time search and analysis functions of the third-party service ES; Push business data to the third-party service NATS, and push business data to the client based on the high scalability and Publish / Subscribe model of the third-party service NATS; Push business data to the third-party service Kafka, and use the distributed publish-subscribe messaging system based on the third-party service Kafka to push business data to the client.
5. The method according to claim 1, characterized in that The method further comprises: Push the business data that needs to be pushed in the database managed by the current database instance to the corresponding database managed by the target database instance.
6. The method according to claim 1, characterized in that The method further comprises: Before pushing business data, check whether the business data to be pushed complies with the network green information regulations; If it meets the requirements, data will be pushed; If it does not match, the business data to be pushed will be recorded and the recorded business data will be processed.
7. The method according to claim 1, characterized in that The method further comprises: When a user browses a product page, determine the user's browsing time on the current product page; If the user's browsing time on the current page is longer than the preset threshold, it is determined that the user has a subscription intention for the product corresponding to the current page, and a product subscription confirmation is initiated to the user; After confirmation, subscribe the user to the product corresponding to the current page; If the browsing time of the user on the current product page is not greater than the preset threshold, it is confirmed that the user has no subscription intention for the product corresponding to the current page.
8. The method according to claim 7, characterized in that The method further comprises: Obtain historical data on user subscription trends, and determine user preferences based on the historical data on user subscription trends; Generate a product recommendation layout corresponding to the user based on the user's preferences on the product preview page.
9. The method according to claim 1, characterized in that: The business data of the product is stored in tables, including: The business data of the product is stored through one table or a combination of multiple tables.
10. A real-time data push system based on a database, characterized in that: include: Processor and memory; The processor and the memory are connected via a communication bus: Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store a program, and the program is at least used to execute a database-based real-time data push method as described in any one of claims 1-9.
Citation Information
Patent Citations
Product subscribing recommending system based on knowledge base
CN107862080A
Data push method, device, and system, and terminal device
CN109286648A
Data pushing method for product containing plurality of columns
CN110351288A
Message data pushing method, system and device
CN110995566A
Service data pushing method and system, computer equipment and computer storage medium
CN113190778A
