# Why is my API slow?

> When an API gets slower than its normal, find the step a slow request waits on (often one database query), change it, and let Relia confirm the speed is back.

Section: Find and fix real problems · Page: https://tryrelia.com/docs/slow-api · Last checked against the product: 2026-11-01
Video walkthrough: https://youtu.be/W8ONSladzPk

A page that used to load fast now takes seconds. Usually one API behind it got slow, and usually that API is waiting on one thing: a database query, another service or an outside API. This page shows how to find that one thing.

The example is Relia's demo shop: at 13:00 the order page takes 2 seconds to load because `GET /api/orders/:id` got slow.

## What you'll see

- **Home** shows the slow API under **For you** or **Worth watching**, for example *GET /api/orders/:id got slow*. **APIs** turns **Watch**: slow, not broken.
- A slowdown alone is usually **Watch**. It becomes **Needs you** when it also comes with failures or with users struggling, or when the API is one you told Relia must never break.

Relia compares the time 95% of requests finish within (the p95) with that route's normal. It flags a route only when the p95 is at least 500 ms, at least twice its normal and at least 300 ms slower. The normal takes the time of day and day of the week into account, so a busy Monday morning is compared with other Monday mornings.

## Find the cause

1. **Open the incident.** It gives the numbers, for example *p95 2,300 ms, normally 130 ms*. **Normal at this hour** shows what the route usually does on this weekday and hour.
2. **Go to APIs, then Performance.** Under **Slowest Endpoints by Average Latency**, find the API. Click it to narrow the list of requests below to that API.
3. **Open one of its slowest requests.** The **Execution Trace Waterfall** shows every step of that request as a bar: database queries, calls to other services and outside APIs. The longest bar is what the request waits on.
4. **Hover the long step to read it.** Database queries are shown with their values removed (`?` instead of ids and text), so you can see the query's shape safely.

> **Tip:** the incident's **Do this next** gives the same advice: *Open a slow request to the API and see what it waits on (database or another service).*

## Fix it

What to change depends on what the request waits on:

| The long step is | Common fixes |
|---|---|
| One slow database query | Add an index on the columns it filters or joins on; drop joins the page doesn't need; select fewer columns. |
| The same query many times | Load the rows in one query. See [Slow database queries and N+1](https://tryrelia.com/docs/slow-database-queries.md). |
| A call to an outside API | Add a timeout and a fallback; check the provider's status page. See [Payment provider failing](https://tryrelia.com/docs/payment-provider-failing.md). |
| Your own code (no long child step) | Look for heavy loops or large payloads in that handler. |

On Growth and Pro, **Show how to fix** on the incident turns the evidence into concrete steps, and **Copy for your AI assistant** copies a brief for Claude Code, Cursor or another assistant.

## Check the fix worked

Deploy your change. Relia picks up a new version of the affected service by itself; otherwise click **I fixed it** on the incident. Relia then watches real traffic. Once the problem stays away for at least 15 minutes with at least 20 requests, the incident says **Fix confirmed** and you get *Your fix worked*. If it gets slow again, you get *Still happening after your fix*.

> **Tip:** watch [From alert to verified fix](https://youtu.be/gtORFurIkow) (2 min).

## Next

- [Slow database queries and N+1](https://tryrelia.com/docs/slow-database-queries.md)
- [APIs: requests, errors, logs and latency](https://tryrelia.com/docs/apis.md)
- [Did my deploy break anything?](https://tryrelia.com/docs/did-my-deploy-break.md)

---
All Relia docs for AI assistants: https://tryrelia.com/llms.txt (index) · https://tryrelia.com/llms-full.txt (everything in one file)
