All work

Freelance via Upwork, 2022, for Viasox

Viasox’s order tool, from 37 seconds to 4

Viasox’s team worked through orders one by one in an internal Laravel tool, pressing the arrow keys to move to the next order. The page took 37 seconds to open and up to 18 seconds per order. I made it fast enough to keep up with them.

First load of the order page
37s to 4s
To open each next order
15–18s to 1.8s

How it got fast

The problem

Every order, all at once

The order view page asked one controller for every order before it showed anything. The first load took 37 seconds, every time someone opened the tool.

Fix one

The page first, the order second

I moved the loading to jQuery and AJAX: the page renders straight away and fetches only the order on screen. The first load dropped to 4 seconds.

The next problem

Each next order still took 15 to 18 seconds

Pressing the arrow to move to the next order was slow on its own. Finding an order meant reading through the whole orders table, and every product image and SKU was fetched again.

Fix two

Indexes and a cache

I indexed local_order_id and shopify_order_id, so the database goes straight to the order, and cached product images and SKUs. Each next order now opens in 1.8 seconds on average.

Fix three

Four years the team didn’t need

The team only worked with the last six months of orders, so I partitioned the 2018 to 2021 orders out of the working set, and wrote an automated Laravel script so old orders keep moving out on their own.

Before and after

First load of the order page

37s

4s

To open each next order

15–18s

1.8s

Before After

The work

Client
Viasox, a $12.4M‑a‑year sock brand
Engagement
Freelance via Upwork, 2022
My part
Diagnosis, loading, indexing, caching and the archive script
  • Laravel
  • MySQL
  • jQuery
  • JavaScript
  • Redis