// Case study

Rescuing a Marketplace at Scale

Nine years keeping a top-3 US affiliate marketplace fast, reliable, and able to grow — while millions in commissions flowed through it live.

// 01

The client

A top-3 US affiliate marketplace for digital products — the kind of platform where vendors list products, affiliates promote them for commission, and the platform sits in the middle processing every transaction and routing the money. When our engagement began around 2013, the system worked, but it was straining: built in vanilla PHP, slow in the places that mattered, and fragile in the places that mattered most. We worked together for roughly nine years keeping it fast and reliable as it scaled.

// 02

The challenge

This is a business where the software failing quietly is worse than the software failing loudly. Money moves through it constantly. Two problems stood out:

1. Commission calculation was a multi-day liability. The job that calculated and distributed affiliate commissions took two to three days to run — and sometimes failed partway through, forcing a full re-run. There were no queues; while it ground away, it dragged down the whole system. For a platform distributing commissions in the range of ~$3 million, a calculation job that's both slow and failure-prone isn't a performance issue — it's a business risk.

2. The site itself was slow, and the codebase fought back. The user-facing platform — including the affiliate dashboard real users logged into daily — was sluggish. Underneath, the code made it worse: the same logic (a query to fetch affiliates, for instance) was copy-pasted across 10–15 different files. Changing one business rule meant editing fifteen places without missing one — a recipe for bugs and slow development.

// 03

What we did

Everything below happened on a live system, with real money and new data flowing in constantly. There was no staging-only luxury — changes had to be made carefully, in production, without disrupting a platform people depended on for income.

Rebuilt the commission engine: 2–3 days → under an hour. The original job was a textbook case of how not to handle data at scale — nested queries, joins, and in some places nested queries running inside loops. We attacked it on three fronts: optimizing the database queries, replacing nested-query-and-join patterns with in-memory processing using loops and arrays, and re-architecting how the whole calculation was batched. Then we introduced queues so the heavy work no longer blocked the rest of the system. The same calculation that took two to three days — and sometimes failed — finished in under an hour, reliably.

Modernized the stack. We migrated the platform from PHP 5.4 to PHP 7, with all the performance and maintainability gains that brought.

Cut the code rot. We refactored the duplicated logic — consolidating those 10–15 scattered copies into single, maintainable sources of truth. Fewer places to break, fewer chances for error, faster development going forward.

Built proper observability. The system had no real logging. We added structured logs that made debugging, bottleneck identification, and failure detection dramatically faster — turning "something's wrong somewhere" into "here's exactly what failed and why."

Gave affiliates a modern dashboard. Alongside the migration, we built a new dashboard for affiliates — with graphs and richer analytics, so the people earning on the platform could actually see and understand their performance.

// 04

My role

As with most of my engagements, I started hands-on in the code — building the optimizations myself — and later moved into managing the work with a small team of two. Deep enough to do the hard re-architecture personally; senior enough to own the relationship as it ran for nearly a decade.

// 05

The outcome

By the client's own measurement — they tracked the business data directly — the work delivered:

  • Overall site load time down ~75%, on the user-facing platform and affiliate dashboard.

  • A ~40% improvement in profitability, as the client measured it.

  • Commission processing from 2–3 days (sometimes failing) to under an hour, reliably.

And the platform could now grow without buckling. In the years that followed, the commissions flowing through it rose from ~$3 million to ~$4–4.5 million — demand the marketing and sales teams drove, on infrastructure that could finally handle it. Better performance also meant happier affiliates, more referrals, and lower server costs for the same load.

Let's talk

If you're a founder navigating a hard technical decision — even if we never end up working together — I'm happy to spend 30 minutes on it.