Design a Kafka-backed logging system that can handle high-volume, distributed logs from multiple services.
Instruction: Explain the architectural considerations and component choices for building a highly scalable and reliable logging system using Kafka.
Updated
Official answer
Use local log collection agents or deliberately integrated producers to send structured events to Kafka. Keep application request handling isolated from a slow logging destination with bounded buffers and an explicit overload policy. Local disk spooling needs capacity, permissions, recovery and disk-full handling; it is not unlimited durability.
Define a log envelope with service, instance, event timestamp, ingestion timestamp, severity and correlation ID. Remove credentials and unnecessary sensitive content before publishing. A schema registry is an optional contract-management component, not a requirement imposed by Kafka.
Choose topics by ownership, retention and access needs. Partition for useful load distribution while preserving only the ordering the use case requires; putting a very busy service entirely on one key can create a hot partition. Use a KRaft metadata quorum and suitable broker/replica fault-domain placement for Kafka 4.x.
Separate consumer groups can feed a search index, archival storage and alert processing. Sink delivery and duplicate handling depend on the chosen connector/application. Use stable event identity and idempotent indexing where repeated delivery is possible, and define quarantine/retry behavior for bad records.
Size from measured byte rate and retention. For example, 10 MiB/s for one day is about 843.75 GiB of raw single-copy payload; replication factor three gives about 2,531.25 GiB before compression, indexes, segment overhead, headroom and separate sinks. Include catch-up and failure traffic in capacity tests.
Monitor accepted, dropped, quarantined and indexed events, end-to-end age, spool runway, consumer progress and storage. Test broker/destination outages and agent restarts, including what happens when buffers fill. Replication and successful ingestion do not prove a log is searchable or permanently archived.
Related Questions
-
medium
-
hard
-
hard