Abstract
Modern industrial systems generate massive volumes of logs, creating significant storage and operational burdens. Traditional general-purpose compression tools like gzip often fail to exploit the inherent structure of logs, where static templates are interspersed with variable parameters. This paper presents Logzip, a high-performance log compression framework that utilizes a novel Iterative Structure Extraction (ISE) algorithm. Logzip automatically separates logs into structured data streams—static templates and variable parameters—enabling standard compression kernels to achieve significantly higher compression ratios. Evaluation on diverse large-scale datasets shows that Logzip can save approximately 50% more storage space than traditional tools while maintaining comparable execution speeds through parallelization.
Introduction
Modern industrial systems generate massive volumes of logs, often reaching terabytes per day. While storage costs are declining, the sheer scale of this "fast-growing big data" creates substantial financial and operational challenges. Traditional compression tools like gzip or bzip2 are general-purpose, relying on sliding windows (e.g., 32KB) to identify redundant strings. However, system logs possess a unique structure: they are typically generated by static code statements (e.g., log.info("Found block {} locally", blockId)), resulting in a collection of a few hundred "templates" filled with millions of "parameters." General-purpose tools often fail to exploit this global structure because redundant templates are frequently separated by variable data exceeding the sliding window size.
The Logzip Framework
Logzip is a high-performance compression framework designed to treat logs as structured data. It operates by transforming raw logs into highly coherent data streams before passing them to a standard compression "kernel" such as gzip, bzip2, or lzma.
The framework processes logs through three primary levels:
- Field Extraction: Utilizing regular expressions, Logzip extracts standard header fields such as Date, Time, Level, and Component.
- Template Extraction: This core stage employs the Iterative Structure Extraction (ISE) algorithm to automatically separate static message templates from variable content.
- Parameter Mapping: For repetitive variables like HDFS block IDs, Logzip maps unique strings to short 64-base IDs, further reducing the footprint of the variable data.
By grouping parameters belonging to the same template together, Logzip creates data streams with extremely high local redundancy, which standard compression algorithms can then compress far more efficiently.
Iterative Structure Extraction (ISE)
The primary innovation of Logzip is its ISE algorithm, which avoids the need for exhaustive processing of every log line to identify templates.
The ISE process follows an iterative loop:
- Sampling: A small fraction (e.g., 1%) of the logs is randomly sampled.
- Clustering: These samples are grouped hierarchically based on log level, component name, and frequent tokens. An optimized Longest Common Subsequence (LCS) algorithm identifies the "constant" template part.
- Matching: A Prefix Tree (Trie) of these templates is built to quickly match the remaining 99% of the logs.
- Iteration: Any logs that fail to match are fed back into the next round of sampling until a high coverage (typically ~90%) is achieved.
This approach is "embarrassingly parallel," allowing Logzip to scale effectively across multiple CPU cores.
Evaluation and Key Results
Logzip was evaluated on five diverse datasets from the loghub repository (HDFS, Spark, Android, Windows, and Thunderbird), totaling 63.6 GB.
- Superior Compression: Logzip achieved approximately 50% higher compression ratios on average compared to traditional tools. On Windows logs specifically, Logzip (using a gzip kernel) outperformed plain gzip by 15.1x.
- Industrial Performance: In a deployment at Huawei, Logzip reduced storage requirements for a system generating 2TB of logs daily by 40% compared to their previous gzip-based solution.
- Efficiency: When parallelized with 32 workers, Logzip's execution time is comparable to or faster than standard gzip, making it suitable for production environments with tight compression windows.
Conclusion
Logzip demonstrates that treating logs as structured data rather than raw text can yield massive gains in compression efficiency. By leveraging sampling and iterative clustering, it identifies global structures that general-purpose tools miss. While currently optimized for human-readable textual logs and requiring minimal initial regex setup for headers, Logzip represents a significant step forward in managing the storage demands of modern big data systems.
Summary updated