Session duration calculation method and device, computer device, and storage medium

By integrating the session duration calculation algorithm into the ClickHouse database and leveraging its aggregation and replacement engine, real-time session duration statistics in edge computing environments were achieved, solving the problems of high storage and bandwidth costs and meeting the needs of massive data storage.

CN116319948BActive Publication Date: 2026-04-21XIAMEN JIKUAI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
XIAMEN JIKUAI TECH CO LTD
Filing Date
2022-09-09
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In edge computing scenarios, existing technical solutions require pushing access logs to a central server for processing, which increases storage and bandwidth costs. Furthermore, the update operations of time-series databases consume system resources, cannot meet the needs of massive data storage, and suffer from analysis latency.

Method used

By integrating the session duration calculation algorithm into the ClickHouse database and leveraging its aggregation and replacement engines, real-time session duration statistics are performed based on materialized views and the replacement engine by creating access log tables and session log tables, reducing intermediate steps and saving equipment and storage costs.

Benefits of technology

It enables real-time statistics of session duration, reduces the cost of intermediate links such as Kafka, avoids the additional overhead of data reading and writing, and meets the needs of massive data storage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116319948B_ABST
    Figure CN116319948B_ABST
Patent Text Reader

Abstract

This application provides a method, apparatus, computer device, and storage medium for calculating session duration. The method involves creating an access log table and generating link identifiers for each session in the access log table; creating a session log table based on the link identifier, start time, end time, and access duration of each session, and using the link identifier and start time in the session log table as the session identifier; and replacing records with the same session identifier in the session log table using the ClickHouse replacement engine. This invention integrates the session duration algorithm into the ClickHouse database, fully utilizing the ClickHouse aggregation and replacement engines to achieve real-time statistics of access duration. This not only reduces intermediate steps and saves costs associated with devices, storage, and maintenance such as those associated with Kafka, but also eliminates the need to develop external applications, avoiding the bandwidth and memory costs associated with reading and writing data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of session processing technology, and in particular to a method, apparatus, computer device and storage medium for calculating session duration. Background Technology

[0002] In fields such as cloud computing and edge computing, to meet the needs of information security supervision and their own business requirements, it is necessary to log and statistically analyze network access. Unlike data centers, where dedicated equipment can be deployed for analysis and statistics, edge computing scenarios have limited device resources, making it inconvenient to perform resource-intensive operations such as statistical analysis. Access logs are often pushed to a central server for processing. Currently, most mainstream solutions push logs to a Kafka cluster, then write programs to subscribe to messages from the Kafka cluster for offline statistical analysis, and finally save the results to a time-series database. Network traffic often generates a large amount of logs. In this solution, using Kafka as an intermediate data storage incurs double the storage and bandwidth costs. Furthermore, for access duration statistics, analyzing and then storing the data introduces significant latency. Real-time storage, on the other hand, is often not supported by time-series databases, or update operations require substantial system resources, leading to performance degradation and failing to meet the demands of massive data storage. Summary of the Invention

[0003] This application provides a method, apparatus, computer device, and storage medium for calculating session duration, so as to realize real-time statistics of session duration.

[0004] Firstly, this application provides a method for calculating session duration, the method comprising:

[0005] Create an access log table and generate link identifiers for each session in the access log table;

[0006] Based on the ClickHouse materialized view, records with the same link identifier in the access log table are aggregated and segmented, and the start time, end time and access duration of each session are calculated.

[0007] A session log table is created based on the link identifier, start time, end time, and access duration of each session, and the link identifier and start time in the session log table are used as the session identifier.

[0008] Based on the ClickHouse replacement engine, records with the same session identifier in the session log table are replaced to achieve real-time statistics of session duration.

[0009] Furthermore, the method for calculating session duration also includes:

[0010] Create a last session dictionary table based on the session records in the session log table whose last access time is less than a preset access interval threshold;

[0011] Within the preset access interval threshold, the last session record in the last session dictionary table is refreshed.

[0012] Before replacing records with the same session identifier in the session log table based on the ClickHouse replacement engine to achieve real-time session duration statistics, the process also includes:

[0013] The access log table is statistically analyzed using materialized views, and the results are stored in the session log table.

