Rajnish.
Let's talk ↗
← All Work
backendmicroservicesperformanceecommerce

Optimizing High-Volume E-Commerce APIs

Flipkart Health Plus (via Prismberry) · 2023–2024

Cutting transaction time by 70% was not about writing clever code. It was about eliminating unnecessary work on every request.

Context

Flipkart Health Plus manages high volumes of pharmaceutical and health product orders. At this scale, even slight checkout delays directly increase cart abandonment, making API latency a key business metric.


The Problem

Key checkout endpoints (cart calculation, coupon validation, and refund processing) were taking too long during sales events. The services were fetching oversized database records, running redundant validation queries in loops, and blocking synchronously on third-party steps.

Constraints
  • High-traffic production platform where all API contracts had to stay backwards-compatible.
  • Strict performance SLAs defined by the core platform team.
  • Multiple frontend and mobile clients depending on existing API structures.

My Role

I redesigned and rebuilt the backend microservices for cart, coupon, and refund flows, taking the work from profiling through to production rollout.

The Thinking

Profiling showed that the services were doing the right tasks, but doing them inefficiently. Handlers were querying database models for 30 fields when they only needed two, running lookups inside loops, and mixing read paths with write validation.

The Decision

We focused on the data access layer first: separating read queries from write logic, fetching only necessary fields, and caching frequently requested catalog metadata. We also made refund processing asynchronous so customer responses were not blocked by external banking services.


Implementation
  • 01Profiled the full lifecycle of cart and checkout calls, cataloging every database query and cache hit.
  • 02Implemented selective field queries and batched lookups to eliminate repetitive queries.
  • 03Placed Redis caching at the data access layer with well-defined invalidation policies.
  • 04Restructured coupon validation to reject ineligible promotions early before running expensive cart price breakdowns.
  • 05Converted refund processing to an event-driven queue, unblocking immediate user responses.
  • 06Kept all API response schemas backwards-compatible for mobile and web clients.
Trade-offs
  • Separating read and write models added slight schema complexity that we documented for the team.
  • We chose shorter cache TTLs to ensure pricing and inventory stayed consistent, accepting slightly lower cache hit ratios.
  • Asynchronous refund handling required frontend updates to display pending states clearly.

Outcome

Reduced transaction processing time by 70% across cart, coupon, and refund endpoints. The services ran reliably through high-traffic sales without response degradation.

What I Learned

Effective backend optimization is usually about doing less work per request, not writing complex micro-optimizations. When you clean up the database queries and avoid unnecessary blocking calls, the system gets fast naturally.

← Previous

Upgrading a Live Fintech Engine