The transition from v1 to v2 marked an architectural overhaul isolating concurrency benefits from connection reuse. Benchmarked over 20 live interleaved runs querying destination Tokyo: v1 unpooled (individual requests.get calls) had a median execution time of 2103.7ms [min: 1994.2ms, max: 2836.9ms, Q1–Q3: 2039.9–2187.8ms, IQR: 148.0ms] due to repeated TCP/TLS setups and cumulative blocking I/O; v1 pooled (sequential requests.Session with HTTP keep-alive) had a median time of 2075.0ms [min: 1972.3ms, max: 3091.6ms, Q1–Q3: 2045.3–2102.5ms, IQR: 57.3ms]; v2 concurrent (aiohttp.ClientSession and asyncio.gather) drops median total wall-clock time to 882.8ms [min: 857.2ms, max: 931.6ms, Q1–Q3: 873.5–895.8ms, IQR: 22.2ms] — achieving an overall 58.0% reduction vs unpooled and 57.5% (>50%) vs pooled sequential execution by running the 8 independent secondary endpoints in parallel. Residual variance is governed by remote API server response times.
- Parallel Execution: Leveraging
asyncio.gather, multiple independent API calls are fired concurrently, eliminating cumulative round-trip latency. - Efficient Connections: Utilizing
aiohttp.ClientSessionensures TCP connection reuse and keep-alive across requests. - Hybrid Two-Stage Flow: Dependent data (country coordinates and capital city) is resolved first, unlocking the simultaneous parallel fetching of the remaining 8 datasets.