About this question
Medium · networking · Quant Developer interview question · dns, caching, ttl, networking, unordered-map, session-management
In high-frequency trading, DNS resolvers cache IP addresses with a Time-To-Live (TTL) to minimize latency when connecting to exchange endpoints. Tuning TTL values is a critical trade-off: short TTLs add latency from frequent lookups, while long TTLs risk connection failures from stale IPs. Simulating cache hit/miss rates allows engineers to optimize TTLs against expected query patterns and predict system behavior during failovers. Task Implement the function simulate_dns_cache(const std::vector