This question evaluates understanding of asynchronous batching, request coalescing, and consistency guarantees in single-threaded event-loop environments, including competencies in concurrency control, error propagation, backpressure, and graceful shutdown.
You are working in a single-threaded environment with concurrent I O (think event loop). Implement a function:
Within any 100 ms window, the implementation must batch multiple incoming key requests and issue exactly one HTTP request per batch:
You are given two helpers:
After the batch response arrives, parse it and invoke each original per-key callback with its value.
Consistency requirement:
Also specify and design for the following:
Include a brief rationale about when you would choose callbacks versus multi-threading for this problem, and the trade-offs in complexity, latency, and throughput.
Login required