Log Ingestion Volume
Kafka (Message Queue)
Log Collection Service
Flink (Data Aggregation)
Cassandra (Database)
Elasticsearch
S3 (Archival Storage)
API Gateway & Services
Headroom & Buffering
| Over-provision disk and network for spikes |
GET /logs {
query, // optional full-text search query
logLevel, // optional log level filter
serviceId, // optional service ID to filter logs
start, // required start time
end, // required end time
page, // optional page number (default: 1)
limit // optional page size (default: 100)
}
GET /services/{serviceId}/metrics {
metricType, // required (e.g., error_count, request_rate)
start, // required start time
end, // required end time
interval // required interval size (e.g., 1m, 5m, 1h)
}
Cassandra is perfect data base for string logs, because was designed for horizontal salability and handling a lot of write operations. We can partitionate data by service_id
Data model in Cassandra
{
service_id
log_level
timestamp
log_message
log_id
}
Kafka feeds logs into multiple services:
Logs → Kafka.
Kafka → various consumers:
Search Service ↔ Elasticsearch ↔ Cassandra
Elasticsearch → S3
Clients access logs/search via API Gateway + Log View Service.
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...
Explain any trade offs you have made and why you made certain tech choices...