
字数 1190,阅读大约需 6 分钟
近期看了几篇关于日志解决方案的文章, 发现它们都在使用 Apache Parquet 作为存储文件格式. 如下:
这勾起了我的好奇心:
Apache Parquet 是一种开源的列式存储文件格式,专门为大数据处理框架设计,最初由 Twitter 和 Cloudera 联合开发,现为 Apache 顶级项目。
行式存储:Row1[col1,col2,col3], Row2[col1,col2,col3], ...
列式存储:Column1[所有行的值], Column2[所有行的值], ...# 示例:日志存储成本对比
原始 JSON 日志:1TB → 存储成本 $$$$
Parquet 压缩后:~100GB → 存储成本 $-- 典型日志查询场景
SELECT COUNT(*), error_code
FROM logs
WHERE date >= '2024-01-01'
AND status = 'ERROR'
GROUP BY error_code;
-- Parquet 优势:
-- 1. 只读取 date, status, error_code 三列
-- 2. 利用列统计快速跳过无关日期分区
-- 3. 压缩数据减少磁盘 I/O# 典型日志处理管道
原始日志 → Fluentd/Logstash → Kafka →
Spark Streaming → Parquet (S3/ADLS) →
Trino/Athena 查询 → BI 工具原始日志 (JSON/文本)
↓
实时处理层 (Kafka)
↓
批处理层 (Spark) → 转换为 Parquet
↓
云存储 (S3/GCS) → 分区: dt=2024-01-01/
↓
查询层 (Athena/Presto)
↓
可视化 (Grafana/Tableau)Parquet 已成为现代数据湖和日志分析的事实标准格式,特别适合需要长期存储、批量分析和成本优化的日志管理场景。
[1] Yelp 发布大规模管理 S3 服务器访问日志的方案_架构_InfoQ精选文章: https://www.infoq.cn/article/yYvYwDZJOIEVI2h1rKvq
[2] Cloudflare Log Explorer is now GA, providing native observability and forensics: https://blog.cloudflare.com/logexplorer-ga/
[3] 逆势降本:云上数据平台年复削减30%的治理实践_云计算_吴建阳_InfoQ精选文章: https://www.infoq.cn/article/lgHiav5blTU6Sa8yaF7l
[4] AWS Debuts a Distributed SQL Database, Amazon S3 Tables for Iceberg - The New Stack: https://thenewstack.io/aws-debuts-a-distributed-sql-database-s3-tables-for-iceberg/
[5] Grafana Tempo 2.5 release: vParquet4, streaming endpoints, and more metrics | Grafana Labs: https://grafana.com/blog/grafana-tempo-2-5-release-vparquet4-streaming-endpoints-and-more-metrics/
[6] 对象存储应用:云原生最新架构 - The New Stack --- Object Store Apps: Cloud Native's Freshest Architecture - The New Stack: https://thenewstack.io/object-store-apps-cloud-natives-freshest-architecture/
[7] Extracting key insights from Amazon S3 access logs with AWS Glue for Ray | AWS Big Data Blog: https://aws.amazon.com/cn/blogs/big-data/extracting-key-insights-from-amazon-s3-access-logs-with-aws-glue-for-ray/