[0014] The step of performing statistical analysis on the access log table using materialized views and storing the results in the session log table includes:

[0015] The sessions in the access log table are grouped according to the link identifier to generate session groups;

[0016] Sort the session groups with the same link identifier by time;

[0017] According to the access time threshold, each sorted session group is divided into N ordered time session groups.

[0018] The N ordered time session groups are split into multiple session records;

[0019] Take the minimum time of each session record as the start time, and take the maximum time of each session record as the end time;

[0020] The access duration is generated based on the difference between the start time and the end time.

[0021] Each link identifier, along with its corresponding start time, end time, and access duration, is stored in the session log table.

[0022] The step of refreshing the last session record in the last session dictionary table within the preset access interval threshold includes:

[0023] The last session information corresponding to each link identifier is obtained from the last session dictionary table and used as the last session record.

[0024] The time difference is calculated based on the minimum time of the first session group in the N ordered time session groups and the end time of the last session record;

[0025] When the time difference is less than the access interval threshold, the start time of the last session record is obtained and used as the start time of the first session group to complete the update of the last access duration.

[0026] The method for calculating session duration also includes:

[0027] At each access interval threshold, session records whose last access duration is less than the access interval threshold are read from the session log table and stored in the last session dictionary table.

[0028] The link identifier includes the access time, source IP, destination IP, source port, destination port, and protocol for each session.

[0029] Secondly, this application also provides a session duration calculation device, the session duration calculation device comprising:

[0030] The access log creation module is used to create an access log table and generate link identifiers for each session in the access log table.

[0031] The session parameter calculation module is used to aggregate and segment records with the same link identifier in the access log table based on the Clickhouse materialized view, and calculate the start time, end time and access duration of each session.

[0032] The session log creation module is used to create a session log table based on the link identifier, start time, end time and access duration of each session, and use the link identifier and start time in the session log table as the session identifier.

[0033] The session duration statistics module is used to replace records with the same session identifier in the session log table based on the ClickHouse replacement engine, so as to realize real-time statistics of session duration.

[0034] Thirdly, this application also provides a computer device, the computer device including a memory and a processor; the memory is used to store a computer program; the processor is used to execute the computer program and, when executing the computer program, implement the session duration calculation method as described above.

[0035] Fourthly, this application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to implement the session duration calculation method described above.

[0036] This application discloses a method, apparatus, computer device, and storage medium for calculating session duration. The method involves creating an access log table and generating link identifiers for each session in the access log table; aggregating and segmenting records with the same link identifier in the access log table based on ClickHouse materialized views, and calculating the start time, end time, and access duration of each session; creating a session log table based on the link identifier, start time, end time, and access duration of each session, and using the link identifier and start time in the session log table as the session identifier; and replacing records with the same session identifier in the session log table based on the ClickHouse replacement engine to achieve real-time statistics of session duration. Through this method, the present invention integrates the session duration algorithm into the ClickHouse database, fully utilizing the ClickHouse aggregation and replacement engines to achieve real-time statistics of access duration. This not only reduces intermediate steps and saves costs such as equipment, storage, and maintenance costs associated with Kafka, but also eliminates the need to develop external applications, avoiding the bandwidth and memory costs incurred from reading data out and writing it back in. Attached Figure Description

[0037] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0038] Figure 1 This is a schematic flowchart illustrating a session duration calculation method provided in an embodiment of this application;

[0039] Figure 2 This is a schematic block diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation

[0040] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0041] The flowchart shown in the attached diagram is for illustrative purposes only and does not necessarily include all content and operations / steps, nor does it necessarily have to be performed in the order described. For example, some operations / steps can be broken down, combined, or partially merged, so the actual execution order may change depending on the actual situation.

[0042] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0043] It should also be understood that the term "and / or" as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0044] This application provides a method, apparatus, computer device, and storage medium for calculating session duration. The session duration calculation method can be applied to a server, integrating the session duration algorithm into the ClickHouse database. It fully utilizes the ClickHouse aggregation and replacement engines to achieve real-time statistics of access duration. This not only reduces intermediate steps and saves costs associated with devices, storage, and maintenance such as those used by Kafka, but also eliminates the need to develop external applications, avoiding the bandwidth and memory costs associated with reading and writing data. The server can be a standalone server or a server cluster.

