Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

OLX Tech 10 min read Case study mediumAdept

Scaling recommendations service at OLX

OLX scaled a Python FastAPI recommendations service to tens of thousands of requests per second with p99 latency under 10ms by systematically removing event-loop stalls. Key steps were making I/O non-blocking (offloading the sync ScyllaDB driver to threads, swapping boto3 for aioboto3), which cut latency over 40% and raised throughput over 50%. Batching fan-out ScyllaDB queries halved p99, and replacing Pydantic with slotted dataclasses everywhere except request inputs cut latency over 30%. Raising GC thresholds (gen0 700→7000, gen1/2 10→20) removed bimodal pauses and dropped homepage p99 from 52ms to 12ms.

Assumes: Python asyncioFastAPI basicsPython GIL

Related posts

  • Rapidly scaling online storage to serve over 1 billion ChatGPT users

    OpenAI mediumAdept

    Habitat, OpenAI's online storage platform, grew from a client-side Python library over Azure Cosmos DB into a centralized Python service handling 70M+ requests per second and 500+ PB across about 40 regions. It moved to a service because coordinating client-library rollouts across dozens of services had become slow and error-prone. Running Python at this scale meant fighting tail latency from asyncio event-loop scheduling delay, which the team measured directly and controlled by keeping per-process concurrency low and scaling out worker processes. Specific fixes included shrinking and jittering Statsig feature-flag config refreshes, and switching aiohttp's LIFO connection reuse to FIFO to break a metastable failure that concentrated load on already-slow processes.

  • From Event-Driven Chaos to a Blazingly Fast Serving API

    Zalando Engineering mediumAdept

    Zalando replaced an event-driven pipeline that merged Product, Price and Stock events with a central Product Read API (PRAPI). During Cyber Week that pipeline delayed price and stock updates by up to 30 minutes, because over 90% of each payload was unchanged. PRAPI is a Caffeine async-loading cache over DynamoDB, run on Kubernetes with Netty/Epoll non-blocking I/O, and serves millions of requests per second at sub-10ms P99. Consistent hash load balancing in Skipper partitions the catalogue so small per-pod caches hold hot products. Fixed ring positions and a bounded-load cap of 2× the average keep caches warm during scaling and stop hyped products from overloading a pod. Tail latency came down by caching payloads as byte arrays to avoid GC pauses, using LIFO queuing, and splitting DynamoDB clients into a 10ms primary and a 100ms fallback. Adoption across ~350 teams worked because PRAPI served the legacy formats via the Accept header, and the org was restructured along CQRS lines.

  • The search for speed in Figma

    Figma mediumAdept

    Figma's search slowness traced mostly to its own stack, not OpenSearch: OpenSearch's headline 8 ms metric was per-shard time, and only the "took" field in responses reveals overall query latency, which accounted for under 30% of API time. Fixes included reordering and slimming Ruby permission checks, repairing a database connection setup bug that also sped up the rest of Figma, and trimming index size by 50% and then 90% so the data fit in the OS page cache. Load tests with a custom Go benchmark showed AWS sizing guidance suited log workloads, not latency-sensitive search. Cutting shards from 450 to 180 and moving to nodes with less CPU and more RAM paid off, while concurrent segment search hurt. Overall API latency fell about 60%, peak QPS rose over 50%, and cost dropped more than 50%.

  • Optimization story: Bloom inference

    Hugging Face hardMaster

    Hugging Face's BLOOM (176B parameters, 352GB in bf16) inference server reached 5x lower latency and 50x higher throughput over several weeks, starting from 0.3 req/s and 350ms/token on 16xA100 40GB with pipeline parallelism via Accelerate's device_map="auto". A FLOPs estimate (~17 TFLOP per forward pass, a theoretical floor of about 3ms/token) showed how far off that baseline was. The team weighed tensor parallelism against pipeline parallelism and tried a JAX/Flax port on TPUs, ONNX/TensorRT and DeepSpeed. Lessons include using small test models and fixed greedy-generation prompt suites to catch numerical drift, and staying within PyTorch for flexibility after DeepSpeed proved unstable under webserver load.

  • Break chatbot speed limits with speculative tool calls

    incident.io mediumAdept

    incident.io cut its incident chatbot's response latency by about 50% (saving 2-3s per interaction) by speculatively executing LLM tool calls in both directions. Tools are started in parallel with the main chat prompt when simple keyword matching suggests they will be needed, and the follow-up chat prompt is run optimistically by assuming the tool succeeded, then re-run on error. Side effects are prevented with a Go write barrier: speculative tools do all their LLM 'thinking' but block before writing until the main prompt confirms the call, otherwise the context is cancelled. The tradeoff is occasional wasted LLM spend, which effectively lets the team buy speed with money.

The quest for software engineering knowledge.

Look:
Layout: