Index query method, statistical method, device, equipment and storage medium
By using read-time cache and write-time cache in the shared memory of the server, the full memory cache of indicators is realized, which solves the problem of long query time in the existing technology, improves query efficiency, and meets real-time needs.
Patent Information
- Application Number
- CN202410875853.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-02
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2044-07-02
AI Technical Summary
The existing technology requires retrieving a large number of flow logs from the disk when querying indicators, which causes the query to take a long time and cannot meet real-time needs.
By using read-time cache and write-time cache in the shared memory of the server, indicators with different time granularities are cached in full memory to avoid retrieval from the disk and improve query efficiency.
It significantly reduces the query time of indicators and meets the needs of real-time display of indicators and real-time recommendation system.
Smart Images

Figure CN118410076B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to an indicator query method, statistical method, device, equipment and storage medium. Background Art
[0002] Advertisement indicators can reflect information such as user acquisition, activity, retention, conversion, and behavior. Indicators can be displayed externally as the number of likes, forwarding, and activity, and can also be applied to recommendation systems to help improve the quality and efficiency of recommendations.
[0003] In related technologies, the client's transaction logs are imported into the server in batches through a distributed streaming platform (Kafka) or a distributed computing framework (Hadoop). The server uses a disk to save transaction logs reported for one or more days, and uses indexes and segments to improve the query performance of indicators.
[0004] However, the related technologies need to retrieve a large amount of log files from the disk each time they query an indicator, which is time-consuming. For example, querying a single indicator takes about 50 milliseconds, and batch querying thousands of indicators often takes tens of seconds or even minutes. Summary of the invention
[0005] The present application provides an index query method, statistical method, device, equipment and storage medium. The technical solution is as follows:
[0006] In one aspect, a method for querying an indicator is provided, the method being executed by a server and comprising:
[0007] Receive a query request from a client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period;
[0008] Obtaining the target indicator corresponding to the query request from indicators of different time granularities of write-time cache or read-time cache in a shared memory of at least one storage engine of the server, wherein the write-time cache refers to caching when the indicator is written to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when the indicator is read, and the indicator is obtained by aggregating and transforming the stream log reported by the client;
[0009] The target indicator corresponding to the query request is returned to the client.
[0010] On the other hand, a method for calculating the statistics of an indicator is provided, the method being executed by a server and comprising:
[0011] Receive transaction logs reported by the client;
[0012] Aggregating and transforming the logbook to obtain indicators at different time granularities;
[0013] The indicators of the different time granularities are cached to at least one storage engine of the server, and the at least one storage engine is used to cache the indicators of the different time granularities in a shared memory when writing or when reading. The write-time cache refers to caching when the indicators are written to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when reading the indicators.
[0014] On the other hand, a device for querying an indicator is provided, the device comprising:
[0015] A receiving module, used to receive a query request from a client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period;
[0016] A query module, used to obtain the target indicator corresponding to the query request from indicators of different time granularities of write-time cache or read-time cache in a shared memory of at least one storage engine of the server, wherein the write-time cache refers to caching when the indicator is written to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when the indicator is read, and the indicator is obtained by aggregating and transforming the flow log reported by the client;
[0017] The return module is used to return the target indicator corresponding to the query request to the client.
[0018] On the other hand, a statistical device for indicators is provided, the device comprising:
[0019] The receiving module is used to receive the transaction log reported by the client;
[0020] A processing module, used to aggregate and transform the journal log to obtain indicators of different time granularities;
[0021] A cache module is used to cache the indicators of different time granularities to at least one storage engine of the server, and the at least one storage engine is used to cache the indicators of different time granularities in a shared memory when writing or when reading. The write-time cache refers to caching when writing the indicators to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when reading the indicators.
[0022] On the other hand, a computer device is provided, comprising: a processor and a memory, wherein the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the query method of the indicator and / or the statistical method of the indicator as described above.
[0023] On the other hand, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program is loaded and executed by a processor to implement the query method of indicators and / or the statistical method of indicators as described above.
[0024] On the other hand, a computer program product is provided, which includes computer instructions, which are stored in a computer-readable storage medium. A processor obtains the computer instructions from the computer-readable storage medium, so that the processor loads and executes them to implement the query method for indicators and / or the statistical method for indicators as described above.
[0025] The beneficial effects brought by the technical solution provided by the embodiment of the present application include at least:
[0026] Through the read-time cache and write-time cache of at least one storage engine in the server, indicators of different time granularities are stored in shared memory, achieving full memory cache of indicators of different time granularities, so that indicators do not need to be retrieved from disk when querying. Since shared memory reading takes less time than disk reading, it can reduce the query time of indicators, and thus meet the needs of external display of indicators and the needs of real-time recommendation systems. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0028] Figure 1 is a structural block diagram of a computer system provided by an exemplary embodiment of the present application;
[0029] Figure 2 is a system schematic diagram of a related technology provided by an exemplary embodiment of the present application;
[0030] Figure 3 It is a schematic diagram of a system for statistics and query of indicators provided by an exemplary embodiment of the present application;
[0031] Figure 4 is a flowchart of a method for querying an indicator provided by an exemplary embodiment of the present application;
[0032] Figure 5 is a schematic diagram of indicators of different time granularities provided by an exemplary embodiment of the present application;
[0033] Figure 6is a flowchart of a method for querying an indicator provided by another exemplary embodiment of the present application;
[0034] Figure 7 It is a system diagram of a method for querying an indicator provided by an exemplary embodiment of the present application;
[0035] Figure 8 is a flow chart of a statistical method for indicators provided by an exemplary embodiment of the present application;
[0036] Fig. 9 is a flow chart of a statistical method for indicators provided by another exemplary embodiment of the present application;
[0037] Fig.10 It is a system diagram of a statistical method of indicators provided by an exemplary embodiment of the present application;
[0038] Fig.11 is a system diagram of a statistical method for indicators provided by another exemplary embodiment of the present application;
[0039] Fig.12 is a block diagram of an indicator query device provided by an exemplary embodiment of the present application;
[0040] Fig.13 is a block diagram of a statistical device for indicators provided by an exemplary embodiment of the present application;
[0041] Fig.14 It is a structural block diagram of a server provided by an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0042] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0043] 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, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. 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.
[0044] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0045] It should be understood that, although the terms first, second, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first parameter may also be referred to as the second parameter, and similarly, the second parameter may also be referred to as the first parameter. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0046] It should be noted that this application can display a prompt interface, pop-up window or output voice prompt information before collecting relevant user data (for example, data related to statistics and query of indicators, user acquisition, activity, retention, conversion, behavior, etc.) and during the process of collecting relevant user data. The prompt interface, pop-up window or voice prompt information is used to prompt the user that its relevant data is currently being collected, so that this application only starts to execute the relevant steps of obtaining user-related data after obtaining the user's confirmation operation on the prompt interface or pop-up window, otherwise (that is, when the user's confirmation operation on the prompt interface or pop-up window is not obtained), the relevant steps of obtaining user-related data are terminated, that is, the user's relevant data is not obtained. In other words, all user data collected by this application are collected with the user's consent and authorization, and the collection, use and processing of relevant user data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0047] First, the nouns involved in the embodiments of the present application are briefly introduced.
[0048] Indicator: Also known as counting indicator, it is a kind of data that can reflect information such as user acquisition, activity, retention, conversion, behavior, etc. Indicators can be displayed externally as the number of likes, forwarding, activity, etc., and can also be applied to recommendation systems to help improve the quality and efficiency of recommendations. In some embodiments, the indicator includes at least one of page views (PV), unique visitors (UV), visit views (VV), and unique IP numbers. Page views are the number of page views, which are used to measure the number of web pages visited by website users. The number of unique visitors refers to the number of users who visit a website within a period of time. The number of visitor visits refers to the number of times all visitors visit the website within a period of time. The number of unique IPs refers to the number of times users with different IP addresses visit the website within a period of time. In this embodiment, indicators of different time granularities are counted, and the time granularity includes at least one of minutes, hours, days, months, and years. For example, the number of page views per minute or the number of unique visitors per hour are counted.
[0049] Online counting and statistics system: a system with real-time online statistics function and real-time online query function provided by the embodiment of the present application, which can be located or stored in the server. The online counting and statistics system is used to aggregate and transform a large number of logbooks, transform the logbooks into indicators of different time granularities and cache them, and also provides the function of fast real-time query of indicators of different time granularities.
[0050] For example, when a user swipes a short video (Feed) in a short video recommendation scenario or a friend scenario, a flow log containing at least one of the detailed information of the content identifier (Feed Id), user account identifier, scene value (Scene), timestamp, and behavior type will be reported to the online counting and statistics system. After aggregation and transformation, an operation of adding 1 to the index corresponding to the keyword (Key) at a certain minute, hour, or day will be generated, wherein the keyword may include at least one of the above-mentioned content identifier, user account identifier, scene value, and behavior type. When the online reporting system or recommendation system needs to query the target indicator, it only needs to provide at least one of the detailed information of the content identifier, user account identifier, scene value, and behavior type, as well as the target time period and target time granularity to be queried, and the specific value of the indicator corresponding to the corresponding target time granularity can be queried. The specific values of these indicators can be displayed externally as the number of likes, forwardings, and the number of people entering the homepage, and can also be applied to recommendation scenarios to help improve the quality and efficiency of recommendations.
[0051] The online counting and statistics system provides at least the following capabilities: 1. High throughput: Through the asynchronous queue aggregated by the client and the server, it provides high-throughput log reporting capabilities, especially in the hot data reporting scenario with good performance. 2. Low latency: The processing delay from the reporting of the running log to the query of the indicator reaches the second level, and can even reach the millisecond level, realizing real-time online statistics and real-time online query of the indicator. 3. Low latency: Through read-time caching and write-time caching, the query time of the indicator is reduced, providing fast response capabilities. 4. Eventual consistency: The servers in the same server cluster (Set) are each other's master and backup. The indicators updated by the host can also be written to the backup machine. The host and the backup machine can provide query services to the outside world at the same time, which improves the query performance. The indicators are also regularly stored in the reliability storage of the backend to avoid the loss of indicators.
[0052] Next, the computer system involved in the embodiments of the present application is described.
[0053] Figure 1 1 is a block diagram of a computer system 100 provided by an exemplary embodiment of the present application. The computer system 100 can realize a system architecture of an index query method and / or an index statistical method. The computer system 100 includes: a terminal 120 and a server 140.
[0054] The terminal 120 may be an electronic device such as a mobile phone, a tablet computer, a vehicle-mounted terminal (vehicle computer), a wearable device, a PC (Personal Computer), an unmanned reservation terminal, etc. A client that runs a target application may be installed in the terminal 120. The embodiment of the present application does not limit the form of the target application, including but not limited to an App (Application), a client, a mini-program, etc. installed in the terminal 120, and may also be in the form of a web page.
[0055] Optionally, the target application may be an application for querying indicators, for example, the target application is implemented as a real-time online query platform or a real-time online query system or a real-time online query database for indicators, or other applications that provide query functions for indicators. Alternatively, the target application may be an application for statistics of indicators, for example, the target application is implemented as an online counting statistics platform or an online counting statistics system or an online counting statistics database for indicators, or other applications that provide statistics functions for indicators. Alternatively, the target application may also be an application for recording and generating running water logs, or other applications that provide running water log generation functions, or other applications that provide running water log acquisition and reporting functions. The embodiments of the present application are not limited to this.
[0056] Server 140 may be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services, cloud database, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDN), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms. Server 140 may be a backend server of the above-mentioned target application, used to provide backend services for the client of the target application.
[0057] Among them, cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to realize data computing, storage, processing and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool, which is used on demand and flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the high development and application of the Internet industry, in the future, each item may have its own identification mark, and all need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0058] In some embodiments, the server 140 can also be implemented as a node in a blockchain system. Blockchain is a new application model of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain is essentially a decentralized database, a string of data blocks generated by cryptographic methods. Each data block contains a batch of network transaction information, which is used to verify the validity of its information (anti-counterfeiting) and generate the next block. Blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.
[0059] The terminal 120 and the server 140 may communicate with each other via a network, such as a wired or wireless network.
[0060] In the index query method and / or index statistical method provided in the embodiment of the present application, the execution subject of each step may be a computer device, which refers to an electronic device with data calculation, processing and storage capabilities. Figure 1 Taking the implementation environment of the scheme shown as an example, the terminal 120 can execute the indicator query method and / or the indicator statistical method, for example, the indicator query method and / or the indicator statistical method can be executed by the client of the target application installed and running in the terminal 120, or the indicator query method and / or the indicator statistical method can be executed by the server 140, or the terminal 120 and the server 140 can interact and cooperate to execute, and this application does not limit this.
[0061] Those skilled in the art will appreciate that the number of the terminals 120 may be more or less. For example, the terminal 120 may be only one, or the terminal 120 may be dozens or hundreds, or a greater number. The embodiment of the present application does not limit the number and device type of the terminals 120.
[0062] Next, the statistical and query methods of the indicators provided in the embodiments of the present application are briefly introduced.
[0063] Figure 2 This is a system diagram of a related technology provided by an exemplary embodiment of the present application. In the related technology, the client's logbook is imported into the server in batches through a distributed streaming platform (Kafka) or a distributed computing framework (Hadoop). The server saves the logbook reported for one or more days through a disk, and uses indexes and segments to improve the query performance of indicators.
[0064] For example, refer to Figure 2 The real-time analysis system based on the distributed data storage system (Durid) in (1) is an analytical data platform including a time series database, a data warehouse and a full-text retrieval system. After the log is collected 101, it is reported to the distributed streaming platform (Kafka) 102 and the distributed streaming platform component (Storm ETL) 103 and imported into Durid 104, which can then process the read request 105 to realize the query of indicators. Reference Figure 2 In (2), the real-time storage system is based on a columnar database management system (ClickHouse) for online analysis. The real-time write layer 111 reports the flow log to the ClickHouse cluster 112. The ClickHouse cluster 112 combines with the distributed application coordination service (ZooKeeper) 113 to process the read request 114 to realize the query of the indicator.
[0065] However, the related technology needs to retrieve a large amount of log files from the disk each time it queries an indicator, and the query is time-consuming. For example, it takes about 50 milliseconds to query a single indicator, and batch query of thousands of indicators often takes tens of seconds or even minutes. In addition, the log files in the related technology need to be written in batches, or no more than one write request per second, and the report needs to go through Kafka or Hadoop, which increases the complexity of the system. The delay in the effectiveness of the log files is generally in minutes or hours, and it is impossible to achieve real-time updates in seconds.
[0066] Based on this, an embodiment of the present application provides an online counting and statistics system, which is located in the server and can aggregate and transform the transaction log to obtain indicators of different time granularities, and cache all these indicators of different time granularities in memory to ensure that the transaction log takes effect in seconds. Based on the online counting and statistics system, the query of indicators can be realized, making the query of indicators low-time and highly available, thereby meeting the needs of external display of indicators and the needs of real-time recommendation systems.
[0067] Figure 31 is a schematic diagram of a system for statistics and query of indicators provided by an exemplary embodiment of the present application. In a possible implementation, the query method of indicators and / or the statistical method of indicators provided by the embodiment of the present application can be executed by a computer device, which can be Figure 1 The server 140 shown. The server that executes the index query method and the server that executes the index statistical method can be the same server or different servers. When the two servers are different servers, they can be different servers in the same server cluster. Figure 3 The steps of the statistical method of the indicators executed by the server are briefly described as steps 1 to 3, and the steps of the query method of the indicators are briefly described as steps 4 to 6:
[0068] Step 1: The server receives the transaction log reported by the client; optionally, the transaction log is reported in batches.
[0069] Step 2: The server aggregates and transforms the log to obtain indicators of different time granularities; optionally, the different time granularities include minute, hour, and day. For example, the indicators are page views (PV) and unique visitors (UV). The minute-level indicators include minute PV sequences and minute UV sequences, the hour-level indicators include hour PV sequences and hour UV sequences, and the day-level indicators include day PV sequences and day UV sequences.
[0070] Step 3: The server caches the indicators of different time granularities to at least one storage engine of the server. The at least one storage engine is used to cache the indicators of different time granularities in the shared memory when writing or reading. The cache when writing refers to caching when writing the indicators to the at least one storage engine, and the cache when reading refers to caching in the at least one storage engine when reading the indicators. Optionally, the indicators of different time granularities are cached to the at least one storage engine of the server according to the corresponding keywords.
[0071] Step 4: The server receives a query request from the client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period.
[0072] Step 5, obtain the target indicator corresponding to the query request from the indicators of different time granularities of the write-time cache or read-time cache in the shared memory of at least one storage engine of the server. The write-time cache refers to caching the indicator when writing it to at least one storage engine, and the read-time cache refers to caching the indicator in at least one storage engine when reading it. The indicator is obtained by aggregating and transforming the flow log reported by the client. Optionally, the server can query the target indicator from each storage engine in the at least one storage engine in turn, for example, first query from the storage engine with the write-time cache, and if no result is found, query from the storage engine with the read-time cache.
[0073] Step 6: The server returns the target indicator corresponding to the query request to the client.
[0074] Specifically, refer to Figure 3 , the client includes a shared memory, and the logbook is reported in batches. The client is used to batch multiple logbooks in the shared memory. When the set conditions are met, multiple logbooks with the same keyword (Key) are merged to obtain the logbook 210. Among them, the set conditions can be set to at least one of the following: reaching a preset time point, reaching a preset duration, the number of logbooks reaching a preset number, and the storage space occupied by the logbook reaching a preset storage space size. For example, the keywords of N logbooks are all: (promotion_id_1, action_type_exposure, scene_friend) + 1, and the client converts these N logbooks into 1 (promotion_id_1, action_type_exposure, scene_friend) + N logbooks. Next, a Remote Procedure Call (RPC) request is issued in batches. The client reports the logbook 210 to the server in batches. The log 210 includes log 1 (Log1), log 2 (Log2) and log 3 (Log3), which are expressed as: Log1: (promotion_id_1, action_type_exposure, scene_friends) uin_list=["123"], +1; Log2: (promotion_id_1, action_type_exposure, scene_hot) uin_list=["123", "456"], +2; Log3: (promotion_id_2, action_type_click, scene_friends) uin_list=["456"], +1.
[0075] The server aggregates and transforms the log 210 to obtain minute-level, hour-level, and daily-level indicators 220 corresponding to different keywords. The indicators 220 can be page views (PV) and unique visitors (UV). The minute-level indicators 220 include minute PV sequences and minute UV sequences, the hour-level indicators 220 include hourly PV sequences and hourly UV sequences, and the daily indicators 220 include daily PV sequences and daily UV sequences. Each keyword and its corresponding indicator 220 are represented as: Key=promotion_1_exposure+3, uv add ["123", "456"]; Key=promotion_1_exposure_friends+1, uv add ["123"]; Key=promotion_1_exposure_hot+2, uv add ["123", "456"].
[0076] The query request is a real-time online query request 230. The server receives the real-time online query request 230. The real-time online query request 230 is used to indicate the target index of the target time granularity of the query target time period, which is expressed as: Q1: promotion_id=1, action_type=exposure, scene=all, PV per minute in the last 30 minutes; Q2: promotion_id=1, action_type=exposure, scene=hot, total UV in the last hour; Q3: promotion_id=2, action_type=click, scene=all, total historical PV. The server then obtains the target index corresponding to the query request 230 in the index 220 and returns these target indexes to the client.
[0077] In summary, the statistical method and query method of indicators provided in the embodiments of the present application provide an online counting and statistics system that supports multiple condition aggregation, multiple time granularities and time periods. Multiple conditions refer to the conditions when querying the target indicator, which can be determined based on keywords. For example, you can query the indicator of "promotion_id_1, action_type_exposure, scene=all", or you can query the indicator of "promotion_id_1, action_type_exposure, scene_friend". The indicators are obtained by aggregating and converting the running logs between the client and the server, providing a high-throughput running log reporting capability and a running log processing capability. Through the read-time cache and write-time cache in the server, and storing the indicators in shared memory, the full memory cache of the indicators is realized, so that the indicators do not need to be retrieved from the disk when querying, reducing the query time of the indicators, and thus being able to meet the needs of external display of the indicators and the needs of the real-time recommendation system.
[0078] Next, the query method of the indicator provided in the embodiment of the present application is described.
[0079] Figure 4 is a flowchart of a method for querying an indicator provided by an exemplary embodiment of the present application. The method is executed by a computer device, which may be Figure 1 The method includes at least part of steps 320, 340 and 360.
[0080] Step 320 , receiving a query request from the client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period.
[0081] Indicators can reflect information such as user acquisition, activity, retention, conversion, and behavior.
[0082] Optionally, the indicator includes at least one of page views (PV), unique visitors (UV), visitor visits (VV), and unique IP addresses. Page views are the number of page views, which are used to measure the number of web pages visited by website users. Unique visitors refer to the number of users who visit a website within a period of time. Visitor visits refer to the number of times all visitors visit a website within a period of time. Unique IP addresses refer to the number of times users with different IP addresses visit a website within a period of time. The aforementioned different types of indicators all include different time granularities. Optionally, the time granularity includes at least one of minutes, hours, days, months, and years. For example, taking page views as an example, indicators of different time granularities may be page views per minute or page views per day. The aforementioned period of time may be a set fixed duration, or may be determined based on different time granularities.
[0083] A query request is a request sent by a client, and the query request is used to indicate a target indicator of a target time granularity of a query target time period. The target time granularity is one of different preset time granularities. In this embodiment, the time granularity includes at least one of minutes, hours, days, months, and years. For example, the query request is used to indicate the number of web page visits per day from 20240601 to 20240607, or to indicate the number of visitor visits per minute from 20240601 14:05 to 20240601 14:46.
[0084] In some embodiments, the query request may also optionally carry query details information, and the query details information is used to specifically determine the keyword corresponding to the query request. Optionally, the query details information includes at least one of the user's operations and events, access status, timestamp, protocol type, user account identifier (promotion_id), login method, login IP address, content identifier involved, behavior type (action_type), and scene value (scene). Optionally, the behavior type includes at least one of click, long press, exposure, slide, update, delete, add, modify, and forward. The scene value is determined based on the scene when the log is generated, and can be expressed as a descriptive word corresponding to the scene. For example, the scene value is at least one of friends, hot, short video, and live broadcast. For example, the query request carries at least one of the content identifier, user account identifier, scene value, and behavior type, which is used to indicate the number of times a user swipes to a specific content in a specific scene at the target time granularity of the query target time period. It should also be noted that these details in the query request are all information that has been agreed and authorized.
[0085] In a possible implementation, the query request includes a remote procedure call (RPC) request. The client encapsulates the target time period, target time granularity, target indicator and other information that the user needs to query into a query request according to the remote procedure call protocol, and sends the query request to the server. The server receives the query request from the client and parses the query request to determine the information indicating the target time period, target time granularity and target indicator of the query.
[0086] Step 340, obtain the target indicator corresponding to the query request from the indicators of different time granularities of the write-time cache or read-time cache in the shared memory of at least one storage engine of the server. The write-time cache refers to caching when the indicator is written to at least one storage engine, and the read-time cache refers to caching in at least one storage engine when reading the indicator. The indicator is obtained by aggregating and transforming the flow log reported by the client.
[0087] The logbook is a log that records at least one of the detailed information of the various operating states of an application or application system, user operations and events, access status, timestamp, protocol type, user account ID (promotion_id), login method, login IP address, content ID involved, behavior type (action_type), and scene value (Scene). Optionally, the behavior type includes at least one of click, long press, exposure, slide, update, delete, add, modify, and forward. The scene value is determined based on the scene when the logbook is generated, and can be expressed as a descriptive word corresponding to the scene. For example, the scene value is at least one of friends, hot, short video, and live broadcast. It should also be noted that these detailed information in the logbook are all agreed and authorized information.
[0088] In some embodiments, the client reports the log flow to the server, the server receives the log flow reported by the client, and performs aggregation and conversion on the log flow to obtain indicators of different time granularities. Optionally, the client includes shared memory, and the shared memory is the / dev / shm / directory of the client, which is used to represent a storage space mounted in the memory. The log flow is reported in batches, and the client is used to batch multiple log flow in the shared memory. When the set conditions are met, multiple log flow with the same keyword (Key) are merged to obtain pre-processed log flow, and these pre-processed log flow are reported to the server.
[0089] Optionally, the setting condition can be set to at least one of the following: reaching a preset time point, reaching a preset duration, the time difference between the earliest log and the current time reaches a preset time difference, the number of logs reaches a preset number, the storage space occupied by the logs reaches a preset storage space size or the storage space size of the shared memory. For example, if the storage space size of the shared memory of the client is 1GB, when the log has reached 1GB, or has reached 500, or the earliest log is 100 milliseconds away, then the merging of multiple logs is performed.
[0090] For example, the keywords of N logbooks are all: (promotion_id_1, action_type_exposure, scene_friend) + 1, and the client converts these N logbooks into 1 logbook of (promotion_id_1, action_type_exposure, scene_friend) + N. Next, a Remote Procedure Call (RPC) request is issued in batches to report the logbooks to the client in batches. This embodiment is equivalent to batching logbooks in shared memory. Since the client may be multi-process and multi-threaded, this batching method can be used for multi-process and multi-threaded, and read-write conflicts are handled through lightweight locks.
[0091] In some embodiments, the index is obtained by aggregating and transforming the log reported by the client. The aggregation and transformation method is that the server performs permutations and combinations based on the log attributes of the log to obtain the keywords corresponding to the log, and then reads the indicators to be updated at different time granularities based on the keywords, that is, the old indicators, and then performs an addition N operation on the indicators to be updated to update these indicators to be updated, thereby realizing the aggregation and transformation of the log to obtain the indicators of different time granularities, where N is greater than 0.
[0092] Specifically, the log attributes of the log include at least one of the user account identifier (promotion_id), login method, login IP address, the type of behavior involved (action_type), and the scene value (Scene). For example, log 1 (Log1), log 2 (Log2), and log 3 (Log3) are represented as: Log1: (promotion_id_1, action_type_exposure, scene_friend) uin_list=["123"], +1; Log2: (promotion_id_1, action_type_exposure, scene_hot) uin_list=["123", "456"], +2; Log3: (promotion_id_2, action_type_click, scene_friend) uin_list=["456"], +1. The server performs permutations and combinations on the log attributes and determines that the keywords at least include: Key=promotion_1_exposure; Key=promotion_1_exposure_friend; Key=promotion_1_exposure_hot. Next, based on these keywords, the indicators to be updated are read, and the addition N operation is performed on the indicators to be updated to update these indicators to be updated, so as to obtain indicators of different time granularities. These indicators can be expressed as: Key=promotion_1_exposure+3, uvadd["123","456"]; Key=promotion_1_exposure_friends+1, uv add["123"]; Key=promotion_1_exposure_hot+2, uv add["123","456"].
[0093] In some embodiments, the time granularity includes at least one of minutes, hours, days, months, and years. For example, indicators of different time granularities may be: counting the number of web page views per minute or counting the number of unique visitors per hour. The number of web page views per minute may also be referred to as minute-level web page views, and the number of unique visitors per hour may also be referred to as hour-level unique visitors. Specifically, indicators of different time granularities include two parts, one part is the specific numerical value (Value) of the indicator, and the other part is a set of log identifier (Uuid) sequences, the log identifier sequence set includes the log identifiers of multiple flow logs, and these multiple flow logs are flow logs aggregated to the indicator. Among them, the log identifier may be represented by one or more combinations of letters, numbers, random numbers, and characters. For example, taking the time granularity of every minute and every 10 minutes, and the indicators are the number of web page views PV and the number of unique visitors UV as an example. Reference Figure 5 Schematic diagram of indicator 222, which includes minute-level indicator 2221 and 10-minute-level indicator 2222 and log identifier sequence set 2223. For minute-level indicator 2221 and 10-minute-level indicator 2222, it is necessary to record the values corresponding to a limited number of time points to count PV and UV. Each Counter in Counter_t1, Counter_t2, etc. in the first row of minute-level indicator 2221 and 10-minute-level indicator 2222 is a 64-bit unsigned integer (Unit64) corresponding to the corresponding moment, which is used to count PV, and each Hll in Hll_t1, Hll_t2, etc. in the second row is the cardinality (Hyperloglog) corresponding to the corresponding moment, which is used to count UV. Uuid set 2223 contains the log identifier (Uuid) sequence of the flow log that has been recently aggregated to indicator 222.
[0094] In some embodiments, the server includes a shared memory, and the shared memory is the / dev / shm / directory of the server, which is used to represent a storage space mounted in the memory. The server includes at least one storage engine, and at least one storage engine is used to cache corresponding data in the shared memory, or it is understood that at least one storage engine is an embedded KV storage engine (RocksDB) instance written in C++, which is essentially a file on the shared memory, and its cached indicators are placed in the shared memory of the server. In this embodiment, the server also performs aggregation and conversion on the water flow log to obtain indicators of different time granularities, and caches them to at least one storage engine. Optionally, when caching, it can be a write-time cache or a read-time cache. The write-time cache refers to caching when writing indicators to at least one storage engine, and the read-time cache refers to caching in at least one storage engine when reading a certain indicator, which will be described in detail in subsequent embodiments. In this embodiment, the shared memory of the server has higher read and write performance than the disk, which can improve the query efficiency of the indicator. Moreover, when the process exits, the data in the shared memory still exists to avoid data loss.
[0095] Optionally, the server receives the query request and obtains the target indicator corresponding to the query request from the indicators of different time granularities of the write-time cache or read-time cache of at least one storage engine of the server in the shared memory. In some embodiments, when at least one storage engine is one storage engine, the target indicator can be obtained from the storage engine. When at least one storage engine is multiple storage engines, the target indicator is queried according to the preset query order corresponding to the multiple storage engines, or the preset priority corresponding to the multiple storage engines, or the query order indicated by the query request, or the target storage engine in at least one storage engine indicated by the query request, or the data attribute of the target indicator. Among them, the data attribute includes one of cold data and hot data. Cold data refers to data with an access frequency lower than a threshold and is not frequently queried. Hot data refers to data with an access frequency higher than a threshold and is frequently queried. For example, at least one storage engine includes storage engine 1 and storage engine 2, and the preset query order is storage engine 1, storage engine 2, or the data attribute of the target indicator is hot data, then the target indicator is first queried from storage engine 1, and when it is not queried (miss), the target indicator is continued to be queried in storage engine 2.
[0096] In a possible implementation, the server of this embodiment is a server in a server cluster (Set), and the servers in a server cluster are mutually active and standby, and the indicators in each server in the same server cluster are synchronized and completely consistent. When querying the target indicator, it can be queried from any server in the server cluster.
[0097] Here, we also provide some additional explanations for the server cluster (Set). Define data shards (Shard), and these indicator-related data are stored on data shards. Each server cluster contains multiple data shards. Each server in the same server cluster holds the same data shards, and the data shards between different server clusters do not overlap. For example, 9 servers are divided into 3 server clusters: Set0, Set1, and Set2, and each server cluster contains 3 servers. The number of data shards is defined as a fixed value of 65536. Through the consistent hashing algorithm, each data shard corresponds to a unique server cluster. For all logs and indicators, their keywords (Key) will have some common parts, such as the promotion_id in the aforementioned embodiment. A hash algorithm is executed based on the promotion_id to obtain a hash value. The number of data shards 65536 is modulo based on the hash value to obtain the corresponding data shard identifier (Shard_Id). The server cluster identifier (Set_Id) corresponding to the data shard identifier is obtained through the consistent hashing algorithm. Next, the server cluster corresponding to the server cluster identifier is determined through the routing table. The routing table stores the server cluster identifier and its corresponding server cluster, thereby determining any one of the three servers in the server cluster used for the query.
[0098] Specifically, the server used in this embodiment is any server in the server cluster. Before obtaining the target indicator corresponding to the query request from the indicators of different time granularities of the write-time cache or read-time cache of at least one storage engine of the server in the shared memory in step 340, it is necessary to first determine the server cluster where the server is located. Specifically, based on the keyword corresponding to the query request and the defined number of data shards, a hash algorithm is executed on the keyword to obtain a hash value, and the number of data shards is modulo based on the hash value to obtain the data shard identifier corresponding to the keyword; the server cluster identifier corresponding to the data shard identifier is obtained by a consistent hashing algorithm; the server cluster corresponding to the server cluster identifier is determined by a routing table, and the routing table stores the server cluster identifier and its corresponding server cluster, and any server in the server cluster is determined as the server used for the query.
[0099] Step 360: Return the target indicator corresponding to the query request to the client.
[0100] Exemplarily, the server returns the target indicator corresponding to the query request to the client. Optionally, the target indicator can be displayed as a numerical value on the client, for example, as at least one of the number of likes, the number of reposts, and the activity level, or the client is further used to display recommended content based on the target indicator, and the recommended content can be at least one of a short video, a recommended image, a recommended text, and a recommended advertisement.
[0101] In summary, the query method of indicators provided in the embodiment of the present application is that the server receives the query request of the client, and the query request is used to indicate the target indicator of the target time granularity of the query target time period; the target indicator corresponding to the query request is obtained from the indicators of different time granularities cached in the shared memory of at least one storage engine of the server when writing or reading, the write-time cache refers to the cache when the indicator is written to at least one storage engine, and the read-time cache refers to the cache in at least one storage engine when reading the indicator, and the indicator is obtained by performing aggregation and conversion on the flow log reported by the client; the target indicator corresponding to the query request is returned to the client. Accordingly, the indicators of different time granularities are stored in the shared memory through the read-time cache and write-time cache of at least one storage engine in the server, and the full memory cache of the indicators of different time granularities is realized, so that the indicators do not need to be retrieved from the disk when querying. Since the shared memory read takes less time than the disk read, the query time of the indicator can be reduced, and thus the demand for external display of the indicator and the demand of the real-time recommendation system can also be met.
[0102] In some embodiments, in order to ensure the accuracy of the query, the server also stores indicators of different time granularities in the form of key-value pairs. Figure 6 340 is specifically implemented as step 342.
[0103] Step 342, based on the keyword corresponding to the query request, obtain the target indicator corresponding to the query request from the indicators of different time granularities cached during write or read in the shared memory of at least one storage engine of the server; wherein, at least one storage engine is used to cache indicators of different time granularities corresponding to different keywords in the form of key-value pairs, and the keywords and indicators correspond one-to-one.
[0104] A key-value pair includes a keyword (Key) and its corresponding value (Value). The keyword is used as the index of the data, and the value represents the data stored and read. The data in this embodiment is the specific value of the indicator at different time granularities.
[0105] Optionally, in at least one storage engine, at least one storage engine is used to cache indicators of different time granularities corresponding to different keywords in the form of key-value pairs, and the keywords correspond to the indicators one-to-one. Then, based on the keyword corresponding to the query request, the server obtains the target indicator corresponding to the query request from the indicators of different time granularities cached during write or read in the shared memory of at least one storage engine of the server.
[0106] In this embodiment, the server stores keywords and their corresponding indicators in the form of key-value pairs, so that the keywords and indicators are uniquely corresponding, which can improve the query efficiency of the indicators and ensure the accuracy of the query.
[0107] In some embodiments, Figure 7 1 is a system diagram of an indicator query method provided by an exemplary embodiment of the present application, involving a client 10 and a server 20. The client 10 includes a shared memory 11. The server 20 includes a shared memory ( Figure 7 (not shown), the server 20 includes at least one storage engine, and the at least one storage engine specifically includes a first storage engine (LogDB) 21 and a second storage engine (Map DB) 22. The first storage engine 21 is used to cache the running log, and the running log can also be understood as: the running log recently reported by the client. The second storage engine 22 is used to cache the first type of indicators when writing in the shared memory. The first type of indicators are indicators obtained after updating the indicators to be updated at different time granularities based on the running log. The first type of indicators can also be understood as: indicators that have been updated recently. The logical components of the server 20 include a log processing component (Log ETL) 25, and the log processing component 25 is used to perform aggregation and transformation (Aggregate&Transformer) based on the running log (Recent Log Extract) and the indicators to be updated to update the indicators to be updated, obtain the first type of indicators, and write the first type of indicator updates to the second storage engine 22, that is, locally load (Locally Load) to the second storage engine 22. The second storage engine 22 caches the first type of indicators based on the update writing of the log processing component 25 to the second storage engine 22. The process of the second storage engine 22 caching the first type of indicators is: write-time caching.
[0108] In some embodiments, based on the server 20 including the first storage engine 21 and the second storage engine 22, at least one storage engine of the server 20 further includes a third storage engine (Read Cache) 23, and the third storage engine 23 is used to cache the second type of indicators during reading, and the second type of indicators are indicators of different time granularities read from the backend storage engine (TTL KV) 24 that have not been updated and are queried by this query request or the last query request. The second type of indicators can also be understood as indicators that have not been updated recently but have been queried. The backend storage engine 24 is used to cache all indicators, and the third storage engine 23 caches the second type of indicators, which is implemented based on the reading of the backend storage engine 24. The process of the third storage engine 23 caching the second type of indicators is: read-time caching.
[0109] It should also be noted that, since the statistical method of the indicator may not involve reading the backend storage engine 24, but may involve the aggregation and conversion of the running log by the log processing component 25 and the update writing to the second storage engine 22, the third storage engine 23 may not be used temporarily in the statistical method of the indicator. In other embodiments, the backend storage engine 24 may be located in the current server, may be located in other servers, or may be a storage engine specifically used to provide reliability storage services, which is not limited in this embodiment.
[0110] For example, continue to refer to Figure 6 , then step 342 can be specifically implemented as step 3421.
[0111] Step 3421, based on the keyword corresponding to the query request, obtain the target indicator corresponding to the query request from the first type of indicators cached by the second storage engine during write in the shared memory.
[0112] The second storage engine (Map DB) is used to cache the first type of indicators, that is, the indicators that have been updated recently. These first type of indicators are placed on the shared memory of the server and cached in the form of key-value pairs.
[0113] Exemplarily, the server obtains the target indicator corresponding to the query request from the first type of indicators cached by the second storage engine in the shared memory when writing based on the keyword corresponding to the query request. For example, the query request is represented as: Q2: promotion_id=1, action_type=exposure, scene=hot, total UV in the last hour, then the keyword of the query request is Key=promotion_1_exposure_hot, the target time period is the last hour, the target indicator is total UV, and the specific value of the target indicator corresponding to the above keyword is queried from the second storage engine.
[0114] In this embodiment, based on the assumption that recently updated indicators are generally easier to query in a short period of time, the indicators obtained by aggregation and transformation are cached in the second storage engine (Map DB) as a write-time cache. When querying indicators, the second storage engine is first queried to achieve fast query of indicators, and these indicators cached by the second storage engine (Map DB) are placed in shared memory. Since shared memory reading takes less time than disk reading, the query time of the indicators can be reduced.
[0115] In some embodiments, when the target index is not found (missed) in the second storage engine, it means that the target index is not a recently updated index, and the third storage engine can be queried. Exemplarily, step 342 is further implemented as step 3422 based on step 3421.
[0116] Step 3422, when the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request, obtain the target indicator corresponding to the query request from the second type of indicator cached when the third storage engine reads in the shared memory.
[0117] The third storage engine (Read Cache) is used to cache the second type of indicators, that is, indicators that have not been updated recently but have been queried. These second type of indicators are placed on the shared memory of the server and cached in the form of key-value pairs.
[0118] Exemplarily, when the server fails to find the target indicator corresponding to the query request from the second storage engine, it indicates that the target indicator is not a recently updated indicator. Next, based on the keyword corresponding to the query request, the server continues to obtain the target indicator corresponding to the query request from the second type of indicator cached in the shared memory by the third storage engine during reading. It should be noted that the second type of indicator cached in the shared memory by the third storage engine during reading can be based on the current query request or based on the cached during reading of the last query request. The last query request refers to any query request before the current query request.
[0119] For example, suppose that the last query request 1 is used to indicate that the target indicator 1 is queried, and the current query request 2 is used to indicate that the target indicator 1 is queried. For the last query request 1, when the server fails to query the target indicator 1 from the second storage engine, the server continues to query the target indicator 1 from the second type of indicator cached when reading from the shared memory by the third storage engine. When the target indicator 1 is still not queried from the third storage engine, the third storage engine penetrates to the backend storage engine to read the target indicator 1 from the backend storage engine and cache the target indicator 1 for the next query, which is convenient for the current query request 2. For the current query request 2, when the server fails to query the target indicator 1 from the second storage engine, the server queries the target indicator 1 from the second type of indicator cached when reading from the shared memory by the third storage engine. Assuming that the query request 2 this time is used to indicate that the target indicator 2 has been queried, when the server fails to query the target indicator 2 from the second storage engine, the server queries the target indicator 2 from the second type of indicator cached when the third storage engine reads in the shared memory. When the target indicator 2 is not queried from the third storage engine, the third storage engine is used to penetrate to the backend storage engine to read the target indicator 2 from the backend storage engine and cache the target indicator 2 for the next query.
[0120] In this embodiment, the backend storage engine is used as reliability storage, which can save all indicators and ensure that data is not lost. When the target indicator is not queried from the second storage engine, it is necessary to penetrate to the backend storage engine, and cache the indicators read from the backend storage engine in the third storage engine (Read Cache) as a read-time cache. First, the indicators can be successfully read, and second, the next query for these indicators can be convenient, improving the response speed of the next query.
[0121] Next, the statistical method of the indicators provided in the embodiments of the present application is described.
[0122] Figure 8 is a flowchart of a statistical method for an indicator provided by an exemplary embodiment of the present application. The method is executed by a computer device, which may be Figure 1 The server 140 is shown. The method includes at least part of steps 420, 440 and 460.
[0123] Step 420: Receive the transaction log reported by the client.
[0124] A logbook is a log that records at least one of the detailed information of the various operating states of an application or application system, user operations and events, access status, timestamp, protocol type, user account ID (promotion_id), login method, login IP address, content ID involved, behavior type (action_type), and scene value (Scene). Optionally, the behavior type includes at least one of click, long press, exposure, slide, update, delete, add, modify, and forward. The scene value is determined based on the scene when the logbook is generated, and can be expressed as a descriptive word corresponding to the scene. For example, the scene value is at least one of friends, hot, short video, and live broadcast. It should also be noted that these detailed information in the logbook are all agreed and authorized information.
[0125] In some embodiments, the client reports the log flow to the server, and the server receives the log flow reported by the client. Optionally, the client includes a shared memory, and the shared memory is the / dev / shm / directory of the client, which is used to represent a storage space mounted in the memory. The log flow is reported in batches, and the client is used to batch multiple log flow in the shared memory. When the set conditions are met, multiple log flow with the same keyword (Key) are merged to obtain pre-processed log flow, and these pre-processed log flow are reported to the server.
[0126] Optionally, the setting condition can be set to at least one of the following: reaching a preset time point, reaching a preset duration, the time difference between the earliest log and the current time reaches a preset time difference, the number of logs reaches a preset number, the storage space occupied by the logs reaches a preset storage space size or the storage space size of the shared memory. For example, if the storage space size of the shared memory of the client is 1GB, when the log has reached 1GB, or has reached 500, or the earliest log is 100 milliseconds away, then the merging of multiple logs is performed.
[0127] For example, the keywords of N logbooks are all: (promotion_id_1, action_type_exposure, scene_friend) + 1, and the client converts these N logbooks into 1 logbook of (promotion_id_1, action_type_exposure, scene_friend) + N. Next, a Remote Procedure Call (RPC) request is issued in batches to report the logbooks to the client in batches. This embodiment is equivalent to batching logbooks in shared memory. Since the client may be multi-process and multi-threaded, this batching method can be used for multi-process and multi-threaded, and read-write conflicts are handled through lightweight locks.
[0128] Step 440 , aggregate and transform the logbook to obtain indicators of different time granularities.
[0129] Indicators can reflect information such as user acquisition, activity, retention, conversion, and behavior.
[0130] Optionally, the indicator includes at least one of page views (PV), unique visitors (UV), visitor visits (VV), and unique IP addresses. Page views are the number of page views, which are used to measure the number of web pages visited by website users. Unique visitors refer to the number of users who visit a website within a period of time. Visitor visits refer to the number of times all visitors visit a website within a period of time. Unique IP addresses refer to the number of times users with different IP addresses visit a website within a period of time. The aforementioned different types of indicators all include different time granularities. Optionally, the time granularity includes at least one of minutes, hours, days, months, and years. For example, taking page views as an example, indicators of different time granularities may be page views per minute or page views per day. The aforementioned period of time may be a set fixed duration, or may be determined based on different time granularities.
[0131] Exemplarily, the server performs aggregation and transformation (Aggregate & Transformer) on the log flow to obtain indicators of different time granularities. For example, the timestamp corresponding to the log flow is used to calculate the indicators at time granularities such as minutes, 10 minutes, hours, and days corresponding to the log flow. For example, if the timestamp of the reported log flow is 20240610 10:09, then the minute corresponding to the log flow is 20240610 10:09, the corresponding 10 minutes is 20240610 10:00, the corresponding hour is 20240610 10:00, and the corresponding day is 20240610 00:00. The indicators to be updated corresponding to these timestamps are found from the original indicators, and the indicators to be updated are obtained after these indicators to be updated. In some embodiments, aggregation and transformation of the log flow is implemented based on the log processing component (Log ETL) in the server.
[0132] In some embodiments, the server also includes an anti-reentry component (Anti-Reentry). Before the server aggregates and converts the logbook, it also filters the logbooks that are repeatedly reported by the client based on the anti-reentry component. Specifically, the anti-reentry component is used to generate a log identifier (Uuid) corresponding to the logbook, and to filter the logbooks that are repeatedly reported by the client by judging whether the log identifier of the logbook already exists in the log identifier sequence set included in the corresponding indicator, so as to avoid duplicate counting. Among them, the log identifier sequence set generally stores a maximum of 5,000 log identifiers in the last 10 minutes.
[0133] Step 460, cache the indicators of different time granularities to at least one storage engine of the server, at least one storage engine is used to cache the indicators of different time granularities when writing or reading in the shared memory, write-time caching refers to caching when writing the indicators to at least one storage engine, and read-time caching refers to caching in at least one storage engine when reading the indicators.
[0134] In some embodiments, the server includes a shared memory, and the shared memory is the / dev / shm / directory of the server, which is used to represent a storage space mounted in the memory. The server includes at least one storage engine, and at least one storage engine is used to cache corresponding data in the shared memory, or it is understood that at least one storage engine is an embedded KV storage engine (RocksDB) instance written in C++, which is essentially a file on the shared memory, and its cached indicators are placed in the shared memory of the server. In this embodiment, the server also performs aggregation and conversion on the water flow log to obtain indicators of different time granularities, and caches them to at least one storage engine. Optionally, when caching, it can be a write-time cache or a read-time cache. The write-time cache refers to caching when writing indicators to at least one storage engine, and the read-time cache refers to caching in at least one storage engine when reading a certain indicator, which will be described in detail in subsequent embodiments. In this embodiment, the shared memory of the server has higher read and write performance than the disk, which can improve the query efficiency of the indicator. Moreover, when the process exits, the data in the shared memory still exists to avoid data loss.
[0135] Optionally, the server caches the indicators of different time granularities to at least one storage engine of the server, and the at least one storage engine is used to cache the indicators of different time granularities when writing or reading in the shared memory. It should be noted that step 420, step 440 and step 460 can be performed before step 320, or step 320 is performed after step 460, or step 320 and step 460 are performed synchronously.
[0136] In summary, the statistical method of indicators provided by the embodiment of the present application is that the server receives the running log reported by the client; performs aggregation and conversion on the running log to obtain indicators of different time granularities; caches the indicators of different time granularities to at least one storage engine of the server, and at least one storage engine is used to cache the indicators of different time granularities when writing or reading in the shared memory. The write-time cache refers to caching when the indicator is written to at least one storage engine, and the read-time cache refers to caching in at least one storage engine when reading the indicator. Accordingly, the server can perform aggregation and conversion on the running log reported by the client to obtain indicators of different time granularities, which can improve the statistical speed of the indicator. Through the read-time cache and write-time cache of at least one storage engine in the server, the indicators of different time granularities are stored in the shared memory, and the full memory cache of the indicators of different time granularities is realized, so that the indicators do not need to be retrieved from the disk when querying. Since the shared memory read takes less time than the disk read, it can reduce the query time of the indicator, and thus can also meet the needs of the external display of the indicator and the needs of the real-time recommendation system.
[0137] In some embodiments, the server includes a log processing component (Log ETL), which is used to perform aggregation and transformation on the log flow. Fig. 9 4 is a flow chart of a statistical method for indicators provided by an exemplary embodiment of the present application. Then step 440 is specifically implemented as step 442.
[0138] Step 442: Aggregate and transform the log flow based on the log processing component to obtain indicators of different time granularities.
[0139] Specifically, the log processing component (Log ETL) is used to perform aggregation and transformation (Aggregate & Transformer) based on the recent log (RecentLog Extract) reported by the client to obtain indicators of different time granularities. The server then performs aggregation and transformation on the log based on the log processing component to obtain indicators of different time granularities.
[0140] In this embodiment, the log processing component of the server can realize the aggregation and conversion of the running log, so that the indicators of different time granularities can be quickly obtained, thereby improving the statistical efficiency of the indicators.
[0141] In some embodiments, indicators of different time granularities are indicators of the first type, and at least one storage engine includes a first storage engine (Log DB) and a second storage engine (Map DB). The first storage engine is used to cache the running log, which can also be understood as: the running log recently reported by the client. The second storage engine is used to cache the first type of indicators when writing in the shared memory. The first type of indicators are indicators obtained after updating the indicators to be updated of different time granularities based on the running log. The first type of indicators can also be understood as: indicators that have been updated recently.
[0142] For example, continue to refer to Fig. 9 , step 442 can be optionally implemented as step 4421 and step 4422.
[0143] Step 4421, based on the log processing component, batch read the log flow from the first storage engine, and query the indicators to be updated of different time granularities from the second storage engine.
[0144] The first storage engine (Log DB) is used to cache log files, and the log processing component (Log ETL) can read log files in batches from the first storage engine according to a set reading cycle or a set reading quantity, and query the indicators to be updated at different time granularities from the second storage engine (Map DB).
[0145] Exemplarily, the server reads the log flow log in batches from the first storage engine based on the log processing component, and queries the updated indicators of different time granularities from the second storage engine. These two processes can be executed successively or synchronously, and this embodiment does not limit this.
[0146] Step 4422, performing aggregation and conversion based on the flow log and the indicator to be updated to update the indicator to be updated and obtain the first type of indicator.
[0147] The server performs aggregation and conversion based on the running log and the indicator to be updated through the log processing component to update the indicator to be updated and obtain the first type of indicator. Optionally, the server performs permutations and combinations based on the log attributes of the running log through the log processing component to obtain the keyword corresponding to the running log; the indicator to be updated is read based on the keyword, and the plus N operation is performed on the indicator to be updated to update the indicator to be updated to obtain the first type of indicator, where N is greater than 0. In some embodiments, when at least one storage engine is one storage engine, when the indicator to be updated is read based on the keyword, the indicator to be updated is obtained from the storage engine. When at least one storage engine is multiple storage engines, the indicator to be updated is queried according to the preset query order corresponding to the multiple storage engines, or the preset priority corresponding to the multiple storage engines.
[0148] For example, the log processing component performs permutations and combinations based on the log attributes of the running log to generate keywords (Key) corresponding to indicators of different time granularities. Next, the indicator to be updated is read from the second storage engine (Map DB), the third storage engine (ReadCache), and the backend storage engine (TTL KV) in sequence, and the indicator to be updated is executed +N to obtain a new indicator, that is, an indicator of the first type, and the new indicator is returned. Subsequently, the log processing component can also write the new indicator to the second storage engine.
[0149] In this embodiment, the log processing component reads batch logs from the first storage engine, and queries the indicators to be updated of different time granularities from the second storage engine. Next, aggregation and conversion are performed based on the logs and the indicators to be updated to update the indicators to be updated, and the indicators of the first type are obtained, thereby realizing the update of the indicators and improving the statistical efficiency of the indicators.
[0150] In some embodiments, in order to reduce the delay in the effectiveness of the running log, the log processing component (Log ETL) is split into multiple threads. However, when each of the multiple threads is used to scan the same first storage engine (Log DB), a large number of invalid repeated scans will be generated. Therefore, this embodiment also splits the first storage engine (Log DB) into multiple column families (Column Family, CF), each of the multiple column families includes a part of the running log in the first storage engine (Log DB), and the reading and writing of each column family are independent. Then, each thread of the log processing component (Log ETL) is used to scan the running log corresponding to at least one column family in the first storage engine, that is, a part of the running log, and the number of threads and the number of column families can be the same.
[0151] Specifically, the server of this embodiment is a server in a server cluster. In combination with the above-mentioned embodiments, it can be seen that the data shards held by the servers in a server cluster are completely consistent. It is usually necessary to select one server in the server cluster as the host and the other servers as backup machines. However, this will cause only the host to be able to write, resulting in an imbalance in the central processing unit (CPU) resources. Therefore, this embodiment also configures the number of threads in each server cluster. For example, a server cluster is configured as 9 threads, and correspondingly, 9 column families (Column Family, CF) are configured in the first storage engine (LogDB). The 9 threads select the master by priority, and try to make the number of main threads held by each server in the server cluster equal. For example, the server cluster includes 3 servers: M0, M1, and M2, and the number of configured threads is 9, then each server has 9 threads, and correspondingly, the first storage engine (Log DB) has 9 column families. When the running log is reported and written to the first storage engine (Log DB), the server takes the hash value of the keyword corresponding to the running log modulo 9 and calculates the column family ID corresponding to the running log, so as to synchronously write the running log to the column family corresponding to the column family ID in the first storage engine (Log DB) of the three servers. Among them, the 9 threads select the master by priority. For example, by default, the master of threads 0, 1, and 2 is M0; the master of threads 3, 4, and 5 is M1; and the master of threads 6, 7, and 8 is M2. For threads 0, 1, and 2, aggregation and transformation are performed on the running logs in column families 0, 1, and 2 on the M0 server respectively. After generating indicators of different time granularities, they are written to the second storage engine (Map DB) of the local machine, and the running logs of column families 0, 1, and 2 of the first storage engine (MapDB) of the local machine are deleted. At the same time, they are written to the second storage engine (Map DB) in the M1 and M2 servers through RPC requests, and the running logs corresponding to column families 0, 1, and 2 of the first storage engine (Map DB) on the M1 and M2 servers are deleted. Since the master and backup machines here are based on threads, from the perspective of server granularity, the servers in the same server cluster are master and backup for each other. It should also be noted that other logical components of the server: Anti-Reentry, Bin Log Sync, and In-Set Sync are all based on servers and are shared by multiple threads.
[0152] Exemplarily, the log processing component (Log ETL) includes multiple threads, including a main thread, and the main thread of the log processing component (Log ETL) performs aggregation and conversion of the log flow. In other embodiments, when the server is a server in a server cluster, the server where the main thread of the log processing component (Log ETL) is located is also called the main server, and the other servers are called backup servers. Fig. 9 , step 4422 specifically includes step 4422A and step 4422B.
[0153] Step 4422A, through the main thread of the log processing component, perform permutations and combinations based on the log attributes of the log journal to obtain keywords corresponding to the log journal.
[0154] Step 4422B, based on the keyword, read the indicator to be updated, perform an add N operation on the indicator to be updated to update the indicator to be updated, and obtain a first type of indicator, where N is greater than 0.
[0155] Exemplarily, the server performs permutations and combinations based on the log attributes of the running log through the main thread of the log processing component to obtain keywords corresponding to the running log; based on the keywords, the index to be updated is read, and the index to be updated is added with N to update the index to be updated, so as to obtain the first type of index, where N is greater than 0. In some embodiments, when at least one storage engine is one storage engine, when the index to be updated is read based on the keywords, the index to be updated is obtained from the storage engine. When at least one storage engine is multiple storage engines, the index to be updated is queried according to the preset query order corresponding to the multiple storage engines, or the preset priority corresponding to the multiple storage engines.
[0156] For example, the main thread of the log processing component performs permutations and combinations based on the log attributes of the running log to generate keywords (Key) corresponding to indicators of different time granularities. Next, the indicator to be updated is read from the second storage engine (Map DB), the third storage engine (Read Cache), and the backend storage engine in turn, and the indicator to be updated is executed +N to obtain a new indicator, that is, an indicator of the first type, and the new indicator is returned. Subsequently, the log processing component can also write the new indicator to the second storage engine.
[0157] In this embodiment, by splitting the log processing component into multiple threads, the main thread performs aggregation and conversion on the running logs. First, it is possible to obtain indicators of different time granularities based on these running logs to avoid repeated scanning of the running logs by multiple threads. Second, it is possible to move the server's master election logic from the server machine level to the thread level, so that the servers in each server cluster (Set) are mutually master-slave, reducing the CPU consumption of a single host. It should be noted that master election is a unique mechanism for complex distributed services, which aims to ensure the consistency of system data. Among them, the distributed service generally stores data in the form of: each node (that is, the server) stores the full amount of data, so that each node can provide "consistent" services to the outside world, which involves data synchronization between different nodes. Master election is an important link to ensure the consistency of data in each node of the service after triggering and controlling data changes within the service and after the change.
[0158] In some embodiments, the indicators of different time granularities refer to the first type of indicators, and the first type of indicators can also be understood as: indicators that have been updated recently. After the indicators have been updated based on the running log, these first type of indicators can also be updated and written to the second storage engine to cache these first type of indicators. Then step 460 is specifically implemented as step 462.
[0159] Step 462, based on the log processing component, write the first type of indicator update to the second storage engine of the server.
[0160] The log processing component is also used to update and write these first type of indicators into the second storage engine of the server. Exemplarily, the server writes the first type of indicator updates to the second storage engine of the server based on the log processing component. Wherein, update writing can also be understood as overwriting writing.
[0161] In this embodiment, by writing the first type of indicator update to the second storage engine of the server based on the log processing component, the new indicator can be cached in the second storage engine to facilitate the query of the indicator.
[0162] In some embodiments, the server includes a first synchronization component (Bin Log Sync). After step 460 or simultaneously with step 460 , the method may further optionally include step 470 .
[0163] Step 470: Synchronize the first type of indicators to the backend storage engine based on the first synchronization component.
[0164] The first synchronization component (Bin Log Sync) is used to synchronize indicators of various time granularities and updated indicators to the backend storage engine (TTL KV), and the backend storage engine is used to cache all indicators, including updated and non-updated indicators. Exemplarily, the server also synchronizes the first type of indicators to the backend storage engine based on the first synchronization component. It should be noted that the backend storage engine can be located in the current server, can also be located in other servers, and can also be a storage engine specifically used to provide reliability storage services, which is not limited in this embodiment.
[0165] In this embodiment, by synchronizing the first type of indicators to the backend storage engine based on the first synchronization component, reliable storage of the indicators can be ensured and loss of the indicators can be effectively avoided.
[0166] In some embodiments, after the index has been updated based on the logbook, the logbooks that have been aggregated and converted may also be deleted. Then, after step 460 and / or step 470, or simultaneously with step 460 and / or step 470, the method may further optionally include step 480.
[0167] Step 480: Delete the processed journal log in the first storage engine based on the log processing component.
[0168] The log processing component can also directly delete the processed log journal in the first storage engine. Exemplarily, the server also deletes the processed log journal in the first storage engine based on the log processing component.
[0169] In this embodiment, by deleting the processed log logs in the first storage engine based on the log processing component, the processed (or aggregated) log logs in the first storage engine can be deleted in time to avoid occupying the storage space of the first storage engine, thereby facilitating the subsequent storage of new log logs.
[0170] In some embodiments, the server includes a second synchronization component (In-Set Sync). Optionally, this embodiment further sets a server cluster (Set), and a server cluster includes multiple servers. For a server cluster, the data shards held by each server contained therein are the same, and the data shards between different server clusters do not overlap. This embodiment also writes the indicators updated by the host to the standby machine, and the host and the standby machine can provide query services at the same time. The steps of the foregoing embodiments are all executed by the server, which can be a server in the server cluster, also referred to as the host, and the other servers are referred to as standby machines. Each server in the server cluster includes at least one storage engine, and each server is used to synchronously receive the flow log reported by the client, and cache the flow log to the first storage engine in at least one storage engine.
[0171] Exemplarily, after the host has updated the index based on the logbook, in addition to deleting the aggregated and converted logbooks in the host, the aggregated and converted logbooks in the standby machine may also be deleted to avoid occupying the storage space of the first storage engine of the standby machine. Then, after step 460 and / or step 470, or simultaneously with step 460 and / or step 470, the method may further optionally include step 520.
[0172] Step 520, sending a first notification message to the second synchronization component based on the log processing component; wherein the first notification message is used to instruct the second synchronization component to delete the processed log flow in the first storage engine of other servers in the server cluster.
[0173] The log processing component is also used to notify the second synchronization component to delete the processed log flow in the standby machine, and the second synchronization component is used to directly delete the processed log flow in the standby machine. Exemplarily, the server sends a first notification message to the second synchronization component based on the log processing component, and the first notification message is used to instruct the second synchronization component to delete the processed log flow in the first storage engine of other servers in the server cluster.
[0174] In this embodiment, since the host and the backup machine synchronously receive the log flow reported by the client, the log processing component can send a first notification message to the second synchronization component to instruct the second synchronization component to delete the processed log flow in the first storage engine of other servers in the server cluster. The processed (or aggregated) log flow in the first storage engine of the host and the backup machine can be deleted in time to avoid occupying the storage space of the first storage engine of the backup machine, thereby facilitating the backup machine to continue to store new log flow.
[0175] In some embodiments, after the host has updated the indicators based on the journal log, the first type of indicators can also be updated and written to the second storage engine of the standby machine, so as to cache the first type of indicators in the standby machine. Then, after step 460 and / or step 470 and / or step 480, or simultaneously with step 460 and / or step 470 and / or step 480, the method can also optionally include step 540.
[0176] Step 540, sending a second notification message to the second synchronization component based on the log processing component; wherein the second notification message is used to instruct the second synchronization component to synchronize the first type of indicator to a second storage engine in at least one storage engine of other servers in the server cluster.
[0177] The log processing component is also used to notify the second synchronization component to synchronize the first type of indicators to the standby machine, and the second synchronization component is used to synchronize the second synchronization component to the second storage engine of the standby machine. Exemplarily, the server sends a second notification message to the second synchronization component based on the log processing component, and the second notification message is used to instruct the second synchronization component to synchronize the first type of indicators to the second storage engine in at least one storage engine of other servers in the server cluster.
[0178] In this embodiment, by sending a second notification message to the second synchronization component based on the log processing component, it is used to instruct the second synchronization component to synchronize the first type of indicators to the second storage engine in at least one storage engine of other servers in the server cluster, and these indicators can also be synchronized to the standby machine. When a host is restarting or an abnormality occurs in the host, the statistical task for the indicator in the host can continue to be executed in the standby machine, and the indicators in the standby machine and the host can maintain consistency, thereby ensuring the read and write performance and final consistency of the indicator.
[0179] Next, the statistical and query methods of the indicators provided in the embodiments of the present application are explained with reference to the diagrams.
[0180] Overall architecture.
[0181] Fig.10 It is a schematic diagram of a statistical method for indicators provided by an exemplary embodiment of the present application, which mainly involves a client 10 and a server 20 (also referred to as a host 20), and also involves a backend storage engine 24, wherein the backend storage engine 24 can be located in the server 20 or in other servers, and can also be a storage engine specifically used to provide reliability storage services, which is not limited in this embodiment.
[0182] The client 10 includes a shared memory 11. The client 10 involves a logical component including a shared memory aggregation component (Shared Memory Aggregation) ( Fig.10 (not shown) is used to implement the logic of batching and merging the running logs based on the shared memory 11 of the client 10.
[0183] The server 20 includes a shared memory ( Fig.10(not shown), the server 20 includes three storage engines and four logical components. The three storage engines include a first storage engine (Log DB) 21, a second storage engine (Map DB) 22, and a third storage engine (Read Cache) 23. The four logical components include a log processing component (Log ETL) 25, a first synchronization component (Bin LogSync) 28, a second synchronization component (In-Set Sync) 27, and an anti-reentry component (Anti-Reentry) 29. In other embodiments, the above three storage engines and four logical components of the server 20 can also be combined to be called an online counting and statistics system.
[0184] The first storage engine 21 is used to cache the logs recently reported by the client 10. The second storage engine 22 is used to cache the recently updated indicators when writing in the shared memory. The third storage engine 23 is used to cache the indicators that have not been updated recently but have been queried when reading in the shared memory.
[0185] The anti-reentry component (Anti-Reentry) 29 is used to generate a log identifier (Uuid) corresponding to the log flow log, and to filter the log flow logs repeatedly reported by the client 10 to avoid repeated counting by judging whether the log identifier of the log flow log already exists in the log identifier sequence set included in the corresponding indicator. The log identifier sequence set generally stores a maximum of 5,000 log identifiers within the last 10 minutes.
[0186] The log processing component 25 is used to batch read the recent log flow (Recent LogExtract) and the original indicators (indicators to be updated) in the shared memory from the first storage engine 21 to perform aggregation and transformation (Aggregate & Transformer) to update the indicators to be updated to obtain new indicators, and to update and write the new indicators to the second storage engine 22, that is, to locally load (Locally Load) to the second storage engine 22. The first synchronization component (Bin Log Sync) 28 is used to synchronize the recently updated indicators to the backend storage engine 24. The servers in the same server cluster (Set) are master and backup to each other. After the log flow of the host is aggregated and transformed to obtain indicators, the second synchronization component (In-Set Sync) 27 is used to delete the relevant log flow in the server cluster, and to synchronize the updated indicators to other servers 30 (also called backup machines 30) in the server cluster where the server is located.
[0187] The overall process of aggregation and master-slave synchronization.
[0188] refer to Fig.11, the client 10 synchronously reports (Report) the watermark log to the first storage engine 21 of the host 20 and the first storage engine 31 of the backup machine 30; for the host 20, the log processing component 25 regularly scans the watermark log in batches, and queries the indicators to be updated from the second storage engine 22. The log processing component 25 performs aggregation and transformation based on the watermark logs and the indicators to be updated scanned in batches from the first storage engine 21 to update the indicators to be updated to obtain new indicators, and notifies the second synchronization component 27 to synchronize these new indicators to the second storage engine 32 in the backup machine 30. The log processing component 25 deletes the processed watermark logs in the first storage engine 21, and notifies the second synchronization component 27 to delete the corresponding watermark logs in the first storage engine 31 in the backup machine 30. At the same time, the first synchronization component 28 ( Fig.11 (not shown) also synchronizes these new metrics to the backend storage engine 24.
[0189] The overall process of indicator query.
[0190] Combined with reference Figure 7 and Fig.10 The client 10 sends a query request to the server 20. The query request is used to indicate the query target indicator. The server 20 receives the query request and first queries the target indicator from the second storage engine 22 based on the keyword corresponding to the query request. If the target indicator is not found, it indicates that the target indicator has not been updated recently. Next, the target indicator is queried from the third storage engine 23. If the target indicator is not found, it penetrates to the backend storage engine 24, pulls the target indicator from the backend storage engine 24 and caches it in the third storage engine 23, obtains the target indicator and facilitates the next query.
[0191] Application scenarios.
[0192] The method of the embodiment of the present application can be applied to the statistics and query scenarios of offline or online indicators such as short videos, game live broadcasts, product recommendations, and content recommendations, to achieve fast and accurate statistics of indicators of various time granularities, and provide real-time and high-performance query capabilities for indicators, thereby improving the accuracy and real-time performance of recommendations.
[0193] In a possible implementation, this embodiment takes the application scenario of short video scenario and the indicator of independent visitor number as an example. Users can browse short videos of different contents through the short video client, and the number of people who browsed the short video is displayed in real time. Exemplarily, when a user browses a short video content, the client reports a log to the server; optionally, the log includes at least one detailed information of content identification, user account identification, scene value, timestamp, and behavior type. The scene value can be a short video, the timestamp can be a certain day, time, minute, and second, and the behavior type can be sliding or clicking; the server receives the log, performs aggregation and transformation on the log, generates an operation of adding 1 to the number of independent visitors corresponding to the keyword (Key) at a certain minute, hour, and day, and obtains the number of independent visitors at the minute level, hour level, and day level; the aforementioned number of independent visitors is cached in at least one storage engine of the server when it is written.
[0194] When the number of independent visitors of the target time granularity in the target time period needs to be queried, the client sends a query request to the server. For example, the query request is used to indicate the query of the number of independent visitors of a certain day of a certain month, and the query request also includes at least one detailed information of the content identifier, user account identifier, scene value and behavior type; the server receives the query request, obtains the number of independent visitors of a certain day of a certain month from the number of independent visitors of the minute level, hour level and day level cached in the shared memory when writing or reading by at least one storage engine of the server, and returns the number of independent visitors of a certain day of a certain month to the client. The client can display the number of independent visitors of a certain day of a certain month as the number of people who have watched the short video, and can also recommend other short videos to the user account later.
[0195] In another possible implementation, this embodiment takes the application scenario as a live broadcast scenario and the indicator as the number of independent visitors as an example. Users can enter different live broadcast rooms through the live broadcast client to watch different live broadcasts, such as game live broadcasts, shopping live broadcasts, and charity live broadcasts, and the number of viewers in the live broadcast room is displayed in real time.
[0196] Exemplarily, when a user enters a live broadcast room, the client reports a log to the server; optionally, the log includes at least one of the following detailed information: a live broadcast room identifier, a user account identifier, a scene value, a timestamp, and a behavior type, where the scene value may be a live broadcast, the timestamp may be a certain day, time, minute, and second, and the behavior type may be a click; the server receives the log, aggregates and transforms the log, generates an operation of adding 1 to the number of independent visitors corresponding to a keyword (Key) at a certain minute, hour, or day, and obtains the number of independent visitors at the minute, hour, and day levels; and caches the aforementioned number of independent visitors in at least one storage engine of the server when writing.
[0197] When the number of independent visitors of the target time granularity in the target time period needs to be queried, the client sends a query request to the server. For example, the query request is used to indicate the query of the number of independent visitors at the minute level on a certain day of a certain month, and the query request also includes at least one detailed information of the live broadcast room identifier, user account identifier, scene value, and behavior type; the server receives the query request, obtains the number of independent visitors at the minute level on a certain day of a certain month from the number of independent visitors at the minute level, hour level, and day level cached in the shared memory when writing or reading by at least one storage engine of the server, and returns the number of independent visitors at the minute level on a certain day of a certain month to the client. The client can display the number of independent visitors at the minute level on a certain day of a certain month as the number of viewers of the live broadcast room, and can also recommend other live broadcast rooms to the user account later.
[0198] Beneficial effects.
[0199] The beneficial effects of the embodiments of the present application include at least the following aspects.
[0200] 1. Optimization of reporting of running logs for hot keywords (Key): For scenarios where the running logs of a single hot keyword are concurrently reported, such as hot videos, super live broadcast rooms, etc., the instantaneous reporting volume of the running logs for a single hot keyword is very high. Generally, the running logs of such single hot keyword will end up on the same server, and the consistency is guaranteed by the transactions of a single machine. Since the performance of a single machine is generally limited by the server's CPU, disk input / output (I / O), network I / O and other resources, it is difficult to expand linearly. However, the reporting clients may come from many upstream machines. In this regard, this embodiment performs batching on the shared memory of the client for a very short time (such as 500 milliseconds), which can convert a single request to the server to write a single running log into a single request batch write to the running log, reducing transmission overhead. Moreover, for the log writing of the same hot keyword, a simple merge can be performed on the client, which can convert the log of 100 indicators plus 1 into a log of 1 indicator plus 100, thereby reducing the number of logs written and alleviating the pressure of server aggregation and conversion. At the same time, the embedded KV storage engine (RocksDB) written in C++ is used in the server to develop and implement the first storage engine (Log DB), add an asynchronous write queue in the server, and change the transactional write to RocksDB one by one into transactional write in batches, reducing the write burr of RocksDB and further improving the write performance.
[0201] 2. Optimization of the time delay of the running log: In order to reduce the time delay of the running log, since the aggregation of the running log is completed by the log processing component (Log ETL), the log processing component (Log ETL) can be split into multiple threads. However, if each thread scans the same first storage engine (Log DB), a large number of invalid repeated scans will be generated. Therefore, the data in the first storage engine (Log DB) is split into multiple column families (Column Family, CF) according to Hash. Each column family is an independent storage space, and the reading and writing of transactions are also independent, avoiding the problem of multiple threads of the log processing component (LogETL) scanning duplicate running logs. This embodiment further optimizes the master-slave logic, moving the server's master selection logic from the machine level to the thread level, so that the servers in each server cluster (Set) are mutually master-slave, reducing the CPU consumption of a single host.
[0202] 3. Query time optimization: In order to meet the real-time requirements of online recommendation computing services and improve the recommendation effect, based on the assumption that recently updated indicators are generally easier to query in a short period of time, the indicators of different time granularities obtained by aggregation and transformation are cached in the second storage engine (Map DB) as a write-time cache, and the indicators cached by the second storage engine (Map DB) are placed in shared memory. When querying indicators, they are first queried from the second storage engine (Map DB), which can achieve fast query of indicators. In addition, since shared memory reading takes less time than disk reading, it can reduce the query time of indicators. Considering storage and performance, the backend storage engine is also used as reliable storage, and the first synchronization component (Bin Log Sync) is used to regularly write the data of the second storage engine (Map DB) to the backend storage engine. When querying cold data, it may penetrate the backend storage engine. In order to ensure a faster response to the next query of cold data, the indicators read from the backend storage engine are cached in the third storage engine (Read Cache) as a read-time cache, which can facilitate the next query of these indicators. Therefore, the write-time cache of the second storage engine (Map DB) and the read-time cache of the third storage engine (Read Cache) ensure low query time and high availability for single-machine queries.
[0203] After performance optimization, the flow log reporting throughput of a single server can reach 300w / min, and the average log length is 200Bytes. Benefiting from the batch merging of the client, in the case of a single hot keyword, the flow log reporting volume of a single hot keyword can reach 1.3kw / min. In addition, the delay in the effectiveness of the flow log is shortened to the second level, and even in some configuration conditions that pursue real-time performance, it can reach the millisecond level. In addition, by designing read-time cache and write-time cache, the indicator query cache hit rate reaches 97.75%, and batch reading of 200 indicators only takes 3ms, which reduces query time and improves query speed.
[0204] Fig.12 8 is a block diagram of an indicator query device 800 provided by an exemplary embodiment of the present application. Exemplarily, the indicator query device 800 includes at least part of the receiving module 810, the query module 820 and the returning module 830.
[0205] A receiving module 810 is used to receive a query request from a client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period;
[0206] A query module 820 is used to obtain the target indicator corresponding to the query request from indicators of different time granularities in the write-time cache or the read-time cache of at least one storage engine of the server in the shared memory, wherein the write-time cache refers to caching when the indicator is written to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when the indicator is read, and the indicator is obtained by aggregating and transforming the flow log reported by the client;
[0207] The return module 830 is used to return the target indicator corresponding to the query request to the client.
[0208] In some embodiments, the query module 820 is used to:
[0209] Based on the keyword corresponding to the query request, acquiring the target indicator corresponding to the query request from the indicators of the different time granularities cached during write or cached during read in the shared memory by the at least one storage engine of the server;
[0210] Among them, the at least one storage engine is used to cache the indicators of the different time granularities corresponding to different keywords in the form of key-value pairs, and the keywords correspond to the indicators one-to-one.
[0211] In some embodiments, the at least one storage engine includes a first storage engine and a second storage engine, the first storage engine is used to cache the journal log, and the second storage engine is used to cache a first type of index when writing in the shared memory, the first type of index is an index obtained by updating the to-be-updated indexes of different time granularities based on the journal log;
[0212] The server includes a log processing component, and the log processing component is used to perform aggregation and conversion based on the running log and the indicator to be updated, so as to update the indicator to be updated, obtain the indicator of the first type, and update and write the indicator of the first type into the second storage engine;
[0213] In some embodiments, the query module 820 is used to:
[0214] Based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the indicators of the first type cached by the second storage engine during write in the shared memory.
[0215] In some embodiments, the at least one storage engine further includes a third storage engine, the third storage engine is used to cache the second type of indicators during reading, the second type of indicators are indicators of different time granularities read from the backend storage engine that are not updated and are queried by the current query request or the last query request, and the backend storage engine is used to cache all indicators;
[0216] In some embodiments, the query module 820 is further configured to:
[0217] When the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the second type of indicators cached by the third storage engine when reading in the shared memory.
[0218] Fig.13 1 is a block diagram of an indicator statistics device 900 provided by an exemplary embodiment of the present application. Exemplarily, the indicator statistics device 900 includes at least part of a receiving module 910, a processing module 920 and a buffer module 930.
[0219] The receiving module 910 is used to receive the log file reported by the client;
[0220] A processing module 920 is used to aggregate and transform the journal log to obtain indicators of different time granularities;
[0221] The cache module 930 is used to cache the indicators of the different time granularities to at least one storage engine of the server, and the at least one storage engine is used to cache the indicators of the different time granularities in a shared memory when writing or when reading. The write-time cache refers to caching when writing the indicators to the at least one storage engine, and the read-time cache refers to caching in the at least one storage engine when reading the indicators.
[0222] In some embodiments, the server includes a log processing component;
[0223] In some embodiments, the processing module 920 is configured to:
[0224] Aggregation and conversion are performed on the flow log based on the log processing component to obtain the indicators of the different time granularities.
[0225] In some embodiments, the indicators of different time granularities are indicators of the first type, the at least one storage engine includes a first storage engine and a second storage engine, the first storage engine is used to cache the journal log, and the second storage engine is used to cache the indicators of the first type when writing in the shared memory, and the indicators of the first type are indicators obtained by updating the indicators to be updated of different time granularities based on the journal log;
[0226] In some embodiments, the processing module 920 is configured to:
[0227] Based on the log processing component, the journal log is read in batches from the first storage engine, and the indicators to be updated at different time granularities are queried from the second storage engine;
[0228] Aggregation and conversion are performed based on the flow log and the indicator to be updated to update the indicator to be updated and obtain the indicator of the first type.
[0229] In some embodiments, the log processing component includes multiple threads, including a main thread;
[0230] In some embodiments, the processing module 920 is configured to:
[0231] By means of the main thread of the log processing component, permutations and combinations are performed based on the log attributes of the log journal to obtain keywords corresponding to the log journal;
[0232] The to-be-updated indicator is read based on the keyword, and an addition N operation is performed on the to-be-updated indicator to update the to-be-updated indicator to obtain the first type of indicator, where N is greater than 0.
[0233] In some embodiments, the cache module 930 is used to:
[0234] Writing the first type of indicator updates to the second storage engine of the server based on the log processing component.
[0235] In some embodiments, the server includes a first synchronization component;
[0236] In some embodiments, the device further comprises a synchronization module, the synchronization module being configured to:
[0237] The first type of indicator is synchronized to the backend storage engine based on the first synchronization component.
[0238] In some embodiments, the processing module is further configured to:
[0239] The processed journal log in the first storage engine is deleted based on the log processing component.
[0240] In some embodiments, the server includes a second synchronization component, the server is a server in a server cluster, each server in the server cluster includes the at least one storage engine, each server is used to synchronously receive the log reported by the client, and cache the log to the first storage engine in the at least one storage engine;
[0241] In some embodiments, the synchronization module is used to:
[0242] Sending a first notification message to the second synchronization component based on the log processing component;
[0243] The first notification message is used to instruct the second synchronization component to delete the processed journal logs in the first storage engine of other servers in the server cluster.
[0244] In some embodiments, the synchronization module is used to:
[0245] Sending second notification information to the second synchronization component based on the log processing component;
[0246] The second notification information is used to instruct the second synchronization component to synchronize the first type of indicator to the second storage engine in the at least one storage engine of other servers in the server cluster.
[0247] It should be noted that the specific limitations in the embodiments of the query device 800 for one or more indicators and the statistical device 900 for indicators provided in the above embodiments can refer to the limitations of the query method for indicators and the statistical method for indicators in the above text, and will not be repeated here. The modules of the devices in the above embodiments can be implemented in whole or in part by software, hardware, and a combination thereof. Each module can be embedded in or independent of the processor of the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.
[0248] An embodiment of the present application also provides a computer device, which includes: a processor and a memory, wherein a computer program is stored in the memory; the processor is used to execute the computer program in the memory to implement the query method of indicators and / or the statistical method of indicators provided in the above-mentioned method embodiments.
[0249] By way of example, the computer device may be a server. Fig.14 It is a structural block diagram of a server 1000 provided by an exemplary embodiment of the present application.
[0250] Typically, the server 1000 includes: a processor 1001 and a memory 1002 .
[0251] The processor 1001 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 1001 may be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 1001 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 1001 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 1001 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0252] The memory 1002 may include one or more computer-readable storage media, which may be non-transitory. The memory 1002 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 1002 is used to store at least one instruction, which is used to be executed by the processor 1001 to implement the query method of the indicator and / or the statistical method of the indicator provided in the method embodiment of the present application.
[0253] In some embodiments, the server 1000 may further optionally include: an input interface 1003 and an output interface 1004. The processor 1001, the memory 1002, and the input interface 1003 and the output interface 1004 may be connected via a bus or a signal line. Each peripheral device may be connected to the input interface 1003 and the output interface 1004 via a bus, a signal line or a circuit board. The input interface 1003 and the output interface 1004 may be used to connect at least one peripheral device related to input / output (I / O) to the processor 1001 and the memory 1002. In some embodiments, the processor 1001, the memory 1002, the input interface 1003, and the output interface 1004 are integrated on the same chip or circuit board; in some other embodiments, any one or two of the processor 1001, the memory 1002, the input interface 1003, and the output interface 1004 may be implemented on a separate chip or circuit board, which is not limited in the embodiments of the present application.
[0254] Those skilled in the art will understand that Fig.14 The structure shown in the figure does not constitute a limitation on the server 1000, and the server 1000 may include more or fewer components than those shown in the figure, or combine certain components, or adopt a different component arrangement.
[0255] In an exemplary embodiment, the present application provides a chip, which includes a programmable logic circuit and / or program instructions. When the chip runs on a computer device, it is used to implement the query method of indicators and / or the statistical method of indicators provided by the above method embodiments.
[0256] The present application provides a computer-readable storage medium, which stores a computer program. The computer program is loaded and executed by a processor to implement the indicator query method and / or indicator statistical method provided by the above method embodiments.
[0257] The present application provides a computer program product or a computer program, wherein the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the processor of the computer device loads and executes to implement the query method of the index and / or the statistical method of the index provided in the above method embodiment.
[0258] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0259] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned computer-readable storage medium may be a read-only memory, a disk or an optical disk, etc.
[0260] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.
[0261] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.
Claims
1. A method for querying an indicator, characterized in that: The method is executed by a server and includes: Receive a query request from a client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period; Based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the first type of indicators cached in the shared memory when the second storage engine writes; the first type of indicators are indicators obtained by updating the indicators to be updated at different time granularities based on the running log; When the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the second type of indicators cached by the third storage engine when reading in the shared memory; the second type of indicators are indicators of different time granularities read from the backend storage engine that are not updated and are queried by this query request or the previous query request, and the backend storage engine is used to cache all indicators; Returning the target indicator corresponding to the query request to the client; The server includes at least one storage engine, and the at least one storage engine includes a first storage engine, a second storage engine, and a third storage engine; the first storage engine is used to cache the running log; the second storage engine is used to cache the first type of indicators when writing in the shared memory; the third storage engine is used to cache the second type of indicators when reading in the shared memory; the write-time cache refers to caching when writing the first type of indicators to the second storage engine, and the read-time cache refers to caching in the third storage engine when reading the second type of indicators, and the indicators of different time granularities are obtained by aggregating and transforming the running log reported by the client; The server is any server in a server cluster, and the indicators in each server in the same server cluster are synchronized and completely consistent; the server also includes a log processing component, a first synchronization component, a second synchronization component and an anti-reentry component; The server cluster includes multiple threads, the server where the main thread is located is the host, and the servers in the server cluster are mutually active and standby; the server corresponding to the host is also used to receive the water log reported by the client in batches, and the client is used to batch multiple water logs in the shared memory. When the set conditions are met, multiple water logs with the same keywords are merged to obtain the pre-processed water log, and the pre-processed water log is reported; the water logs repeatedly reported by the client are filtered based on the anti-reentry component; the number of threads of the server is modulo based on the hash value of the keyword corresponding to the water log, and the calculation is performed. The column family identifier corresponding to the waterlogging log is synchronously written into the column family corresponding to the column family identifier in the first storage engine of each server in the server cluster where the server is located; wherein the first storage engine is divided into multiple column families, each of the multiple column families includes a part of the waterlogging log in the first storage engine, the reading and writing of each column family are independent, and the number of threads is the same as the number of column families; based on each thread of the multiple threads of the log processing component scanning the waterlogging log corresponding to at least one column family in the first storage engine, querying the indicators to be updated at different time granularities from the second storage engine; by A main thread among multiple threads of the log processing component performs permutations and combinations based on the log attributes of the running log to obtain a keyword corresponding to the running log; reads the to-be-updated indicator based on the keyword, performs an addition N operation on the to-be-updated indicator to update the to-be-updated indicator to obtain an indicator of the first type, where N is greater than 0; updates and writes the first type of indicator to the second storage engine of the server based on the log processing component; synchronizes the first type of indicator to the backend storage engine based on the first synchronization component; deletes the processed running log in the first storage engine based on the log processing component; sends a first notification message to the second synchronization component based on the log processing component, wherein the first notification message is used to instruct the second synchronization component to delete the processed running log in the first storage engine of other servers in the server cluster; sends a second notification message to the second synchronization component based on the log processing component, wherein the second notification message is used to instruct the second synchronization component to synchronize the first type of indicator to the second storage engine of other servers in the server cluster; the anti-reentry component, the first synchronization component, and the second synchronization component are all based on the server as the granularity and are shared by the multiple threads.
2. The method according to claim 1, characterized in that The at least one storage engine is used to cache the indicators of the different time granularities corresponding to the different keywords in the form of key-value pairs, and the keywords correspond to the indicators one-to-one.
3. The method according to claim 2, characterized in that The setting condition is set to at least one of the following: reaching a preset time point, reaching a preset duration, the number of the journal logs reaching a preset number, and the storage space size occupied by the journal logs reaching a preset storage space size.
4. The method according to any one of claims 1 to 3, characterized in that: Each of the server clusters includes multiple data shards, each server in the same server cluster holds the same data shards, and data shards between different server clusters do not overlap; The method further comprises: Based on the keyword corresponding to the query request and the defined number of data shards, a hash algorithm is executed on the keyword to obtain a hash value; Taking a modulus of the number of data shards based on the hash value, to obtain a data shard identifier corresponding to the keyword; Obtaining a server cluster identifier corresponding to the data shard identifier by using a consistent hash algorithm; Determine the server cluster corresponding to the server cluster identifier through a routing table, wherein the routing table stores the server cluster identifier and the server cluster corresponding to the server cluster; Any server in the server cluster is determined as the server used for the query.
5. A statistical method for an indicator, characterized in that: The method is executed by a server and includes: Receive the logbooks reported by the client in batches, wherein the client is used to batch multiple logbooks in a shared memory, and when a set condition is met, merge the multiple logbooks with the same keyword to obtain the pre-processed logbooks, and report the pre-processed logbooks; Filtering the log repeatedly reported by the client based on the anti-reentry component; Taking a modulus of the number of threads of the server based on the hash value of the keyword corresponding to the running log, calculating the column family identifier corresponding to the running log, and synchronously writing the running log to the column family corresponding to the column family identifier in the first storage engine of each server in the server cluster where the server is located; wherein the first storage engine is split into multiple column families, each of the multiple column families includes a part of the running log in the first storage engine, the reading and writing of each column family are independent, and the number of threads is the same as the number of column families; Each thread among the multiple threads of the log processing component scans the journal log corresponding to at least one column family in the first storage engine, and queries the to-be-updated indicators of different time granularities from the second storage engine; By using a main thread among multiple threads of the log processing component, performing permutations and combinations based on log attributes of the log flow log, a keyword corresponding to the log flow log is obtained; The to-be-updated indicator is read based on the keyword, and an addition N operation is performed on the to-be-updated indicator to update the to-be-updated indicator to obtain an indicator of a first type, where N is greater than 0; Writing the first type of indicator update to the second storage engine of the server based on the log processing component; Synchronizing the first type of indicators to the backend storage engine based on the first synchronization component; Deleting the processed journal log in the first storage engine based on the log processing component; Sending a first notification message to the second synchronization component based on the log processing component, wherein the first notification message is used to instruct the second synchronization component to delete the processed journal logs in the first storage engine of other servers in the server cluster; Sending a second notification message to the second synchronization component based on the log processing component, wherein the second notification message is used to instruct the second synchronization component to synchronize the first type of indicators to the second storage engines of other servers in the server cluster; the anti-reentry component, the first synchronization component, and the second synchronization component are all based on the server as the granularity and are shared by the multiple threads; Wherein, the server includes the log processing component, the first synchronization component and the second synchronization component, and the at least one storage engine of the server includes the first storage engine, the second storage engine and the third storage engine; the first storage engine is used to cache the running log; the second storage engine is used to cache the first type of indicators when writing in the shared memory, and the first type of indicators are indicators obtained after updating the indicators to be updated at different time granularities based on the running log; the third storage engine is used to cache the second type of indicators when reading in the shared memory, and the second type of indicators are indicators of different time granularities read from the backend storage engine that have not been updated and are queried by this query request or by the last query request, and the backend storage engine is used to cache all indicators; the write-time cache refers to caching when writing the first type of indicators to the second storage engine, and the read-time cache refers to caching in the third storage engine when reading the second type of indicators; Any server in the server cluster is also used to receive a query request from the client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period; based on a keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the first type of indicator cached by the second storage engine when writing in the shared memory; when the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the second type of indicator cached by the third storage engine when reading in the shared memory; and the target indicator corresponding to the query request is returned to the client.
6. The method according to claim 5, characterized in that The setting condition is set to at least one of the following: reaching a preset time point, reaching a preset duration, the number of the journal logs reaching a preset number, and the storage space size occupied by the journal logs reaching a preset storage space size.
7. A device for querying an index, characterized in that: The device comprises: A receiving module, used to receive a query request from a client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period; A query module, configured to obtain the target indicator corresponding to the query request from the first type of indicators cached by the second storage engine in the shared memory when writing, based on the keyword corresponding to the query request; the first type of indicators are indicators obtained by updating indicators to be updated at different time granularities based on the running log; The query module is used to obtain the target indicator corresponding to the query request from the second type of indicators cached by the third storage engine when reading in the shared memory when the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request; the second type of indicators are indicators of different time granularities read from the backend storage engine that are not updated and are queried by this query request or the previous query request, and the backend storage engine is used to cache all indicators; A return module, used to return the target indicator corresponding to the query request to the client; The server includes at least one storage engine, and the at least one storage engine includes a first storage engine, a second storage engine, and a third storage engine; the first storage engine is used to cache the running log; the second storage engine is used to cache the first type of indicators when writing in the shared memory; the third storage engine is used to cache the second type of indicators when reading in the shared memory; the write-time cache refers to caching when writing the first type of indicators to the second storage engine, and the read-time cache refers to caching in the third storage engine when reading the second type of indicators, and the indicators of different time granularities are obtained by aggregating and transforming the running log reported by the client; The server is any server in a server cluster, and the indicators in each server in the same server cluster are synchronized and completely consistent; the server also includes a log processing component, a first synchronization component, a second synchronization component and an anti-reentry component; The server cluster includes multiple threads, the server where the main thread is located is the host, and the servers in the server cluster are mutually active and standby; the server corresponding to the host is also used to receive the water log reported by the client in batches, and the client is used to batch multiple water logs in the shared memory. When the set conditions are met, multiple water logs with the same keywords are merged to obtain the pre-processed water log, and the pre-processed water log is reported; the water logs repeatedly reported by the client are filtered based on the anti-reentry component; the number of threads of the server is modulo based on the hash value of the keyword corresponding to the water log, and the calculation is performed. The column family identifier corresponding to the waterlogging log is synchronously written into the column family corresponding to the column family identifier in the first storage engine of each server in the server cluster where the server is located; wherein the first storage engine is divided into multiple column families, each of the multiple column families includes a part of the waterlogging log in the first storage engine, the reading and writing of each column family are independent, and the number of threads is the same as the number of column families; based on each thread of the multiple threads of the log processing component scanning the waterlogging log corresponding to at least one column family in the first storage engine, querying the indicators to be updated at different time granularities from the second storage engine; by A main thread among multiple threads of the log processing component performs permutations and combinations based on the log attributes of the running log to obtain a keyword corresponding to the running log; reads the to-be-updated indicator based on the keyword, performs an addition N operation on the to-be-updated indicator to update the to-be-updated indicator to obtain an indicator of the first type, where N is greater than 0; updates and writes the first type of indicator to the second storage engine of the server based on the log processing component; synchronizes the first type of indicator to the backend storage engine based on the first synchronization component; deletes the processed running log in the first storage engine based on the log processing component; sends a first notification message to the second synchronization component based on the log processing component, wherein the first notification message is used to instruct the second synchronization component to delete the processed running log in the first storage engine of other servers in the server cluster; sends a second notification message to the second synchronization component based on the log processing component, wherein the second notification message is used to instruct the second synchronization component to synchronize the first type of indicator to the second storage engine of other servers in the server cluster; the anti-reentry component, the first synchronization component, and the second synchronization component are all based on the server as the granularity and are shared by the multiple threads.
8. A statistical device for indicators, characterized in that: The device comprises: A receiving module, used for receiving the logbooks reported by the client in batches, wherein the client is used for batching a plurality of logbooks in a shared memory, and when a set condition is met, merging a plurality of logbooks with the same keyword to obtain the pre-processed logbooks, and reporting the pre-processed logbooks; A processing module, for filtering the running logs repeatedly reported by the client based on an anti-reentry component; taking a modulus of the number of threads of the server based on a hash value of a keyword corresponding to the running log, calculating a column family identifier corresponding to the running log, and synchronously writing the running log into a column family corresponding to the column family identifier in a first storage engine of each server in a server cluster where the server is located; wherein the first storage engine is split into a plurality of column families, each of the plurality of column families includes a portion of the running logs in the first storage engine, the reading and writing of each column family are independent, and the number of threads is the same as the number of column families; scanning the running logs corresponding to at least one column family in the first storage engine based on each thread of the plurality of threads of the log processing component, querying the to-be-updated indicators of different time granularities from the second storage engine; performing permutations and combinations based on the log attributes of the running log through a main thread of the plurality of threads of the log processing component, and obtaining a keyword corresponding to the running log; reading the to-be-updated indicator based on the keyword, performing an add N operation on the to-be-updated indicator to update the to-be-updated indicator, and obtaining an indicator of a first type, where N is greater than 0; a cache module, configured to write the first type of indicator update to the second storage engine of the server based on the log processing component; A synchronization module, configured to synchronize the first type of indicators to a backend storage engine based on a first synchronization component; The processing module is used to delete the processed journal log in the first storage engine based on the log processing component; The synchronization module is used to send a first notification message to the second synchronization component based on the log processing component, wherein the first notification message is used to instruct the second synchronization component to delete the processed journal log in the first storage engine of other servers in the server cluster; send a second notification message to the second synchronization component based on the log processing component, wherein the second notification message is used to instruct the second synchronization component to synchronize the first type of indicators to the second storage engines of other servers in the server cluster; the anti-reentry component, the first synchronization component, and the second synchronization component are all based on the server granularity and are shared by the multiple threads; Wherein, the server includes the log processing component, the first synchronization component and the second synchronization component, and the at least one storage engine of the server includes the first storage engine, the second storage engine and the third storage engine; the first storage engine is used to cache the running log; the second storage engine is used to cache the first type of indicators when writing in the shared memory, and the first type of indicators are indicators obtained after updating the indicators to be updated at different time granularities based on the running log; the third storage engine is used to cache the second type of indicators when reading in the shared memory, and the second type of indicators are indicators of different time granularities read from the backend storage engine that have not been updated and are queried by this query request or by the last query request, and the backend storage engine is used to cache all indicators; the write-time cache refers to caching when writing the first type of indicators to the second storage engine, and the read-time cache refers to caching in the third storage engine when reading the second type of indicators; Any server in the server cluster is also used to receive a query request from the client, where the query request is used to indicate a target indicator of a target time granularity for querying a target time period; based on a keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the first type of indicator cached by the second storage engine when writing in the shared memory; when the target indicator corresponding to the query request is not queried from the second storage engine, based on the keyword corresponding to the query request, the target indicator corresponding to the query request is obtained from the second type of indicator cached by the third storage engine when reading in the shared memory; and the target indicator corresponding to the query request is returned to the client.
9. A computer device, characterized in that: The computer device includes: a processor and a memory, the memory stores a computer program, and the computer program is loaded and executed by the processor to implement the query method of the indicator as described in any one of claims 1 to 4 or the statistical method of the indicator as described in claim 5 or 6.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the query method for the indicator as described in any one of claims 1 to 4 or the statistical method for the indicator as described in claim 5 or 6.