[0045] The following detailed description of some embodiments of this application is provided in conjunction with the accompanying drawings. Unless otherwise specified, the following embodiments and features can be combined with each other.

[0046] Please see Figure 1 , Figure 1 This is a schematic flowchart illustrating a session duration calculation method provided in an embodiment of this application. This session duration calculation method can be applied to a server to integrate the session duration algorithm into the ClickHouse database, fully utilizing the ClickHouse aggregation engine and replacement engine to achieve real-time statistics of access duration.

[0047] like Figure 1 As shown, the method for calculating session duration specifically includes steps S101 to S103.

[0048] S101. Create an access log table and generate link identifiers for each session in the access log table;

[0049] S102. Based on the Clickhouse materialized view, aggregate and split the records with the same link identifier in the access log table, and calculate the start time, end time and access duration of each session.

[0050] S103. Create a session log table based on the link identifier, start time, end time and access duration of each session, and use the link identifier and start time in the session log table as the session identifier.

[0051] S104. Based on the ClickHouse replacement engine, replace records with the same session identifier in the session log table to achieve real-time statistics of session duration.

[0052] Furthermore, the method for calculating session duration also includes:

[0053] Create a last session dictionary table based on the session records in the session log table whose last access time is less than a preset access interval threshold;

[0054] Within the preset access interval threshold, the last session record in the last session dictionary table is refreshed.

[0055] Furthermore, before replacing records with the same session identifier in the session log table based on the ClickHouse replacement engine to achieve real-time session duration statistics, the process also includes:

[0056] The access log table is statistically analyzed using materialized views, and the results are stored in the session log table.

[0057] Further, the step of performing statistical analysis on the access log table through materialized views and storing the results in the session log table includes:

[0058] The sessions in the access log table are grouped according to the link identifier to generate session groups;

[0059] Sort the session groups with the same link identifier by time;

[0060] According to the access time threshold, each sorted session group is divided into N ordered time session groups.

[0061] The N ordered time session groups are split into multiple session records;

[0062] Take the minimum time of each session record as the start time, and take the maximum time of each session record as the end time;

[0063] The access duration is generated based on the difference between the start time and the end time.

[0064] Each link identifier, along with its corresponding start time, end time, and access duration, is stored in the session log table.

[0065] Further, refreshing the last session record in the last session dictionary table within the preset access interval threshold includes:

[0066] The last session information corresponding to each link identifier is obtained from the last session dictionary table and used as the last session record.

[0067] The time difference is calculated based on the minimum time of the first session group in the N ordered time session groups and the end time of the last session record;

[0068] When the time difference is less than the access interval threshold, the start time of the last session record is obtained and used as the start time of the first session group to complete the update of the last access duration.

[0069] Furthermore, the method for calculating session duration also includes:

[0070] At each access interval threshold, session records whose last access duration is less than the access interval threshold are read from the session log table and stored in the last session dictionary table.

[0071] The link identifier includes the access time, source IP, destination IP, source port, destination port, and protocol for each session.

[0072] This embodiment provides a method for real-time calculation of session duration based on ClickHouse, specifically including:

[0073] S1. Create an access log table called connections, which includes fields such as access time, source IP, destination IP, source port, destination port, and protocol. Record the same source IP, destination IP, source port, destination port, and protocol as the connection identifier ConnID.

[0074] S2, create a session log table sessionlogs, which includes fields such as link identifier ConnID, start time StartTime, end time EndTime, and access duration Duration. At the same time, mark the same link identifier ConnID and start time StartTime as session identifier SessionID.

[0075] S3, set the access interval threshold interval;

[0076] S4. Read session records whose last access time is less than the interval threshold from the session log table sessionlogs, and create a last session dictionary table (last_session) based on the session records whose last access time is less than the interval threshold.

[0077] S5, within the interval threshold, the system automatically refreshes the last session record (last_session) in S4;

[0078] S6, create a materialized view connections_split, perform statistical analysis on the connections table inserted into S1, and store the results in the session log table sessionlogs in S2;

[0079] S7 uses the ClickHouse replacement engine to replace records with the same session ID in S2, thereby achieving real-time statistics;

[0080] The specific steps for S6 are as follows:

[0081] S61, for the batch insertion into the log table connections in S1, group them according to the connection identifier ConnID to obtain a time series times with the same connection identifier ConnID;

[0082] S62, use arraySort to sort the time series times in ascending order to obtain an ordered time series timesB;

[0083] S63, based on the interval threshold set in S3, use arraySplit to cut records in the ordered time series timesB where the interval between consecutive records exceeds the threshold interval, to obtain N ordered time series parts;

[0084] S64, use dictGet to get the last session information of this link identifier ConnID from the last session dictionary table lass_session in S4, and denot it as lastSession;

[0085] S65, if the minimum value of the first time series parts[0] in S63 and the end time of the last session information lastSession do not exceed the threshold interval set in S3, then the first time series parts[0] is a continuation of the last session information lastSession. Therefore, the start time of the last session information lastSession is taken as the start time of the first time series parts[0], thereby realizing the continuous update of the last access duration.

[0086] S66 uses arrayJoin to split the ordered time series parts into multiple records timesC;

[0087] S67. For each split record, take the minimum value of timesC as the start time StartTime and the maximum value as the end time EndTime. The difference between the two is the access duration Duration, which is inserted into the S2 session log table sessionlogs along with the link identifier ConnID.

[0088] Therefore, the method of this invention fully utilizes the ClickHouse aggregation engine and replacement engine to achieve real-time statistics of access duration. By integrating the session duration algorithm into the ClickHouse database, it not only reduces intermediate steps and saves costs associated with devices, storage, and maintenance such as those associated with Kafka, but also eliminates the need to develop external applications, avoiding the bandwidth and memory costs associated with reading and writing data.

[0089] This application discloses a method, apparatus, computer device, and storage medium for calculating session duration. The method involves creating an access log table and generating link identifiers for each session in the access log table; creating a session log table based on the link identifier, start time, end time, and access duration of each session, and using the link identifier and start time in the session log table as the session identifier; and replacing records with the same session identifier in the session log table using the ClickHouse replacement engine to achieve real-time statistics of session duration. Through this method, the present invention integrates the session duration algorithm into the ClickHouse database, fully utilizing the ClickHouse aggregation and replacement engines to achieve real-time statistics of access duration. This not only reduces intermediate steps and saves costs associated with devices, storage, and maintenance such as those associated with Kafka, but also eliminates the need to develop external applications, avoiding the bandwidth and memory costs incurred from reading and writing data back into the database.

[0090] An embodiment of this application provides a schematic block diagram of a session duration calculation device, which is used to execute the aforementioned session duration calculation method. The session duration calculation device can be configured on a server.

[0091] The session duration calculation device includes:

[0092] The access log creation module is used to create an access log table and generate link identifiers for each session in the access log table.

[0093] The session parameter calculation module is used to aggregate and segment records with the same link identifier in the access log table based on the Clickhouse materialized view, and calculate the start time, end time and access duration of each session.

[0094] The session log creation module is used to create a session log table based on the link identifier, start time, end time and access duration of each session, and use the link identifier and start time in the session log table as the session identifier.

[0095] The session duration statistics module is used to replace records with the same session identifier in the session log table based on the ClickHouse replacement engine, so as to realize real-time statistics of session duration.

[0096] Furthermore, the session duration calculation device also includes a last session record refresh module, which is used for:

[0097] Create a last session dictionary table based on the session records in the session log table whose last access time is less than a preset access interval threshold;

[0098] Within the preset access interval threshold, the last session record in the last session dictionary table is refreshed.

[0099] Furthermore, the session duration calculation device also includes:

[0100] The access log table analysis module is used to perform statistical analysis on the access log table through materialized views, and store the results of the statistical analysis in the session log table.

[0101] Furthermore, the access log table analysis module is also used for:

[0102] The sessions in the access log table are grouped according to the link identifier to generate session groups;

[0103] Sort the session groups with the same link identifier by time;

[0104] According to the access time threshold, each sorted session group is divided into N ordered time session groups.

