Method and device for predicting number of online people, equipment and medium
By dividing the log data stream into time windows and performing deduplication counting, and using hash functions and the maximum leading zeros for calculation, the problem of inaccurate online user statistics in traditional technologies is solved, achieving efficient and accurate online user prediction.
Patent Information
- Application Number
- CN202511810483.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-03
- Publication Date
- 2026-02-17
AI Technical Summary
Traditional technologies are unable to accurately count the number of online users globally or across the entire network in real time when faced with massive amounts of data, resulting in low accuracy in online user counts.
By acquiring the log data stream of the target distributed system, the log data stream is divided into multiple time windows based on access time information. The log data in each time window is deduplicated and counted. The predicted number of online users is calculated using a hash function and the maximum leading zero. The weighted average of multiple hash functions is combined to reduce memory usage and the impact of hash collisions.
It improves the accuracy and processing efficiency of online user prediction, meets real-time requirements, reduces memory resource consumption, and avoids performance problems caused by insufficient memory.
Smart Images

Figure CN121547643A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method, apparatus, device, and medium for predicting the number of online users. Background Technology
[0002] With the gradual growth of internet live streaming services, business systems need to process hundreds of thousands or even millions of user access log queries per second. Against this backdrop, accurately and in real-time counting of the number of online users globally or across the entire network (i.e., deduplicating the count of different user identification information) has become a critical and extremely challenging task. However, traditional deduplication methods yield relatively low accuracy in counting online users when faced with massive amounts of data. Summary of the Invention
[0003] Therefore, it is necessary to provide a method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the accuracy of predicting the number of online users in order to address the above-mentioned technical problems.
[0004] Firstly, this application provides a method for predicting the number of online users, the method comprising:
[0005] Obtain the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information;
[0006] Based on the time order of access time information, the log data stream is divided into window log data under multiple time windows;
[0007] For each time window, the user identification information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window.
[0008] In one embodiment, the user identifier information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window, including:
[0009] Each user's identification information is mapped to a preset number of buckets using a preset hash function;
[0010] The predicted number of online users within a time window is determined based on the maximum number of leading zeros recorded in each bucket.
[0011] In one embodiment, each user identification information is mapped to a preset number of buckets using a hash function, including:
[0012] Perform a hash calculation on each user identifier to obtain the corresponding hash value;
[0013] The target bucket to which the user identification information belongs is determined based on the first preset number of bits of the hash value.
[0014] In one embodiment, the predicted number of online users within a time window is determined based on the maximum number of leading zeros recorded in each bucket, including:
[0015] Update the maximum number of leading zeros recorded in the target bucket based on the number of leading zeros in the remaining bit sequence of the hash value;
[0016] The predicted number of online users within a time window is determined based on the harmonic average of the maximum leading zeros for each bucket and the preset number.
[0017] In one embodiment, the user identifier information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window, including:
[0018] At least two preset hash functions are used to deduplicatively count the user identification information to obtain the corresponding counting results;
[0019] The weighted average of the counts is used to obtain the predicted number of online users within the time window.
[0020] In one embodiment, the process of acquiring the log data stream includes:
[0021] User access log files are collected from the edge nodes deployed in the target distributed system using a log collector.
[0022] Send the user access log file to the message queue of the central cluster to which the edge node is connected;
[0023] The system continuously retrieves user access log files from the message queue to obtain a log data stream.
[0024] In one embodiment, sending the user access log file to the message queue of the central cluster to which the edge node is connected includes:
[0025] According to the priority order of the generation time, the data in the user access log file is encapsulated into requests in sequence, and the requests are sent to the load balancer of the central cluster to which the edge node is connected.
[0026] The pre-defined replication procedure replicates log data from each load balancer to the message queue of the central cluster.
[0027] Secondly, this application also provides an online user prediction device, the device comprising:
[0028] The access data acquisition module is used to acquire the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information;
[0029] The time window segmentation module is used to divide the log data stream into window log data under multiple time windows based on the time order of access time information;
[0030] The online user count determination module is used to perform deduplication and counting of the user identification information corresponding to the accessing users in the window log data under each time window, so as to obtain the predicted online user count under the time window.
[0031] Thirdly, this application also provides a computer device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the following steps:
[0032] Obtain the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information;
[0033] Based on the time order of access time information, the log data stream is divided into window log data under multiple time windows;
[0034] For each time window, the user identification information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window.
[0035] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:
[0036] Obtain the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information;
[0037] Based on the time order of access time information, the log data stream is divided into window log data under multiple time windows;
[0038] For each time window, the user identification information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window.
[0039] Fifthly, this application also provides a computer program product comprising a computer program that, when executed by a processor, performs the following steps:
[0040] Obtain the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information;
[0041] Based on the time order of access time information, the log data stream is divided into window log data under multiple time windows;
[0042] For each time window, the user identification information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window.
[0043] The aforementioned method, apparatus, device, and medium for predicting online users first acquire the log data stream of the target distributed system. The log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information. Then, based on the temporal order of the access time information, the log data stream is divided into window log data within multiple time windows. This avoids processing large amounts of continuous data all at once, thus improving processing efficiency and facilitating independent analysis and statistics of user access within different time periods, thereby more accurately predicting the number of online users in each time period. Finally, for each time window, the user identification information corresponding to the accessing users in the window log data within that time window is deduplicated and counted to obtain the predicted number of online users within that time window. This improves the accuracy of the final online user count. Attached Figure Description
[0044] Figure 1 A flowchart illustrating a method for predicting online user numbers provided in some embodiments of this application;
[0045] Figure 2 A flowchart for determining the predicted number of online users is provided for some embodiments of this application;
[0046] Figure 3 A flowchart for determining the target bucket to which user identification information belongs, provided in some embodiments of this application;
[0047] Figure 4 A flowchart for determining the predicted number of online users is provided for some embodiments of this application;
[0048] Figure 5 A flowchart for determining the predicted number of online users is provided in some further embodiments of this application;
[0049] Figure 6 A flowchart for obtaining log data streams provided in some embodiments of this application;
[0050] Figure 7 A flowchart illustrating the process of accessing a user access log file to a message queue, provided for some embodiments of this application;
[0051] Figure 8 Structural block diagram of an online user prediction device provided in some embodiments of this application;
[0052] Figure 9 This is an internal structural diagram of a computer device provided in some embodiments of this application. Detailed Implementation
[0053] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0054] The online user prediction method provided in this application can be applied to a target distributed system, such as a large e-commerce platform, social network platform, or live streaming platform, which faces a large number of users accessing the system simultaneously. To accurately predict the online user count, the backend controller in the target distributed system first acquires the log data stream of the target distributed system. The log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information. Then, based on the time order of the access time information, the log data stream is divided into window log data under multiple time windows. Finally, for each time window, the user identification information corresponding to the accessing user in the window log data under that time window is deduplicated and counted to obtain the predicted online user count for that time window. Thus, by dividing the log data stream into time windows for processing and deduplicating the user identification information corresponding to the accessing user in the window log data under each time window, the one-time processing of a large amount of continuous data can be avoided, thereby improving processing efficiency and accuracy.
[0055] In one embodiment, such as Figure 1 As shown, the method is applied to the aforementioned terminal as an example for illustration. In this embodiment, the method includes the following steps:
[0056] Step 102: Obtain the log data stream of the target distributed system.
[0057] In this context, a target distributed system refers to a specific distributed system that requires online user prediction. It consists of multiple computers or nodes located in different geographical locations connected via a network, where these nodes collaborate to complete various system tasks. For example, the backend systems of large e-commerce platforms, social networking platforms, and live streaming platforms are typically distributed systems, facing a large number of simultaneous user accesses, thus requiring accurate prediction of online user numbers.
[0058] Log stream data is a continuous stream of data records related to user access generated during the operation of the target distributed system. This data is continuously generated and transmitted in stream form, containing various information generated by different users accessing the target distributed system, such as accessed pages, operational behaviors, request parameters, and the specific time information of these access behaviors. Access logs are detailed records generated when users access the target distributed system, including but not limited to the URL of the page accessed, the type of device used, the requested resources, and the form data submitted. The corresponding access time information refers to the specific time corresponding to the access log, accurate to the second.
[0059] Optionally, log data can be collected from each node of the target distributed system using a log collection tool and sent to a message queue. Then, these log data streams can be retrieved from the message queue, or the log data can be read directly from the log storage location of the target distributed system.
[0060] Step 104: Based on the time order of access time information, divide the log data stream into window log data under multiple time windows.
[0061] In this context, a time window refers to a predefined, specific period of time. A time window is created by dividing a continuous timeline into fixed-length time segments based on business needs and analytical objectives. Window log data refers to a subset of log data within a specific time window.
[0062] Optionally, the access time information in the log data stream can be sorted according to a preset time window length (e.g., 1 minute), and then the log data stream can be divided into different time windows in chronological order.
[0063] Step 106: For each time window, perform deduplication and count the user identifier information of the accessing users corresponding to the window log data under the time window to obtain the predicted number of online users under the time window.
[0064] Among them, user identification information is used to uniquely identify each accessing user. User identification information can be user ID, account name, device ID, etc.
[0065] Optionally, a probabilistic algorithm, such as the HyperLogLog algorithm, can be used to deduplicatively count user identifiers within the time window. Alternatively, the deduplication function of the database can be used.
[0066] The aforementioned method for predicting online users, by dividing the log data stream into time windows and deduplicating the user identifiers of the accessing users within each time window's log data, avoids processing large amounts of continuous data all at once, thus improving processing efficiency and accuracy. Furthermore, by acquiring the log data stream in real time and processing it in windows, the predicted online user count for each time window can be obtained promptly, meeting the business's real-time requirements.
[0067] In one embodiment, such as Figure 2 As shown, the user identifier information corresponding to the accessing users in the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window, including:
[0068] Step 202: Map each user's identification information to a preset number of buckets using a preset hash function.
[0069] The preset hash function is a pre-defined mathematical function that maps user identification information to a fixed range of values. A bucket can be understood as a data container, a unit used to store the data mapped by the hash function. In this embodiment, each bucket has a unique number; after user identification information is mapped by the hash function, it is assigned to the corresponding bucket.
[0070] Optionally, a suitable preset hash function can be selected, such as the MurmurHash function, and a preset number of buckets can be determined, for example, the preset number of buckets is 1024; then, each user identification information under each time window is traversed, and it is passed as input to the preset hash function to obtain the hash value. Then, based on the hash value and the number of buckets, a modulo operation is performed to map the user identification information to the corresponding bucket.
[0071] Step 204: Determine the predicted number of online users within the time window based on the maximum number of leading zeros recorded in each bucket.
[0072] The maximum number of leading zeros is a logarithmic scale measure of the data size within a bucket, based on probability theory. It is also the number of consecutive zeros preceding a value in its binary representation. In this embodiment, each bucket records the maximum number of leading zeros in the binary representations of all the hash values it receives. For example, if the binary representation of a hash value is 00010101, its leading zeros are 3. Each bucket continuously updates and records the maximum number of leading zeros among all the hash values it receives.
[0073] Optionally, after each user identifier is mapped into a bucket, the leading zeros in the binary representation of the hash value are calculated and compared with the maximum leading zeros recorded in the bucket. If the new leading zeros are larger, the maximum leading zeros in the bucket are updated. The maximum leading zeros of all buckets are collected, and the formula of the HyperLogLog algorithm is used to estimate the number of different users, i.e., to predict the number of online users.
[0074] In this embodiment, a preset hash function is used to evenly distribute different user identifiers into a preset number of buckets. This allows for the distributed processing of large-scale user identifiers, reducing memory usage and computational complexity. Simultaneously, the characteristics of the hash function ensure a relatively even distribution of different user identifiers, improving the accuracy of subsequent estimations. Furthermore, compared to traditional deduplication counting methods, this embodiment only needs to store the maximum number of leading zeros in each bucket, significantly reducing memory usage and enabling the system to process large-scale data with limited memory resources.
[0075] In one embodiment, such as Figure 3 As shown, each user's identification information is mapped to a preset number of buckets using a hash function, including:
[0076] Step 302: Perform a hash calculation on each user identification information to obtain the corresponding hash value.
[0077] Optionally, hash functions such as MurmurHash and CityHash can be selected to iterate through each user identifier in the window log data and pass the user identifier as input to the selected hash function to obtain the corresponding hash value.
[0078] Step 304: Determine the target bucket to which the user identification information belongs based on the first preset number of bits of the hash value.
[0079] In the binary representation of a hash value, a fixed number of bits are selected starting from the leftmost position; these are called the initial preset number of bits. For example, if the preset number is 5, the binary representation of the hash value is 1011010011, and the initial preset number of bits is 10110. These initial preset number of bits are used to determine which bucket the user identification information should be mapped to.
[0080] Optionally, for example, if the preset number of bits is 8, the hash value is first converted to binary representation, then the first 8 bits are truncated, and the corresponding decimal value is calculated based on the truncated bits. This value is the number of the target bucket mentioned in the user identification information. For example, if the truncated first 8 bits are 00000010, which is 2 in decimal, then the user identification information belongs to bucket number 2.
[0081] In this embodiment, the bucket assignment is determined by a pre-set number of bits, further ensuring the uniformity of data distribution among buckets. This uniform distribution helps in subsequent accurate deduplication and online user estimation based on the data within each bucket. Furthermore, this hash value and bit-based mapping method can complete the bucket allocation of a large amount of user identification information in a short time, thereby reducing computation time and resource consumption and improving system processing efficiency.
[0082] In one embodiment, such as Figure 4 As shown, based on the maximum number of leading zeros recorded in each bucket, the predicted number of online users within a time window is determined, including:
[0083] Step 402: Update the maximum number of leading zeros recorded in the target bucket based on the number of leading zeros in the remaining bit sequence of the hash value.
[0084] Optionally, after mapping the user identification information to the target bucket, the remaining bit sequence is extracted from the binary representation of the hash value, and then the number of leading zeros is counted; the calculated number of leading zeros is compared with the maximum number of leading zeros recorded in the target bucket, and if the new number of leading zeros is larger, the maximum number of leading zeros in the target bucket is updated.
[0085] Step 404: Determine the predicted number of online users within the time window based on the harmonic average of the maximum leading zeros for each bucket and the preset number.
[0086] Optionally, the harmonic mean of the largest number of leading zeros can be calculated first using the following formula:
[0087] ;
[0088] In the formula, The harmonic mean of the largest number of leading zeros across all buckets; The preset number of buckets; For the first The maximum number of leading zeros corresponding to each bucket.
[0089] Then, calculate the predicted number of online users for each time window using the following formula:
[0090] ;
[0091] In the formula, It is a predicted number of online users within a certain time window; It is a preset constant; This is the preset number of buckets; It is the harmonic mean of the largest number of leading zeros in all buckets.
[0092] In this embodiment, only the maximum number of leading zeros for each bucket needs to be stored, instead of storing the identification information of all users. This greatly reduces memory usage, enabling the system to run normally with limited memory resources and avoiding performance problems caused by insufficient memory.
[0093] In one embodiment, such as Figure 5 As shown, the user identifier information corresponding to the accessing users in the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window, including:
[0094] Step 502: Use at least two preset hash functions to perform deduplication and counting on the user identification information to obtain the corresponding counting results.
[0095] Optionally, multiple different hash functions can be selected, such as MurmurHash, CityHash, and FNV hash. A separate data structure (such as a set) is maintained for each hash function to store the hash values that have already appeared. The user identification information in the window log data is traversed, and each user identification information is calculated using a different hash function to obtain the corresponding hash value. Then, it is checked whether the hash value already exists in the corresponding data structure; if not, it is added to the data structure, and the count is updated.
[0096] Step 504: Calculate a weighted average of the count results to obtain the predicted number of online users within the time window.
[0097] Optionally, each counting result can be assigned a corresponding weight based on factors such as the performance of different hash functions, with the total weight being 1. Each counting result is multiplied by its corresponding weight, and then these products are summed to obtain the predicted number of online users within the time window.
[0098] In this embodiment, a single hash function may have the problem of hash collisions, that is, different user identification information may generate the same hash value, which will lead to inaccurate deduplication counting. Therefore, using multiple hash functions and taking into account the counting results of each hash function by weighted averaging can reduce the impact of hash collisions on the counting results and improve the accuracy of counting.
[0099] In one embodiment, such as Figure 6 As shown, the process of acquiring log data streams includes:
[0100] Step 602: Collect user access log files from the edge nodes deployed in the target distributed system using a log collector.
[0101] In the target distributed system, edge nodes can be servers, devices, etc., distributed in different geographical locations. They directly interact with users, receive user access requests, and record relevant access logs.
[0102] Optionally, you can use an open-source log collection tool, configure the collection rules of the log collector according to the format and storage location of the log files, such as specifying the path and file type of the log files to be collected; then start the log collector to monitor and collect user access log files on the edge nodes.
[0103] Step 604: Send the user access log file to the message queue of the central cluster to which the edge node is connected.
[0104] The central cluster is a collection of computing resources consisting of multiple servers, typically located in a data center, responsible for the centralized processing and analysis of data collected from edge nodes. A message queue is middleware used to pass messages between different components, managing messages according to a first-in, first-out (FIFO) principle. In this embodiment, the message queue acts as a buffer layer between the edge nodes and the central cluster, temporarily storing user access log files sent by the edge nodes. The central cluster can retrieve log files from the message queue sequentially for processing. Common message queues include Kafka and RabbitMQ.
[0105] Optionally, you can first configure the output of the log collector to the message queue address of the central cluster; then establish a network connection between the log collector and the message queue of the central cluster; finally, send the collected user access log files to the message queue in a certain format (such as JSON) through the log collector.
[0106] Step 606: Continuously retrieve user access log files from the message queue to obtain a log data stream.
[0107] In this embodiment, centralized data management is achieved by collecting user access log files distributed across various edge nodes and sending them to the central cluster. By continuously retrieving log files from the message queue to form a log data stream, real-time analysis and processing of user access logs can be realized, allowing for timely detection of system problems and changes in user behavior, thus providing support for business decisions.
[0108] In one embodiment, such as Figure 7 As shown, sending the user access log file to the message queue of the central cluster to which the edge node is connected includes:
[0109] Step 702: According to the priority order of the generation time, the data in the user access log file is encapsulated into requests in sequence, and the requests are sent to the load balancer of the central cluster to which the edge node is connected.
[0110] Optionally, on the edge node, the user access log file is read, and the data is sorted according to the generation time field in the log data. The sorted log data is then encapsulated into requests in sequence. The requests can use protocols such as HTTP and TCP, and the appropriate protocol is selected according to the actual situation. When encapsulating the requests, the target address of the request (i.e., the address of the load balancer of the central cluster), the request header, and the request body need to be set. Then, the encapsulated requests are sent to the load balancer of the central cluster to which the edge node is connected using the corresponding network library.
[0111] Step 704: The log data from each load balancer is copied to the message queue of the central cluster using a preset replication procedure.
[0112] Optionally, a pre-defined replication program can be deployed in the central cluster. This program can listen to the output port of the load balancer and obtain log data passing through the load balancer. The replication program then copies the obtained log data to the message queue of the central cluster.
[0113] In this embodiment, by encapsulating and sending log data according to the priority order of their generation time, the log data maintains its original chronological order throughout the entire transmission and processing process, providing accurate time information for subsequent data analysis and processing. Furthermore, using a load balancer to evenly distribute requests across the nodes of the central cluster avoids the problem of excessive load on any single node, improving the overall performance and availability of the system.
[0114] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0115] Based on the same inventive concept, this application also provides an online user prediction device for implementing the online user prediction method described above. The solution provided by this device is similar to the implementation described in the above method; therefore, the specific limitations of one or more online user prediction device embodiments provided below can be found in the limitations of the online user prediction method described above, and will not be repeated here.
[0116] In one embodiment, such as Figure 8 As shown, an online user prediction device is provided, comprising: an access data acquisition module 802, a time window division module 804, and an online user determination module 806, wherein:
[0117] The access data acquisition module 802 is used to acquire the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information.
[0118] The time window segmentation module 804 is used to divide the log data stream into window log data under multiple time windows based on the time order of access time information.
[0119] The online user count determination module 806 is used to perform deduplication and counting of the user identification information of the accessing users corresponding to the window log data under each time window, so as to obtain the predicted online user count under the time window.
[0120] In one embodiment, the online user count determination module 806 is further configured to: map each user identification information to a preset number of buckets using a preset hash function; and determine the predicted online user count within a time window based on the maximum number of leading zeros recorded in each bucket.
[0121] In one embodiment, the online user determination module 806 is further configured to: perform a hash calculation on each user identification information to obtain the corresponding hash value; and determine the target bucket to which the user identification information belongs based on the first preset number of bits of the hash value.
[0122] In one embodiment, the online user determination module 806 is further configured to: update the maximum number of leading zeros recorded in the target bucket according to the number of leading zeros in the remaining bit sequence of the hash value; and determine the predicted online user number under the time window according to the harmonic average of the maximum number of leading zeros corresponding to each bucket and a preset number.
[0123] In one embodiment, the online user count determination module 806 is further configured to: use at least two preset hash functions to perform deduplication counting on the user identification information to obtain the corresponding counting results; and perform a weighted average of the counting results to obtain the predicted online user count under the time window.
[0124] In one embodiment, the access data acquisition module 802 is further configured to: collect user access log files from edge nodes deployed in the target distributed system using a log collector; send the user access log files to the message queue of the central cluster to which the edge nodes are connected; and continuously acquire user access log files from the message queue to obtain a log data stream.
[0125] In one embodiment, the access data acquisition module 802 is further configured to: encapsulate the data in the user access log file into requests in sequence according to the priority order of their generation time, and send the requests to the load balancer of the central cluster to which the edge node is connected; and replicate each log data via the load balancer to the message queue of the central cluster through a preset replication program.
[0126] Each module in the aforementioned online user prediction device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the corresponding operations of each module.
[0127] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9 As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a method for predicting the number of online users. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0128] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0129] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0130] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps in the above method embodiments.
[0131] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above method embodiments.
[0132] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0133] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0134] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0135] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A method for predicting online user numbers, characterized in that, The method includes: Obtain the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information; Based on the time sequence of the access time information, the log data stream is divided into window log data under multiple time windows; For each time window, the user identification information of the accessing users corresponding to the window log data under the time window is deduplicated and counted to obtain the predicted number of online users under the time window.
2. The method according to claim 1, characterized in that, The step of deduplicating and counting the user identifiers of the accessing users corresponding to the window log data under the time window to obtain the predicted number of online users under the time window includes: Each user identification information is mapped to a preset number of buckets using a preset hash function; The predicted number of online users within the time window is determined based on the maximum number of leading zeros recorded in each bucket.
3. The method according to claim 2, characterized in that, The step of mapping each of the user identification information to a preset number of buckets using a hash function includes: Perform a hash calculation on each of the user identification information to obtain the corresponding hash value; The target bucket to which the user identification information belongs is determined based on the first preset number of bits of the hash value.
4. The method according to claim 3, characterized in that, Determining the predicted number of online users within the time window based on the maximum number of leading zeros recorded in each bucket includes: Update the maximum number of leading zeros recorded in the target bucket based on the number of leading zeros in the remaining bit sequence of the hash value; The predicted number of online users under the time window is determined based on the harmonic average of the maximum leading zeros corresponding to each bucket and the preset quantity.
5. The method according to claim 1, characterized in that, The step of deduplicating and counting the user identifiers of the accessing users corresponding to the window log data under the time window to obtain the predicted number of online users under the time window includes: At least two preset hash functions are used to perform deduplication and counting on the user identification information to obtain the corresponding counting results; The predicted number of online users under the time window is obtained by weighting and averaging the count results.
6. The method according to claim 1, characterized in that, The process of acquiring the log data stream includes: User access log files are collected from the edge nodes deployed in the target distributed system using a log collector. The user access log file is sent to the message queue of the central cluster to which the edge node is connected; The user access log file is continuously retrieved from the message queue to obtain the log data stream.
7. The method according to claim 6, characterized in that, The step of sending the user access log file to the message queue of the central cluster to which the edge node is connected includes: According to the priority order of the generation time, the data in the user access log file are sequentially encapsulated into requests, and the requests are sent to the load balancer of the central cluster to which the edge node is connected. The log data from each load balancer is replicated to the message queue of the central cluster using a pre-defined replication procedure.
8. A device for predicting the number of online users, characterized in that, The device includes: The access data acquisition module is used to acquire the log data stream of the target distributed system; the log stream data includes access logs generated by different users accessing the target distributed system and corresponding access time information; The time window segmentation module is used to divide the log data stream into window log data under multiple time windows based on the time order of the access time information; The online user count determination module is used to perform deduplication and counting of the user identification information of the accessing users corresponding to the window log data under each time window, so as to obtain the predicted online user count under the time window.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 7.