Estimate the scale of the system you are going to design...
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...
What are some future improvements you would make? How would you mitigate the failure scenario(s) you described above?