[0105] The N ordered time session groups are split into multiple session records;

[0106] Take the minimum time of each session record as the start time, and take the maximum time of each session record as the end time;

[0107] The access duration is generated based on the difference between the start time and the end time.

[0108] Each link identifier, along with its corresponding start time, end time, and access duration, is stored in the session log table.

[0109] Furthermore, the last session record refresh module is also used for:

[0110] The last session information corresponding to each link identifier is obtained from the last session dictionary table and used as the last session record.

[0111] The time difference is calculated based on the minimum time of the first session group in the N ordered time session groups and the end time of the last session record;

[0112] When the time difference is less than the access interval threshold, the start time of the last session record is obtained and used as the start time of the first session group to complete the update of the last access duration.

[0113] Furthermore, the session duration calculation device also includes:

[0114] The final session dictionary table update module is used to read session records whose last access duration is less than the access interval threshold from the session log table every access interval threshold and store them in the final session dictionary table.

[0115] Furthermore, the link identifier includes the access time, source IP, destination IP, source port, destination port, and protocol for each session.

[0116] It should be noted that those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the above-described apparatus and modules can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0117] The aforementioned device can be implemented as a computer program, which can be used in, for example... Figure 2 It runs on the computer device shown.

[0118] Please see Figure 2 , Figure 2 This is a schematic block diagram illustrating the structure of a computer device according to an embodiment of this application. The computer device may be a server.

[0119] See Figure 2 The computer device includes a processor, memory, and network interface connected via a system bus, wherein the memory may include non-volatile storage media and internal memory.

[0120] Non-volatile storage media can store operating systems and computer programs. These computer programs include program instructions that, when executed, cause the processor to perform any method for calculating session duration.

[0121] The processor provides computing and control capabilities, supporting the operation of the entire computer device.

[0122] Internal memory provides an environment for the execution of computer programs in non-volatile storage media, which, when executed by a processor, enable the processor to perform any method of session duration calculation.

[0123] This network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that... Figure 2 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.

[0124] It should be understood that the processor can be a Central Processing Unit (CPU), but it can also be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. Among these, a general-purpose processor can be a microprocessor or any conventional processor.

[0125] In one embodiment, the processor is configured to run a computer program stored in memory to perform the following steps:

[0126] Create an access log table and generate link identifiers for each session in the access log table;

[0127] Based on the ClickHouse materialized view, records with the same link identifier in the access log table are aggregated and segmented, and the start time, end time and access duration of each session are calculated.

[0128] A session log table is created based on the link identifier, start time, end time, and access duration of each session, and the link identifier and start time in the session log table are used as the session identifier.

[0129] Based on the ClickHouse replacement engine, records with the same session identifier in the session log table are replaced to achieve real-time statistics of session duration.

[0130] In one embodiment, when implementing the session duration calculation method, the processor is configured to:

[0131] Create a last session dictionary table based on the session records in the session log table whose last access time is less than a preset access interval threshold;

[0132] Within the preset access interval threshold, the last session record in the last session dictionary table is refreshed.

[0133] In one embodiment, before implementing the replacement of records with the same session identifier in the session log table based on the ClickHouse replacement engine to achieve real-time statistics of session duration, the processor is also configured to implement:

[0134] The access log table is statistically analyzed using materialized views, and the results are stored in the session log table.

[0135] In one embodiment, the processor, in addition to implementing the statistical analysis of the access log table through a materialized view and storing the statistical analysis results in the session log table, is also configured to:

[0136] The sessions in the access log table are grouped according to the link identifier to generate session groups;

[0137] Sort the session groups with the same link identifier by time;

[0138] According to the access time threshold, each sorted session group is divided into N ordered time session groups.

[0139] The N ordered time session groups are split into multiple session records;

[0140] Take the minimum time of each session record as the start time, and take the maximum time of each session record as the end time;

[0141] The access duration is generated based on the difference between the start time and the end time.

[0142] Each link identifier, along with its corresponding start time, end time, and access duration, is stored in the session log table.

[0143] In one embodiment, the processor, in addition to refreshing the last session record in the last session dictionary table within the preset access interval threshold, is further configured to:

