RanSoftware engineer
All work

E-commerce performance · 2022–24 · In-house work

Making search sync, product indexing and the product API fast again on a growing e-commerce site

As the catalog grew on a mother-and-baby e-commerce site, product indexing, search sync and the product API all slowed down. I found what made each one slow and rebuilt that part.

Problem
A product change took 30 minutes to appear on the site, the search sync ran for 20 minutes, and the product API slowed as the catalog grew.
Approach
Full rebuilds became updates that run only when data changes, the product API was split by what each part of the page needs, and wasted database work was removed.
Result
Search sync: 20 minutes → 5 seconds. Product indexing: 30 minutes → 3 minutes. Product API: Apdex 0.84 → 0.96, response time down 53%.
On this page
Before and after: search sync 20 min → 5 s, product indexing 30 min → 3 min, product API 320 ms → 150 ms

I worked in-house on the catalog side of a mother-and-baby e-commerce site: product pages, search, and the APIs behind the website and the apps. Three things had slowed down as the number of products grew.

Search sync: the database does the copying, 20 minutes → 5 seconds

A scheduled job prepared the product data that the search service reads. It built an object for every product, batch by batch, and updated the data from those. I replaced that with a single database statement that copies the rows straight from the source tables. The job’s average run time went from 20 minutes to 5 seconds.

Product indexing: only what changed, 30 minutes → 3 minutes

Another scheduled job rebuilt the product index tables from the first row to the last, so a price change or a new product took 30 minutes to appear on the site. I changed it to react to changes: when a product changes, a job goes onto a queue and only that product is synced. Changes now appear in 3 minutes, and unchanged products are no longer synced again.

Product API: split by what each part of the page needs

The product page’s API returned everything on the page in one response: product details, related products and reviews. I split it by block. The first screen’s core data is rendered on the server; related products and reviews load after it. Filtering moved from a long list of parameters to one structured query, and results are cached.

Apdex, a score for how many requests are answered fast enough, rose from 0.84 to 0.96. Response time fell 53%, from 320 ms to 150 ms.

Category landing pages: 27% fewer database requests

The API behind category landing pages asked the database the same kind of question once per product, and built objects it never used. With both fixed, database requests fell 27% and page response time fell 50%.

More pages that search engines can index

Search result pages that search engines can index went from about 1,000 to more than 25,000, and structured data coverage from 120k to more than 380k. Structured data for products, lists, Q&A and articles is now generated in one place, following the properties Google requires and recommends.

One size, three spellings, unified

The same size had been entered as M, Medium and M-size, all as plain text. Once those were unified, the size filter returned the right products.