Article
Finding out why your web app is slow
A slow web app is usually slow in a few specific places: too many or slow database queries, inefficient processing, large data, or no caching, so the same work is repeated on every request. Measure first to find those places, then fix them, and measure again.
Measure first
Guessing picks the wrong thing to fix. Before changing anything, measure which pages are slow, and what behind them is taking the time. The numbers point at the few places that matter.
Common causes
- Too many database queries. A page that loads a list, then asks the database for each item separately, makes hundreds of trips where one would do.
- Expensive queries. A single query that combines or sorts large tables can take seconds on its own.
- Inefficient queries. A query reads every record to find a few. It’s usually a quick fix.
- Inefficient processing. The app’s own code does its work the slow way, repeating steps or doing far more than the answer needs.
- Large data. As the data grows, anything that reads more than it needs gets slower.
- No caching. Totals, reports and lookups that rarely change are worked out again on every request. Caching works them out once and keeps the answer.
- Slow jobs done while the person waits. Sending emails or building reports can run in the background, so the page answers straight away.
- Heavy pages. Large images and scripts make the page itself slow to load in the browser. Compressing (zipping) what the server sends, shrinking the images, and loading only what each page needs make it lighter.
Often there isn’t one cause. Several of these add up, each costing a little, until together they make the app slow. Measuring shows how much each one costs, so the biggest get fixed first.
Fix, then measure again
Each fix is measured against the numbers from before. If it didn’t help, it comes out. The aim is a faster app, not more code.
Why it slows down over time
Apps often feel fast at launch and slow a year later. The code didn’t change. The data grew, and something that was fine with a thousand records isn’t with a million.
FAQ
Do we just need a bigger server? Sometimes, but measure first. Slow code stays slow on a bigger server, and you pay more for it every month.
Will fixing it need a rewrite? Usually not. It needs a deep analysis instead: measuring where the time goes on each slow page, finding every cause that adds to it, and fixing them one by one.
Can you fix it, or only find the cause? Both. I measure, show you what’s slow and why, then fix the places that matter most and measure again.
Is your app getting slower as it grows?
Tell me which pages are slow and roughly how much data the app holds.