Skip to content

12.1. How would you design a Kafka-based system for real-time inventory management?

Answer: For a Kafka-based system for real-time inventory management, I would start by defining the business event, expected throughput, ordering requirements, retention period, failure tolerance, and latency target. I would create topic(s) around stable event contracts, choose a partition key that preserves the required ordering, and set the partition count based on expected parallelism and growth. Producers would use retries, sensible batching, compression, and idempotence for important events. I would use a replication factor appropriate for the failure model and set a deliberate min.insync.replicas value. Consumers would be organized into separate groups for independent services, with clear offset and retry strategy. For failures, I would use retry topics or dead-letter handling where appropriate rather than blocking an entire partition forever. Finally, I would add metrics for throughput, latency, consumer lag, under-replicated partitions, disk, CPU, network, and error rates, and I would load-test the full path before production.

Interview close: I would validate the design with load tests, failure injection, and production-style observability before calling it ready.