Data collection method, device, system and electronic equipment
Obtaining and forwarding service requests through the data collection device, combined with scheduled message middleware and statistical programs, solves the problem of service request processing delay, achieves efficient data flow statistics and improves response speed.
Patent Information
- Application Number
- CN202110790420.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-07-13
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-07-13
AI Technical Summary
In the existing technology, the processing delay of service requests is high, especially in scenarios with large concurrency and strict delay requirements, which cannot be applied, resulting in delayed response of the service program and affecting the user experience.
The service request is obtained through the data collection device, and after determining the collection content, it is forwarded to the target service program to realize data flow statistics and response, and reduce the delay of service requests. The device includes an acquisition module, a determination module and a forwarding module, and uses predetermined message middleware and statistical programs to analyze and collect data flows.
It effectively reduces the response delay of the service program to service requests and improves the response speed. Especially in scenarios with a large number of concurrent requests, it significantly improves the performance of the target service program.
Smart Images

Figure CN113485893B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data analysis technology, and in particular to a data acquisition method, device, system and electronic equipment. Background Art
[0002] A service program is a program product that a manufacturer provides to users. In order to understand the operation of a service program, it is usually necessary to understand the data flow of the service program.
[0003] In the related art, the processing of service requests is serial processing, and the service program is based on the service request and relies on an external database to collect data, and then responds to the service request.
[0004] However, the service program in the related technology has a very high delay from receiving a service request to responding to the request. In particular, it is obviously not applicable to service programs with a large number of concurrent service requests and strict latency requirements. Summary of the invention
[0005] The purpose of the embodiments of the present invention is to provide a data collection method, device, system and electronic device to realize data collection for the data flow of the service program while reducing the response delay of the service program to the service request. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present invention provides a data collection method, which is applied to a data collection device, wherein the data collection device communicates with a target service program for data flow to be collected, and the method comprises:
[0007] Obtaining a service request for a target service program;
[0008] Based on the service request, determine data content for data flow statistics as collection content corresponding to the service request;
[0009] The service request is forwarded to the target service program, so that the target server program responds to the service request.
[0010] Optionally, after determining, based on the service request, data content for data flow statistics as collection content corresponding to the service request, the method further includes:
[0011] Based on the collected content corresponding to the service request, data flow statistics are performed on the target service program.
[0012] Optionally, performing data flow statistics on the target service program based on the collected content corresponding to the service request includes:
[0013] The collected content corresponding to the service request is sent to a predetermined message middleware, so that a predetermined statistical program obtains the collected content from the predetermined message middleware, and analyzes the data flow of the target service program based on the obtained collected content.
[0014] Optionally, sending the collected content corresponding to the service request to a predetermined message middleware includes:
[0015] Cache the collected content corresponding to the service request into a predetermined array;
[0016] When the collected content in the predetermined array meets a predetermined forwarding condition, the collected content in the predetermined array is forwarded to the predetermined message middleware.
[0017] Optionally, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, including:
[0018] Determine the data content under the specified dimension from the acquired collected content;
[0019] Perform predetermined statistical processing on the data content under the specified dimension.
[0020] Optionally, the predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, including:
[0021] The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field;
[0022] and / or
[0023] Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
[0024] Optionally, the specified dimension includes: a partition dimension, a user dimension, a data volume dimension, a sending time dimension or an HTTP status dimension.
[0025] Optionally, the predetermined forwarding condition includes:
[0026] The number of collected content in the predetermined array reaches a predetermined number threshold;
[0027] or,
[0028] The data volume of the collected content in the predetermined array reaches a predetermined data volume threshold.
[0029] In a second aspect, an embodiment of the present invention provides a data collection device, wherein the data collection device communicates with a target service program for data flow to be collected, and the device comprises:
[0030] An acquisition module, used for acquiring a service request for a target service program;
[0031] A determination module, configured to determine, based on the service request, data content for data flow statistics as collection content corresponding to the service request;
[0032] The forwarding module is used to forward the service request to the target service program so that the target server program can make a request response to the service request.
[0033] In a third aspect, an embodiment of the present invention further provides a data collection system, the system comprising: a data collection device, a predetermined message middleware and a predetermined statistical program;
[0034] The data collection device is used to obtain a service request for a target service program; based on the service request, determine the data content used for data flow statistics as the collection content corresponding to the service request; forward the service request to the target service program so that the target server program responds to the service request; and send the collection content corresponding to the service request to a predetermined message middleware;
[0035] The predetermined message middleware is used to store the collected content sent by the data collection device;
[0036] The predetermined statistical program is used to obtain collected content from the predetermined message middleware, and analyze the data flow of the target service program based on the obtained collected content.
[0037] Optionally, the data collection device sends the collection content corresponding to the service request to a predetermined message middleware, specifically:
[0038] Cache the collected content corresponding to the service request into a predetermined array;
[0039] When the collected content in the predetermined array meets a predetermined forwarding condition, the collected content in the predetermined array is forwarded to the predetermined message middleware.
[0040] Optionally, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, specifically:
[0041] Determine the data content under the specified dimension from the acquired collected content;
[0042] Perform predetermined statistical processing on the data content under the specified dimension.
[0043] Optionally, the predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, specifically:
[0044] The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field;
[0045] and / or
[0046] Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
[0047] In a fourth aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;
[0048] Memory, used to store computer programs;
[0049] The processor is used to implement the data collection method provided by the first aspect when executing the program stored in the memory.
[0050] In a fifth aspect, an embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the data acquisition method provided in the first aspect is implemented.
[0051] An embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-mentioned data collection methods.
[0052] Beneficial effects of the embodiments of the present invention:
[0053] In the scheme provided by the embodiment of the present invention, the data collection device obtains the service request sent by the access end for the target service program, and based on the service request, determines the data content used for data flow statistics as the collection content corresponding to the service request; then, the service request is forwarded to the target service program, so that the target server program responds to the service request. It can be seen that in this scheme, data collection for the data flow of the target service program can be realized by using the data collection device to collect data for the service request; and the data collection device forwards the service request to the target service program for response only after determining the statistics to be counted corresponding to the service request, so that the delay of the target service program from receiving the service request to responding to the request is reduced, especially in the scenario where the number of concurrent requests is large, compared with the serial processing method of the prior art, the response delay of the target service program to the service request can be greatly reduced, thereby improving the response speed of the target service program. Therefore, through this scheme, it is possible to realize data collection for the data flow of the service program while reducing the response delay of the service program to the service request.
[0054] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0056] Figure 1 A flow chart of a data collection method provided by an embodiment of the present invention;
[0057] Figure 2 Another flow chart of a data collection method provided by an embodiment of the present invention;
[0058] Figure 3 This is a schematic diagram of the updating principle of the statistics of the target value under the specified dimension according to an embodiment of the present invention;
[0059] Figure 4 A schematic diagram of a method for performing statistical measurement on the data processing status of each service according to an embodiment of the present invention;
[0060] Figure 5 A working principle diagram of a data acquisition method provided by an embodiment of the present invention;
[0061] Figure 6 A structural schematic diagram of a data acquisition device provided by an embodiment of the present invention;
[0062] Figure 7 A structural schematic diagram of a data acquisition system provided by an embodiment of the present invention;
[0063] Figure 8 The present invention is a schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field based on this application belong to the scope of protection of the present invention.
[0065] In the process of product operation, technical and product staff often need to control the operation of the product and the operation of the technology used by the product itself, and need to fully understand the inflow and output of each piece of data. In the related art, the inflow and output information of the data is often recorded in a cache database, such as redis, mongodb database, etc., and the cache database is used to record this information, and then the service request is responded to and processed. However, in a serverless (serverless) and cloud-native service, due to the large number of concurrent data requests and the requirement that the service latency is very low, if it relies on an external database, it will inevitably affect the latency of the entire service and affect the user experience of the service program. Therefore, the method provided by the related art is obviously not applicable to service programs with a large number of concurrent data requests and strict latency requirements. Therefore, while realizing data collection for the data flow of the service program, reducing the response delay of the service program to the service request, the embodiment of the present invention provides a data collection method, device, system and electronic device.
[0066] First, a data collection method provided by an embodiment of the present invention is introduced below.
[0067] A data collection method provided by an embodiment of the present invention is applied to a data collection device, which communicates with a target service program of a data flow to be counted. The target service program of the data flow to be counted can be any service program with data flow statistics, such as a storage service program, a computing service program, etc.
[0068] In addition, the data acquisition device serves as a request entry for the target service program for the data flow to be counted, that is, the service request for the target service program is first received by the data acquisition device, and after the data acquisition device receives it, the data acquisition device forwards the received service request to the target service program for request response. The specific request content of the service request corresponding to different service programs is different, and the embodiment of the present invention does not limit the specific request content of the service request.
[0069] In addition, the data acquisition device can have a one-to-one correspondence with the target service program, that is, the data acquisition device provides data acquisition and request forwarding functions for a unique target service program; of course, the data acquisition device can correspond to multiple target service programs, that is, the data acquisition device can provide data collection and request forwarding functions for multiple target service programs.
[0070] The data collection method provided by the embodiment of the present invention may include the following steps:
[0071] Obtaining a service request for a target service program;
[0072] Based on the service request, determine data content for data flow statistics as collection content corresponding to the service request;
[0073] The service request is forwarded to the target service program, so that the target server program responds to the service request.
[0074] In the scheme provided by the embodiment of the present invention, data collection for the service request is performed through a data collection device, so that data collection for the data stream of the target service program can be realized; and, the data collection device forwards the service request to the target service program for response only after determining the statistics to be counted corresponding to the service request, so that the delay from receiving the service request to responding to the request of the target service program is reduced, especially in the scenario with a large number of concurrent requests, compared with the serial processing method of the prior art, the response delay of the target service program to the service request can be greatly reduced, thereby improving the response speed of the target service program. Therefore, through this scheme, it is possible to realize data collection for the data stream of the service program while reducing the response delay of the service program to the service request.
[0075] The data flow statistics method provided by the embodiment of the present invention is introduced below with reference to the accompanying drawings.
[0076] like Figure 1 As shown, a data collection method provided by an embodiment of the present invention may include the following steps:
[0077] S101, obtaining a service request for a target service program;
[0078] When the access end needs to access the target service program, it can send a service request to the target service program, and the data acquisition device communicating with the target service program, as the service request entry of the target service program, can obtain the service request sent by the access end for the target service program. Among them, this embodiment does not limit the number of service requests, and the processing of any service request can be processed according to the solution provided in this embodiment.
[0079] It can be understood that, illustratively, in order to realize the data acquisition device as the service request entry of the target service program, in the mapping relationship between the domain name of the target service program and the access address in the DNS server (Domain Name Server), the access address can be set as the external access address of the data acquisition device. In this way, when the access end sends a service request for the target service program, the DNS server can resolve the domain name of the target service program in the service request into the external access address of the data acquisition device, so that the data acquisition device can obtain the service request for the target service program.
[0080] In addition, it should be noted that the access end can be a user client or other device on the network side where the target service program is located and has service needs, which is not limited in the embodiment of the present invention. Moreover, the service request can be an access request, a configuration request, etc. The embodiment of the present invention does not limit the type of service request, and any service request that the target service program can respond to can be applicable to the embodiment of the present invention. S102, based on the service request, determine the data content used for data flow statistics as the collection content corresponding to the service request;
[0081] After obtaining each service request, the data collection device needs to count the data flow for the target service program. Therefore, before forwarding the service request to the target service program, the data content corresponding to the service request for data flow statistics can be determined from the service request as the collection content corresponding to the service request.
[0082] The type of data content for data flow statistics corresponding to the service request can be set according to the actual situation. Exemplarily, the data content for data flow statistics may include: the partition to which the service request belongs, the user ID of the service request, the data volume of the service request, the sending time of the service request, the HTTP status of the service request, etc. The partition to which the service request belongs may be a partition divided according to the geographical location. At this time, the geographical location from which the service request comes can be known through the partition to which the service request belongs, but it is certainly not limited to this; in addition, the HTTP status can be determined by the existing HTTP status code.
[0083] S103, forwarding the service request to the target service program, so that the target server program responds to the service request.
[0084] After determining the collection content corresponding to the service request through the above step S102, the service request is forwarded to the target service program through the data collection device, so that the target service program can respond to the request. Compared with the serial processing method in the prior art of first recording the data content for data flow statistics corresponding to the service request in an external database, and then responding to the service request, the solution provided by the embodiment of the present invention can reduce the delay of the target service program to the service request. Especially for the scenario with a large number of concurrent requests, this solution can undoubtedly greatly reduce the response delay of the target service program to the service request, thereby improving the response performance of the target service program to the service request.
[0085] In the scheme provided by this embodiment, data collection is performed on the service request through a data collection device, so that data collection for the data flow of the target service program can be realized; and, the data collection device forwards the service request to the target service program for response only after determining the statistics to be counted corresponding to the service request, so that the delay from receiving the service request to responding to the request by the target service program is reduced, especially in the scenario where the number of concurrent requests is large, compared with the serial processing method of the prior art, the delay of the target service program for the service request can be greatly reduced, thereby improving the response speed of the target service program. Therefore, through this scheme, data collection for the data flow of the service program can be realized while reducing the response delay of the service program to the service request.
[0086] Optionally, in another embodiment of the present invention, Figure 1 On the basis of Figure 2 As shown, the method may also include:
[0087] S104: Perform data flow statistics on the target service program based on the collected content corresponding to the service request.
[0088] After obtaining the collected content corresponding to the service request, in order to realize data flow statistics for the target service program, data flow statistics can be performed on the target service program based on the determined collected content of the service request. It should be noted that the data collection device can perform data flow statistics on the target service program based on the collected content corresponding to the service request, or send the collected content corresponding to the service request to other devices to perform data flow statistics on the target service program with the help of other devices. In actual applications, the specific statistical method can be set according to actual conditions.
[0089] The specific implementation method of the data collection device performing data flow statistics on the target service program based on the collection content corresponding to the service request can be the same as the specific implementation method of other devices performing data flow statistics on the target server. In order to make the solution clear and the layout clear, the following introduces how the data collection device uses other devices to perform data flow statistics on the target service program through other embodiments.
[0090] It can be seen that the scheme provided by this embodiment can realize data collection for the data flow of the service program while reducing the response delay of the service program to the service request. In addition, the scheme provided by this embodiment can perform data flow statistics on the service program based on the collection content of the service program obtained by the data collection device, thereby achieving effective analysis of the data flow while ensuring that the service program responds quickly to the service request.
[0091] Optionally, in another embodiment of the present invention, in the above Figure 2 Based on the above embodiment, the above step S104 may include the following steps:
[0092] The collected content corresponding to the service request is sent to a predetermined message middleware, so that a predetermined statistical program obtains the collected content from the predetermined message middleware, and analyzes the data flow of the target service program based on the obtained collected content.
[0093] In this embodiment, by combining a data collection device, a predetermined message middleware and a predetermined statistical program item, that is, a distributed statistical method, the data flow of the target service program is counted, which can further improve the statistical efficiency. Among them, the predetermined message middleware is used to implement the message queue function, and the predetermined statistical program is used to consume the collected content in the predetermined message middleware. In addition, the predetermined statistical program is a pre-set program for performing data flow statistics. The embodiment of the present invention does not limit the specific form of the predetermined statistical program, nor does it limit the node on which the predetermined statistical program is deployed.
[0094] In addition, there may be multiple specific implementations of the scheduled message middleware. For example, the scheduled message middleware may be RabbitMQ, RocketMQ, ActiveMQ, Kafka, ZeroMQ, MetaMQ, and other message middleware. It can be understood by those skilled in the art that the MQ (Message Queue) message queue is a "first-in, first-out" data structure in the basic data structure. It means putting the data (message) to be transmitted in the queue, and using the queue mechanism to realize message transmission - the producer generates the message and puts the message into the queue, and then the consumer processes it. The consumer can pull the message from the specified queue, or subscribe to the corresponding queue, and the MQ server pushes the message to it. The message queue middleware is an important component in the distributed system. The message queue middleware that is currently used more frequently includes: ActiveMQ, RabbitMQ, RocketMQ, ZeroMQ, MetaMQ, Kafka, and the like. In addition, since databases such as Redis, MySQL, and phxsql can also realize the message queue function, the scheduled message middleware can also be databases such as Redis, MySQL, and phxsql.
[0095] In addition, there are multiple implementation methods for analyzing the data flow of the target service program based on the acquired collected content.
[0096] Exemplarily, in one implementation, in order to achieve complete statistics of the data flow, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, which may include:
[0097] According to the order in which the service requests are received, the collected content corresponding to each service request is stored in a predetermined database.
[0098] For this implementation, the data collection device can communicate with a predetermined database, so as to store the collection content corresponding to the service request in the predetermined database. In this way, the collection content corresponding to each service request of the target service program can be obtained by querying the predetermined database, so as to understand the data flow of the target service program.
[0099] Exemplarily, in another implementation, in order to count the data flow of the target service program in a finer granularity and improve the flexibility of data flow statistics, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, which may include steps A1-A2:
[0100] A1, determining the data content under the specified dimension from the acquired collected content;
[0101] The number of designated dimensions may be one or more, and each designated dimension may be a dimension corresponding to any type of data content used for data flow statistics. Exemplarily, assuming that the data content used for data flow statistics may include: the partition to which the service request belongs, the user ID of the service request, the data volume of the service request, the sending time of the service request, and the HTTP status of the service request, then the designated dimension may include: any one of the partition dimension, the user dimension, the data volume dimension, the sending time dimension, and the HTTP status dimension.
[0102] In addition, each specified dimension may include multiple dimension values. For example, if the specified dimension is partition, then the multiple dimension values under the specified dimension may include: partition 1, partition 2, partition 3, etc.; if the specified dimension is user dimension, then the multiple dimension values under the specified dimension may include: each user ID; if the specified dimension is data volume dimension, then the multiple dimension values under the specified dimension may include: various data volume ranges, etc.
[0103] A2, performing predetermined statistical processing on the data content under the specified dimension.
[0104] Exemplarily, the statistical processing may include one or more of the following processing methods:
[0105] Processing method 1: saving the data content under the specified dimension into a database, where the database is a database with the specified dimension as a field;
[0106] Processing method two is to determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
[0107] When updating the statistics of the target value under the current specified unit time, the accumulator set for the target value of the specified dimension can be used to update the statistics. Figure 3 As shown, accumulators are respectively provided for target value A and target value B. For each service request, whenever it is determined that the target value to which the data content under the specified dimension belongs is target value A, 1 is added to the accumulator for target value A to update the statistics of target value A under the specified unit time; and whenever it is determined that the target value to which the data content under the specified dimension belongs is target value B, 1 is added to the accumulator for target value B to update the statistics of target value B under the specified unit time.
[0108] In addition, at the end of each specified unit time, the accumulated value of the accumulator can be cleared to obtain the statistics within each specified time. The specified unit time can be every minute, every hour, every day, etc.
[0109] For processing method two, for example, assuming that the specified dimensions are partition dimension and user dimension, then for the collection content a corresponding to each service request, after determining partition 1 and user A in the collection content a, it can be known that the target value of the data content under the partition dimension is 1, and the target value of the data content under the user dimension is user A. The statistics of partition 1 and user A are updated every minute respectively, that is, the statistics of service requests from partition 1 and user A are updated every minute.
[0110] For processing method two, for example, assuming that the specified dimensions are user dimension and data volume dimension, then for the collection content a corresponding to each service request, after determining user A and data volume 1 in the collection content a, it can be known that the target value of the data content under the user dimension is user A, and the target value of the data content under the data volume dimension is the first data volume range, which is a range including data volume 1; the statistics of user A per minute and the statistics of the first data volume range per minute are updated respectively, that is, the statistics of service requests from user A per minute, and the statistics of service requests belonging to the first data volume range per minute are updated.
[0111] It should be noted that the above-mentioned predetermined statistical program can be combined with the implementation method of analyzing the data flow of the target service program based on the acquired collected content. This can not only store the collected content corresponding to each service request of the target service program to ensure the integrity of the content, but also count the data flow of the target service program in a more fine-grained manner and improve the flexibility of data flow statistics.
[0112] In the solution provided by this embodiment, data collection can be performed on the data flow of the service program while reducing the response delay of the service program to the service request. In addition, the data collection device continues to use the predetermined message middleware and the predetermined statistical program to perform data flow statistics on the target service program, which can quickly perform statistics on the data flow of the target service program.
[0113] Optionally, in another embodiment of the present invention, sending the collected content corresponding to the service request to a predetermined message middleware comprises steps A3-A4:
[0114] A3, caching the collected content corresponding to the service request into a predetermined array;
[0115] By caching the collected content corresponding to the service request into a predetermined array, batch processing of service requests for the target service program can be achieved, thereby ensuring better processing efficiency. In addition, the data collection device can cache the collected content corresponding to the service request into a predetermined array by starting an internal thread; and, whenever the collected content corresponding to a service request is obtained, the data collection device can cache the collected content corresponding to the service request into a predetermined array.
[0116] In addition, in a specific application, the number of the predetermined arrays may be one or more, and the specific number may be determined according to the concurrency of the service request, which is not limited in this embodiment. It is understandable that for a scenario with a large concurrency, multiple predetermined arrays may be used to achieve the effect of diversion, thereby further improving data processing efficiency.
[0117] A4: forwarding the collected content in the predetermined array to the predetermined message middleware when the collected content in the predetermined array meets the predetermined forwarding condition.
[0118] The predetermined forwarding condition can be set according to actual conditions. For example, the predetermined forwarding condition includes:
[0119] The number of collected content items corresponding to each service request in the predetermined array reaches a predetermined number threshold; or the data volume of the collected content corresponding to each service request in the predetermined array reaches a predetermined data volume threshold.
[0120] Among them, the predetermined number threshold and the predetermined data volume threshold can be set according to actual conditions. Exemplarily, the predetermined number threshold can be hundreds, such as 100, 200, 300, etc.; or, the predetermined number threshold can be thousands, such as 1000, 2000, etc., but of course it is not limited thereto. Exemplarily, the predetermined data volume threshold can be hundreds of bytes, such as 100 bytes, 300 bytes, etc.; or, the predetermined data volume threshold can be thousands of bytes, such as 1000 bytes, 3000 bytes.
[0121] In this embodiment, after obtaining the collected content corresponding to the service request, the data collection device caches the collected content corresponding to the service request to a predetermined array, and forwards the collected content in the predetermined array to the predetermined message middleware when the collected content in the predetermined array meets the predetermined forwarding condition, so that the predetermined statistical program obtains data from the predetermined message middleware for data flow analysis. For scenarios with large concurrency, multiple predetermined arrays are used to achieve the effect of diversion, thereby further improving data processing efficiency.
[0122] In order to better illustrate the content of the embodiment of the present invention, a specific example is described below.
[0123] The present invention aims to solve the problem of statistically measuring the data processing of the target service program while ensuring high service performance (fast response) and availability. Figure 4 As shown, the upstream service, i.e., the target service program, is used to respond to the service request of the access terminal; the data stream processing service, i.e., the above-mentioned data collection device, is used to collect data for the service request; the queue is a predetermined array, which is used to cache the collection content corresponding to the service request. Since the data flow of the upstream service needs to be counted, the upstream service can be used as the producer responsible for producing data, and the data stream processing service can be used to realize the function of consuming data.
[0124] Specifically, the data stream processing service receives an external service request for an upstream service, extracts basic information of the service request (equivalent to the above-mentioned collected content), and places it in a predetermined array. After extracting the information, the service request can be forwarded to the upstream service for response. The present invention can be used to solve the following problems: Figure 4 The upstream and downstream data statistics and measurement problems shown can be checked in units of minutes / hours / days to see whether the data processing is consistent, whether there is any data loss or repeated data processing.
[0125] Moreover, by starting an internal thread inside the data stream processing service, the thread itself is only responsible for caching the basic information of the data (such as consumption partition, consumption size, etc.) into a predetermined array (the program's own memory array); when the predetermined array reaches a certain batch (such as the array length reaches 1000), the collected content in the predetermined array is uniformly sent to the consumption queue (the message queue is a message middleware for data reception). At the same time, a stream processing task consumes these data at the consumer end of the message queue. After the stream processing task consumes the data, an accumulator is performed on the data inside it (the so-called accumulator is to perform statistical accumulation of data of different dimensions), and then the accumulator result saves the data to the database every minute, which does not affect the performance of the service and can view the information overview of the data stream for data processing. Through practice, using the technology provided by the present invention, after the operation results of the past few months, it can carry a single service with a concurrency of 20w, ensuring the stability of data metering and service.
[0126] In addition, in order to facilitate understanding of the working principle of the data acquisition method of the present invention, Figure 5 The working principle diagram of the data acquisition method is shown in FIG. Figure 5As shown, the data collection device communicates with the target service program. After receiving each service request sent by the access terminal for the target service program, the data collection device determines, for each service request, the data content for data flow statistics corresponding to the service request as the collection content corresponding to the service request, and caches the collection content corresponding to each service request into a predetermined array Queue; and, after each service request is determined to have statistics to be collected, the data collection device forwards the service request to the target service program so that the target service program responds to the service request;
[0127] Furthermore, when the data collection device detects that the collected content corresponding to each service request in the predetermined array Queue meets the predetermined forwarding conditions, the data collection device forwards the collected content corresponding to each service request in the predetermined array to the predetermined message middleware; in addition, the data collection device itself can be connected to a database, and the content in the database is the collected content of the service request, so as to facilitate information query through the data collection device.
[0128] Correspondingly, the scheduled message middleware can consume the collected content corresponding to each service request received. The scheduled message middleware executes data statistics through the scheduled statistical program at the back end. The scheduled statistical program is connected to the database to save the consumption results in the database. That is, the scheduled message middleware uses the collected content corresponding to each service request received to count the data flow of the target service program and store the statistical results in the database.
[0129] Corresponding to the above method embodiment, the embodiment of the present invention further provides a data acquisition device, the data acquisition device communicates with the target service program of the data flow to be counted, such as Figure 6 As shown, the device comprises:
[0130] An acquisition module 610 is used to acquire a service request for a target service program;
[0131] A determination module 620, configured to determine, based on the service request, data content for data flow statistics as collection content corresponding to the service request;
[0132] The forwarding module 630 is used to forward the service request to the target service program, so that the target server program can make a request response to the access request.
[0133] Optionally, the data acquisition device further includes:
[0134] The statistics module is used to perform data flow statistics on the target service program based on the collected content corresponding to the service request.
[0135] Optionally, the statistics module includes:
[0136] The analysis unit is used to send the collected content corresponding to the service request to the predetermined message middleware, so that the predetermined statistical program obtains the collected content from the predetermined message middleware, and analyzes the data flow of the target service program based on the obtained collected content.
[0137] Optionally, the analysis unit comprises:
[0138] A cache subunit, used for caching the collected content corresponding to the service request into a predetermined array;
[0139] The forwarding subunit is used to forward the collected content in the predetermined array to the predetermined message middleware when the collected content in the predetermined array meets the predetermined forwarding condition.
[0140] Optionally, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collected content, including:
[0141] Determine the data content under the specified dimension from the acquired collected content;
[0142] Perform predetermined statistical processing on the data content under the specified dimension.
[0143] Optionally, the predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, including:
[0144] The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field;
[0145] and / or
[0146] Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
[0147] Optionally, the specified dimension includes: a partition dimension, a user dimension, a data volume dimension, a sending time dimension or an HTTP status dimension.
[0148] Optionally, the predetermined forwarding condition includes: the number of collected content in the predetermined array reaches a predetermined number threshold; or the data volume of the collected content in the predetermined array reaches a predetermined data volume threshold.
[0149] Corresponding to the above method embodiment, the embodiment of the present invention also provides a data acquisition system, such as Figure 7 As shown, the system includes: a data collection device 710, a predetermined message middleware 720 and a predetermined statistical program 730;
[0150] The data collection device 710 is used to obtain a service request for a target service program; based on the service request, determine the data content used for data flow statistics as the collection content corresponding to the service request; forward the service request to the target service program so that the target server program responds to the service request; and send the collection content corresponding to the service request to the predetermined message middleware 720;
[0151] The predetermined message middleware 720 is used to store the collected content sent by the data collection device;
[0152] The predetermined statistical program 730 is used to obtain the collected content from the predetermined message middleware, and analyze the data flow of the target service program based on the obtained collected content.
[0153] Optionally, the data collection device 710 sends the collection content corresponding to the service request to the predetermined message middleware 720, specifically:
[0154] Cache the collected content corresponding to the service request into a predetermined array;
[0155] When the collected content in the predetermined array meets the predetermined forwarding condition, the collected content in the predetermined array is forwarded to the predetermined message middleware 720 .
[0156] Optionally, the predetermined statistical program analyzes the data flow of the target service program based on the acquired collected content, specifically:
[0157] Determine the data content under the specified dimension from the acquired collected content;
[0158] Perform predetermined statistical processing on the data content under the specified dimension.
[0159] Optionally, the predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, specifically:
[0160] The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field;
[0161] and / or
[0162] Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
[0163] Among them, the content about the data acquisition system in the embodiment of the present invention is the same as the content of the above-mentioned data acquisition method, and will not be repeated here.
[0164] The embodiment of the present invention further provides an electronic device, such as Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803 and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.
[0165] Memory 803, used for storing computer programs;
[0166] The processor 801 is used to implement the steps of any of the above-mentioned data acquisition methods when executing the program stored in the memory 803.
[0167] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0168] The communication interface is used for communication between the above electronic device and other devices.
[0169] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0170] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0171] In another embodiment of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. When the computer program is executed by a processor, the steps of any of the above data acquisition methods are implemented.
[0172] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the steps of any data collection method in the above embodiments.
[0173] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.
[0174] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0175] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0176] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A data collection method, characterized in that: Applied to a data acquisition device, the data acquisition device communicates with a target service program and serves as a request entry for the target service program, the method comprising: Obtaining a service request for a target service program; Based on the service request, determine the data content used for data flow statistics as the collection content corresponding to the service request; the data content used for data flow statistics is the basic information of the service request; The service request is forwarded to the target service program so that the target service program can make a request response to the service request; after determining the collection content corresponding to the service request, the data collection device forwards the service request to the target service program.
2. The method according to claim 1, characterized in that After determining the data content used for data flow statistics based on the service request as the collection content corresponding to the service request, the method further includes: Based on the collected content corresponding to the service request, data flow statistics are performed on the target service program.
3. The method according to claim 2, characterized in that The performing data flow statistics on the target service program based on the collected content corresponding to the service request includes: The collected content corresponding to the service request is sent to a predetermined message middleware, so that a predetermined statistical program obtains the collected content from the predetermined message middleware, and analyzes the data flow of the target service program based on the obtained collected content.
4. The method according to claim 3, characterized in that The sending of the collected content corresponding to the service request to a predetermined message middleware includes: Cache the collected content corresponding to the service request into a predetermined array; When the collected content in the predetermined array meets a predetermined forwarding condition, the collected content in the predetermined array is forwarded to the predetermined message middleware.
5. The method according to claim 3 or 4, characterized in that: The predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, including: Determine the data content under the specified dimension from the acquired collected content; Perform predetermined statistical processing on the data content under the specified dimension.
6. The method according to claim 5, characterized in that The predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, including: The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field; and / or Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
7. The method according to claim 5, characterized in that The specified dimensions include: Partition dimension, user dimension, data volume dimension, sending time dimension, or HTTP status dimension.
8. The method according to claim 4, characterized in that The predetermined forwarding conditions include: The number of collected content in the predetermined array reaches a predetermined number threshold; or, The data volume of the collected content in the predetermined array reaches a predetermined data volume threshold.
9. A data acquisition device, characterized in that: The data acquisition device communicates with the target service program and serves as a request entry for the target service program, and the device includes: An acquisition module, used for acquiring a service request for a target service program; A determination module, configured to determine, based on the service request, data content for data flow statistics as collection content corresponding to the service request; the data content for data flow statistics is basic information of the service request; The forwarding module is used to forward the service request to the target service program so that the target service program can respond to the service request; after determining the collection content corresponding to the service request, the data collection device forwards the service request to the target service program.
10. A data acquisition system, characterized in that: The system comprises: a data collection device, a predetermined message middleware and a predetermined statistical program; the data collection device communicates with the target service program and serves as a request entry for the target service program; The data collection device is used to obtain a service request for a target service program; based on the service request, determine the data content used for data flow statistics as the collection content corresponding to the service request; forward the service request to the target service program so that the target service program responds to the service request; send the collection content corresponding to the service request to a predetermined message middleware; the data content used for data flow statistics is the basic information of the service request; after determining the collection content corresponding to the service request, the data collection device forwards the service request to the target service program; The predetermined message middleware is used to store the collected content sent by the data collection device; The predetermined statistical program is used to obtain collected content from the predetermined message middleware, and analyze the data flow of the target service program based on the obtained collected content.
11. The system according to claim 10, characterized in that The data collection device sends the collection content corresponding to the service request to the predetermined message middleware, specifically: Cache the collected content corresponding to the service request into a predetermined array; When the collected content in the predetermined array meets a predetermined forwarding condition, the collected content in the predetermined array is forwarded to the predetermined message middleware.
12. The system according to claim 10 or 11, characterized in that The predetermined statistical program analyzes the data flow of the target service program based on the acquired collection content, specifically: Determine the data content under the specified dimension from the acquired collected content; Perform predetermined statistical processing on the data content under the specified dimension.
13. The system according to claim 12, characterized in that The predetermined statistical program performs predetermined statistical processing on the data content under the specified dimension, specifically: The data content under the specified dimension is saved in a database, where the database is a database with the specified dimension as a field; and / or Determine the target value to which the data content under the specified dimension belongs, and update the statistics of the target value under the current specified unit time; wherein the target value is any dimensional value among the dimensional values included in the specified dimension.
14. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 8 when executing a program stored in a memory.
15. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Service governance method, device and system, electronic equipment and storage medium
CN110995848A
Data metering statistical method and device, electronic equipment and storage medium
CN113010852A
Service node connection method and device
CN113037861A
Converting terminal-based legacy applications to web-based applications
US20160019191A1
Virtual network service processing method, apparatus and system, and controller and storage medium
WO2020186909A1
