← Back
2025Distributed Systems

High-ScaleInteroperableDiscoveryEngine

ONDC / UHI — India's Digital Public Infrastructure

Distributed SystemsGolangAI OrchestrationObservability

0ms

P99 Latency

0+

Providers

0

QPS Internal

0.9%

Cache Hit Rate

Overview

IengineeredadiscoveryengineforIndia'sDigitalPublicInfrastructuretosolvethe"TailLatency"probleminherentindecentralizednetworks.

Unlike Amazon, which hits a single internal database, ONDC requires fanning out queries to 100+ external providers simultaneously. My implementation ensures the user experience never suffers from a single slow provider — using speculative Hedged Requests and Semantic Caching to stabilise P99 at 475ms while handling 160+ QPS.

Optimization Journey

FourStepsto475ms

Identifying the Bottleneck01BaselineClick to expand

Identifying the Bottleneck

P99 = 747ms. Provider mfine clocking 625ms was dragging the entire network's tail latency.

Semantic Caching Layer02AI OptimizationClick to expand

Semantic Caching Layer

99.9% cache hit rate in Redis. Deduplicated LLM calls, pushing throughput to 247 req/s.

Circuit Breaker Proof03ResilienceClick to expand

Circuit Breaker Proof

Simulated 30+ QPS until the breaker tripped at state=1, proving self-healing under stress.

Breaking the 500ms Wall04BreakthroughClick to expand

Breaking the 500ms Wall

Hedged Requests fire speculative backup calls to beat slow nodes. P99 stabilised at 475ms.

Proof of Work

PerformanceMetrics

#MetricResultDecisionΔ
01P99 Latency0msSpeculative Hedged Requests↓ 36%
02AI Inference Cost0%Semantic Redis Caching↓ 60%
03Internal Throughput0 QPSGolang Goroutines↑ 54%
04Uptime0%Heartbeats & Circuit Breaker

Core Stack

GolangRedisgRPCGrafanak6DockerONDC ProtocolLLM Scoring