Dev.to WebDev 🛠 Dev 👁 0 📖 6 min read

How Do Engineers Find Out Why an Application Is Slow?

Performance is not about guessing. It is about measuring, finding bottlenecks, and proving that an improvement actually works. Imagine opening a web application. The homepage takes several seconds to load. You click a

How Do Engineers Find Out Why an Application Is Slow?

Performance is not about guessing. It is about measuring, finding bottlenecks, and proving that an improvement actually works.

Imagine opening a web application.

The homepage takes several seconds to load. You click a button, but nothing happens immediately. Sometimes, loading a simple list takes much longer than expected.

The first solutions that come to mind are usually familiar:

  • Get a more powerful server.
  • Add caching.
  • Optimize the code.

But an experienced engineer does not necessarily start with any of these.

Instead, they ask:

Where exactly is the system slow, and what evidence do we have?

Performance engineering is not simply noticing that an application feels slow. It means measuring the problem, identifying its source, applying the right solution, and verifying the result.

Let's break this down.

1. First, Make "Slow" Measurable

When a user says an application is slow, that feedback matters.

But technically, it is not enough.

Slowness can appear in different ways:

  • A page takes too long to load.
  • An API endpoint responds slowly.
  • A database query takes too much time.
  • The interface does not respond quickly to user interactions.
  • The application loses performance under heavy traffic.

Each problem requires a different investigation.

For example, imagine that a product listing page loads slowly.

The problem could be:

  • Large images.
  • Unnecessary frontend operations.
  • A slow API response.
  • An inefficient database query.

The first step is to identify where time is actually being spent.

2. Four Metrics Engineers Should Understand

One useful model is Google's Four Golden Signals, described in its Site Reliability Engineering practices.

It focuses on four important aspects of system health.

1. Latency

How long does a request take to complete?

For example, an endpoint such as:

GET /api/products

might respond in 150 milliseconds for one request and 2 seconds for another.

Looking only at average response time can hide serious problems.

This is why percentiles matter:

  • P50: 50% of requests complete within this time.
  • P95: 95% of requests complete within this time.
  • P99: 99% of requests complete within this time.

Imagine that P50 is 120 ms, but P95 is 1.8 seconds.

Most users receive a fast response, but a significant portion may still experience noticeable delays.

P95 and P99 help reveal problems that averages can hide.

2. Traffic

How much load is the system receiving?

For a web application, requests per second are an important measurement.

An application might normally receive 20 requests per second but suddenly receive 500 during a campaign.

We need to understand how the system behaves as traffic increases.

3. Errors

How many requests are failing?

HTTP status codes such as 500, 502, and 503 can indicate server-side problems.

However, status codes alone do not tell the whole story.

An API might return 200 OK while still providing incorrect or incomplete business data.

Error rates should be considered alongside application behavior.

4. Saturation

How much of the system's available resources are being used?

Important measurements include:

  • CPU usage.
  • Memory usage.
  • Disk utilization.
  • Database connection pools.
  • Thread pools.

For example, when a database connection pool runs out of available connections, new requests may have to wait.

Performance can deteriorate even before CPU usage reaches 100%.

Together, these four signals help us understand not only whether a system is slow, but also why.

3. How Do We Find the Bottleneck?

A good starting point is to divide the application into layers.

Consider this simplified request flow:

User → Frontend → API → Backend → Database

A delay at any stage can affect the entire user experience.

Frontend: Chrome DevTools

The Network tab in Chrome DevTools is a practical starting point.

It helps us inspect:

  • When a request starts.
  • How long it takes.
  • When the first response arrives.
  • How long the response data takes to download.

Imagine an API request that takes 2 seconds.

If 1.7 seconds are spent waiting for the server's first response, the problem probably requires investigation on the backend side.

Backend: Endpoint Response Times

On the backend, we need to measure how long individual endpoints take to respond.

In Java and Spring Boot applications, Spring Boot Actuator and Micrometer can help.

