Hardware & Performance·7 min read·

When to Throw Hardware at a Problem vs Optimising Software

A decision framework for whether to resize a VPS or fix the code instead, based on the actual shape of the bottleneck rather than guesswork.

NB

Netbay Developer Relations

Netbay Engineering

On this page

Throwing hardware at a problem is not lazy; it is often the cheapest correct answer. Resizing a VPS takes minutes and is instantly reversible, while an optimisation can eat a week and touch fragile code. The mistake is choosing from habit. The right call depends on the shape of the bottleneck: whether it scales with resources or with code, and whether it is one-time or permanent.

The cheap wins come from hardware

Some bottlenecks are structurally immune to software fixes within the same budget. A single-threaded process that is CPU-bound on a one-core plan is fixed by a core, not by more clever loops. A working set that exceeds RAM forces continuous paging no matter how clean the query is. For these, sizing up is the rational first move because it converts time into headroom instantly.

  • Latency to the user on a single request: not usually a hardware problem, unless under-provisioned already.
  • Peak traffic you cannot absorb: hardware gives instant headroom for a spike.
  • Working set bigger than RAM: hardware ends the paging cycle now.

When software is the only fix

Hardware cannot make a badly indexed query fast, cannot remove an N+1 loop, and cannot shrink a payload. These are algorithmic costs that scale with the data, not with the plan. Buying more cores for an O(n squared) sort just makes the busy cores busier. Recognise these by the shape: throughput grows slowly with cores, latency stays flat, and the profile shows time inside a small number of functions.

bash
# confirm a scaling problem: does throughput track vCPUs?
for t in 1 2 4; do
  echo "threads $t"
  seq 1 $t | xargs -P $t -n1     sh -c 'sysbench cpu --threads=1 run > /dev/null 2>&1; echo done' &
  wait
done

If total throughput is flat while cores double, the cost is inside one serial path and code, not cores, is the fix. If throughput doubles with cores, you have genuine parallelism and hardware scales.

Set an effort budget so the discussion ends

Teams argue about hardware versus code because neither side can prove the other wrong. The fix is a decision budget, set before the debate: time-box the investigation to a day, cap the optimisation effort at a week, and auto-escalate to more hardware the moment an incident is live rather than waiting for a clean fix.

bash
# a rough loss model to frame the choice
# lost minutes/day x outage cost = what headroom is worth now
echo "monthly cost of headroom vs weekly engineering cost"

That budget turns an endless debate into a simple rule. If the resize closes the gap in minutes and the rewrite takes three weeks, the resize wins while the rewrite stays on the roadmap. If the bottleneck is structural and recurring, pay the engineering cost once and it never comes back. The mindset that respects both, applied to each incident, is far cheaper than a permanent bias toward either side.

The hybrid: hardware buys you time to optimise

The best engineering moves are usually staged. Resize to remove the immediate pain, then optimise the code at leisure, then right-size back down and save the monthly cost. The resize is not shameful; it is a bridge across an incident. The optimisation is the permanent fix that lets you drop back.

hardware or code? add hardware single-threaded, peak spike, working set exceeds RAM optimise code bad query, N+1 loop, serial cost scales with data resize now, optimise later, right-size down hardware is a bridge; code is the permanent fix does throughput track vCPUs? if not, fix code

A rubric for the decision

Ask three questions in order. Is the problem a spike, a working set, or a serial cost? A spike buys headroom. A working set beyond RAM buys memory. A serial cost inside a hot loop buys nothing until you rewrite it. Second: how reversible is the hardware change? On a VPS it is trivially reversible, which lowers the cost of just trying it. Third: what is the time value? When an incident is live, the resize is minutes; the rewrite is days.

Takeaway

Buy hardware for spikes, serial hot paths, and working-set overflow; optimise code for costs that scale with the data. Use a resize to buy time, then right-size back down. On Netbay you can resize an instance on demand from the dashboard or the API at netbayhosts.in and reverse it just as easily.

Keep reading

Follow along on a real VPS

Deploy Linux in under 60 seconds

These guides are written against Ubuntu, Debian, and RHEL-family images — the same ones on NetBay.

Deploy an instance