PerformanceSenior Backend Engineerteam: 5 engineersclient: Promotional products distribution

OEM product catalog platform

A platform that collects supplier catalogs for a promotional products distributor. I built its API foundation, then took over the ingestion pipeline and the upsert into the catalog.

Jul 2024Nov 2024

~70%

faster catalog retrieval via SQL optimization

How it was measured

Catalog query response time before and after SQL optimization (indexes and query rewrites), on the production catalog of 500k+ products.

2+ days → ~22 h

bulk-update pipeline

How it was measured

Wall-clock time of one full bulk update of the catalog, before and after the pipeline rework.

400+

suppliers in the catalog

How it was measured

Supplier records in the platform's supplier list: 418, of which 413 publish a product data service.

On this page
  1. 01Context
  2. 02Problem & constraints
  3. 03Architecture
  4. 04Key decisions
  5. 05Results
  6. 06What I'd do differently
  7. 07Stack
01

Context

A distributor of promotional products needed one catalog of everything its suppliers sell: products and their parts, colors, decoration options, prices, stock and media. Suppliers publish this data through industry-standard SOAP services. The operations are the same everywhere, but versions differ and many suppliers implement only some of the services.

The platform pulls those catalogs into one SQL Server database, and back-office staff manage suppliers, feeds and sync jobs in an admin app. I was one of five backend engineers, working through Valletta Software.

02

Problem & constraints

  • 418 suppliers, 6 service versions and up to 13 supplier calls per product.
  • One product touches 31 tables: parts, colors, sizes, decoration, prices, stock and media.
  • Every sync brings the same products back. Rows must update in place, rows the supplier removed must go, and products no longer for sale must be switched off.
  • Fetching and writing run in parallel, so two writers must never update the same product at once.
  • A full sync runs for hours, and some supplier services time out or return nothing.
03

Architecture

Scroll the diagram sideways

fig. 01: Ingestion pipeline. A job asks each supplier what it sells, raw responses land in S3, and one procedure call per product brings the catalog in line.From Job runner to Suppliers: the list of products for sale. From Admin app to Job runner: start a sync. From Job runner to Fetch stage: one SQS message per product. From Fetch stage to Suppliers: product, stock, media and price calls. From Fetch stage to Raw store: upload when the hash changed. From Raw store to Upsert stage, after a second SQS message. From Upsert stage to Catalog: one procedure call per product. From Catalog to Admin app, through the admin APIAdmin appstart · monitorJob runnerSQL claim · 5 slotsFetch stage≤13 callsSuppliersSOAP · 418CatalogSQL Server31 tablesUpsert stage1 procedure · 34 MERGERaw storeS3 · JSONproducts for saleSQSSQS
fig. 01Ingestion pipeline. A job asks each supplier what it sells, raw responses land in S3, and one procedure call per product brings the catalog in line.
04

Key decisions

DR-01

Two stages, with raw responses kept in S3

Context
Supplier SOAP calls are slow, versioned and unreliable, while database writes are heavy.
Options considered
A: one consumer fetches a product and writes it in one step. B: the first stage fetches and saves raw JSON to S3, and a second message processes it from S3.
Trade-offs
B adds a hop, storage and file bookkeeping. In return supplier calls are decoupled from database load, each stage has its own concurrency limit, unchanged files are skipped by hash, and raw data can be processed again without calling suppliers.
Outcome
Chose B. Fetching runs with 12 concurrent consumers and processing with 10.
DR-02

Idempotent upsert instead of one big transaction

Context
Each product means 30+ statements, with 10 writers in parallel and constant re-runs.
Options considered
A: wrap everything in one transaction and flag removed rows for later cleanup. B: make every statement idempotent: deterministic IDs, row hashes, unique indexes and a separate delete phase after the MERGE statements.
Trade-offs
With B a failure halfway leaves a product partly updated until the next sync. In return re-runs converge, and the cleanup flags are gone.
Outcome
Chose B. The procedure went from version 14 to 27, with 68 new indexes and 34 MERGE statements.
DR-03

A job runner in SQL Server

Context
Syncs start from the admin app or an external call. They must not run twice for one supplier, must survive crashes and must be cancellable.
Options considered
A: a scheduler library, or cron with a queue. B: a jobs table and a claim procedure in the same database.
Trade-offs
B means writing our own heartbeat, frozen-job detection and cancellation, and polling every 30 s. In return there is no new infrastructure, and job status is visible in the admin app next to the catalog.
Outcome
Chose B. Jobs are claimed atomically, one per supplier at a time and up to 5 in parallel, and a job without a heartbeat for 2 minutes is marked frozen.
05

Results

  • API foundation: a layered .NET 8 solution, IdentityServer for the admin app, migrations and versioned stored procedures applied on startup, CodeDeploy hooks for IIS.
  • A two-stage SQS pipeline with separate concurrency limits, retries and a local in-memory mode.
  • A catalog schema mapped to the supplier standard: products and parts, inventory, media, pricing and configuration.
  • The upsert procedure taken to version 27: row hashes, 68 indexes and a separate delete phase.
  • Products a supplier stops selling are switched off in one set-based pass.
  • A job runner with admin endpoints to list, start and cancel jobs and see failed ones.
06

What I'd do differently

  • I would let failures reach the queue. Both consumers caught every exception and only logged it, so a failed product waited for the next full sync.
  • I would enforce per-supplier rate limits and timeouts. The settings existed for every feed but were never applied.
  • I would test and measure before tuning. A 2,560-line generated procedure had no automated tests.
07

Stack

  • C#
  • .NET 8
  • ASP.NET Core
  • SQL Server
  • EF Core
  • Dapper
  • MassTransit
  • Amazon SQS
  • S3
  • Redis
  • IdentityServer
  • SOAP (WCF)
  • AWS CodeDeploy