Micrometer collects application metrics. These metrics can be exported to systems such as Prometheus and visualized with Grafana.

For example, we can investigate:

  • Which endpoint is the slowest?
  • How does response time change as traffic increases?
  • Is the error rate increasing?
  • How much memory is the JVM using?
  • Is garbage collection affecting application performance?

These measurements allow us to make decisions based on evidence rather than assumptions.

Database: Are Queries Efficient?

Sometimes backend code looks perfectly clean while the database is causing serious performance problems.

Consider a product listing that loads 100 products.

If the application executes an additional database query for each product, we may end up with 101 queries.

This is an example of the N+1 Query Problem, which can occur in Hibernate-based applications.

We should inspect:

  • SQL queries.
  • Database indexes.
  • Query execution plans.

Tools such as EXPLAIN help us understand how the database executes a query.

The goal is not to add indexes randomly. It is to identify the queries that are actually expensive.

4. Is Being Fast in Development Enough?

No.

An application running quickly on a developer's computer does not guarantee the same performance under real user traffic.

Production environments have:

  • Multiple concurrent users.
  • Different network conditions.
  • Larger datasets.
  • Changing traffic patterns.

This is where load testing becomes useful.

For example, we can test an e-commerce application with:

  • 50 concurrent users.
  • 100 concurrent users.
  • 500 concurrent users.

We should not only check whether the application stays online.

We should also measure response times, error rates, and resource consumption.

Common tools include:

  • k6
  • Apache JMeter
  • Gatling

There are also different types of performance tests:

Load Testing: Measures behavior under expected workloads.

Stress Testing: Pushes the system beyond its expected capacity to identify its limits.

Spike Testing: Examines how the system reacts to sudden increases in traffic.

These tests help us understand how an application behaves under different conditions.

5. User Experience Is Also Performance

Backend response time is not the whole story.

An API might respond quickly, but if the user sees a blank screen while the page loads, the overall experience is still poor.

Google's Core Web Vitals provide useful metrics for evaluating web performance from the user's perspective.

Three important metrics are:

  • LCP (Largest Contentful Paint): Measures how long it takes for the main page content to become visible. A good target is 2.5 seconds or less.
  • INP (Interaction to Next Paint): Measures how quickly the interface responds to user interactions. A good target is 200 ms or less.
  • CLS (Cumulative Layout Shift): Measures unexpected layout movement while the page loads. A good target is 0.1 or less.

These thresholds are evaluated at the 75th percentile of real-user data.

This is why testing only on our own computers is not enough. We also need to understand the experience of real users.

6. Where Should an Engineer Start Optimizing?

There is one important engineering principle:

Don't optimize before measuring.

Adding Redis because an endpoint feels slow, rewriting queries, or switching to microservices may introduce unnecessary complexity.

A better approach is:

  1. Measure the current P95 response time of the endpoint.
  2. Inspect database query execution times.
  3. Identify unnecessary queries or missing indexes.
  4. Apply a targeted improvement.
  5. Run the same test again.
  6. Compare the results.

If response time decreases without increasing the error rate, we have measurable evidence that the change helped.

Tools such as OpenTelemetry also become useful here.

Distributed tracing allows us to follow a request as it moves through different parts of an application.

This makes it easier to identify where delays occur, especially in systems with multiple services.

Conclusion: Performance Is a Measurement Problem

What separates an experienced engineer is not simply knowing more technologies.

It is the ability to approach problems systematically.

When an application becomes slow, a good engineer does not immediately increase server capacity or introduce another technology.

They investigate the data, identify the bottleneck, form a hypothesis, measure the result, and verify the improvement.

Good engineering is not only about building a system that works.

It is also about understanding how that system behaves under real conditions and improving it based on evidence.

A fast system is not necessarily the one with the most technologies. It is the one whose bottlenecks are understood and addressed correctly.

Further reading: Google SRE – Monitoring Distributed Systems

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.