system health, performance issues, and security threats.
real-time processing and alerting
scalable storage for log data
analysis tools
monitoring
multi-tenancy
user data retention and archiving policy
alert and monitoring
scalability
高可用性:支持故障恢复,99.99% SLA
可扩展性:支持百万级 QPS 读写
低延迟:写入 10ms ~ 100 ms(for message queue),查询 50~ 500ms
数据一致性:支持最终一致性,部分查询支持强一致性
安全:日志加密存储,访问控制,审计日志
10K services, each 1MB logs per minutes = 17KB per sec, each log is 1KB
qps:
write:
17 * 10K = 170K qps
peak hour * 3 = 510K
read:
5 per service = 50K QPS
peak hour * 3 = 150K
Network:
average:
170M per sec
peak:
170 * 3 = 510M per sec
data storage:
170M * 3600 * 24 = 15Million * M = 15T per day
storage 3 years with replica 3 = 49PB
POST /logs
{
"service_id": "abc123",
"timestamp": 1700000000,
"log_level": "ERROR",
"message": "Database connection failed"
}
GET /logs?service_id=abc123&start=1700000000&end=1700001000&level=ERROR
POST /alerts
{
"rule": "error_rate > 5%",
"action": "notify",
"threshold": 5
}
使用 Elasticsearch 或 ClickHouse 存储,支持全文搜索和分析。
sql
CopyEdit
CREATE TABLE logs (
service_id STRING,
timestamp TIMESTAMP,
log_level STRING,
message TEXT
) ENGINE = MergeTree ORDER BY (service_id, timestamp);
数据加密:TLS 传输加密,AES-256 存储加密
访问控制:RBAC + OAuth
审计日志:所有查询/变更记录
DDoS 防护:WAF + 速率限制
Explain how the request flows from end to end in your high level design. Also you could draw a sequence diagram using the diagramming tool to enhance your explanation...
Dig deeper into 2-3 components and explain in detail how they work. For example, how well does each component scale? Any relevant algorithm or data structure you like to use for a component? Also you could draw a diagram using the diagramming tool to enhance your design...
| Kafka vs Pulsar | Kafka 成熟、生态好 | Pulsar 原生多租户、支持存储分层 |
| Elasticsearch vs ClickHouse | ES 强搜索能力 | ClickHouse 查询吞吐高 |
| SQL vs NoSQL | SQL 易用、分析强 | NoSQL 低延迟、可扩展 |
| S3 vs HDFS | S3 低成本 | HDFS 低延迟 |
日志丢失:
查询延迟高:
存储压力:
系统崩溃:
引入 AI/ML 进行智能日志分析
支持更多数据格式(JSON, Protobuf)
分布式查询优化 采用 Presto/Flink