[0144] The last session information corresponding to each link identifier is obtained from the last session dictionary table and used as the last session record.

[0145] The time difference is calculated based on the minimum time of the first session group in the N ordered time session groups and the end time of the last session record;

[0146] When the time difference is less than the access interval threshold, the start time of the last session record is obtained and used as the start time of the first session group to complete the update of the last access duration.

[0147] In one embodiment, the processor, in implementing the session duration calculation method, is further configured to implement:

[0148] At each access interval threshold, session records whose last access duration is less than the access interval threshold are read from the session log table and stored in the last session dictionary table.

[0149] The embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions, and the processor executing the program instructions to implement any of the session duration calculation methods provided in the embodiments of this application.

[0150] The computer-readable storage medium may be an internal storage unit of the computer device described in the foregoing embodiments, such as the hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, SmartMedia Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device.

[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for calculating session duration, characterized in that, The method for calculating session duration includes: Create an access log table and generate link identifiers for each session in the access log table; Based on the ClickHouse materialized view, records with the same link identifier in the access log table are aggregated and segmented, and the start time, end time and access duration of each session are calculated. A session log table is created based on the link identifier, start time, end time, and access duration of each session, and the link identifier and start time in the session log table are used as the session identifier. Based on the ClickHouse replacement engine, records with the same session identifier in the session log table are replaced to achieve real-time statistics of session duration.

2. The session duration calculation method according to claim 1, characterized in that, The method for calculating session duration also includes: Create a last session dictionary table based on the session records in the session log table whose last access time is less than a preset access interval threshold; Within the preset access interval threshold, the last session record in the last session dictionary table is refreshed.

3. The session duration calculation method according to claim 2, characterized in that, Before replacing records with the same session identifier in the session log table based on the ClickHouse replacement engine to achieve real-time session duration statistics, the process also includes: The access log table is statistically analyzed using materialized views, and the results are stored in the session log table.

4. The session duration calculation method according to claim 3, characterized in that, The step of performing statistical analysis on the access log table using materialized views and storing the results in the session log table includes: The sessions in the access log table are grouped according to the link identifier to generate session groups; Sort the session groups with the same link identifier by time; According to the preset access interval threshold, each sorted session group is divided into N ordered time session groups. The N ordered time session groups are split into multiple session records; Take the minimum time of each session record as the start time, and take the maximum time of each session record as the end time; The access duration is generated based on the difference between the start time and the end time. Each link identifier, along with its corresponding start time, end time, and access duration, is stored in the session log table.

5. The session duration calculation method according to claim 4, characterized in that, The step of refreshing the last session record in the last session dictionary table within the preset access interval threshold includes: The last session information corresponding to each link identifier is obtained from the last session dictionary table and used as the last session record. The time difference is calculated based on the minimum time of the first session group in the N ordered time session groups and the end time of the last session record; When the time difference is less than the access interval threshold, the start time of the last session record is obtained and used as the start time of the first session group to complete the update of the last access duration.

6. The session duration calculation method according to claim 5, characterized in that, The method for calculating session duration also includes: At each access interval threshold, session records whose last access duration is less than the access interval threshold are read from the session log table and stored in the last session dictionary table.

7. The method for calculating session duration according to any one of claims 1-6, characterized in that, The link identifier includes the source IP, destination IP, source port, destination port, and protocol.

8. A conversation duration calculation device, characterized in that, The session duration calculation device includes: The access log creation module is used to create an access log table and generate link identifiers for each session in the access log table. The session parameter calculation module is used to aggregate and split records with the same link identifier in the access log table based on the Clickhouse materialized view, and calculate the start time, end time and access duration of each session. The session log creation module is used to create a session log table based on the link identifier, start time, end time and access duration of each session, and use the link identifier and start time in the session log table as the session identifier. The session duration statistics module is used to replace records with the same session identifier in the session log table based on the ClickHouse replacement engine, so as to realize real-time statistics of session duration.

9. A computer device, characterized in that, The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and, when executing the computer program, implement the session duration calculation method as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, causes the processor to implement the session duration calculation method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method, device and server for monitoring microphone connecting conversation

    CN105933375A

  • Method, device and system for calculating session duration

    CN109213906A