Production Errors (Karat)

Difficulty: EASYCategory: HLDFrequency: 1Asked On 2025-05-01

Problem Statement

You’re working on a large-scale application deployed across 500 production servers. Due to a bug, a large number of requests failed. Your team wants to identify which requests failed so they can be retried or investigated.

You have:

•A database table that stores the IDs of all intended requests (let’s call this the “expected set”).
•Log files from all 500 servers that contain the IDs of successful requests (the “success set”).

Your task is to find the missing request IDs, i.e., those present in the database but not in any log file.

This needs to scale well given the volume of data involved.

Solution

Extract the success set:

•Parse all 500 server log files and extract the request IDs into a set (or bloom filter if memory-bound).
•Use distributed processing tools (like MapReduce, Apache Spark, or AWS Lambda + S3) to process logs in parallel.


Compare with the database:

•Stream or batch-read all expected request IDs from the database.
•For each ID, check if it exists in the success set.
•If not found, mark it as a failed request.


Optimizations:

•If success set is too large, store it in a distributed key-value store like Redis or RocksDB.
•If memory is tight, use a Bloom Filter to reduce space at the cost of false positives (but no false negatives).


Output:

•Save all missing IDs to a persistent store (like a database or S3) for further action.


Comments