How I Solved a 7-Day Calculation Problem in a weekend Jithin Sankar Follow 3 min read · 3 days ago 3 days ago -- Listen Share
In a previous project, my team was building a SaaS application. The scenario was this: we had a slider for setting a price, from $0.00 to $10.00. When you moved the slider, the app would show you the projected sales for that price. The slider input was combined with two other attributes, Region and SKU name.
The problem was performance. Each time the slider moved, it would take a full 15 seconds to get a response from the ML model. We knew better hardware could fix it, but we had serious resource constraints due to budget issues.
The obvious solution was to pre-compute and cache(I built a pypi package for it) all the possible values. Let’s look at the numbers.
We had 10 SKUs, 4 regions, and the slider had two-decimal precision ($0.00, $0.01, …, $9.99, $10.00), which is 1,001 steps.
The total number of combinations would be:
10 SKUs x 4 regions x 1,001 price points = 40,040 requests.
If each request takes 15 seconds, the total time would be:
40,040 x 15 seconds = 600,600 seconds. That’s about 6.9 days.
Our demo was in 4 days. 6.9 days was not feasible.
... continue reading