---
title: "How to Test throughput and latency to API?"  
description: "How to Test throughput and latency to API?"  
author: "Anubhav Sharma"  
published: 2026-01-15  
updated: 2026-01-18  
canonical: https://answers.mindstick.com/qa/116286/how-to-test-throughput-and-latency-to-api  
category: "application"  
tags: ["api"]  
reading_time: 4 minutes  

---

# How to Test throughput and latency to API?

How to [Test](https://answers.mindstick.com/qa/100353/how-to-pass-gre-test) [throughput](https://www.mindstick.com/interview/34442/what-is-high-throughput) and [latency](https://www.mindstick.com/interview/34441/what-is-latency-in-software) to [API](https://www.mindstick.com/articles/12641/instagram-api-upgraded-to-facebook-graph)?

## Answers

### Answer by Ravi Vishwakarma

Testing **API throughput** and **latency** is about measuring **how fast** and **how much** your API can handle under different conditions. Below is a **practical, production-style guide** with tools, metrics, and examples—especially relevant if you’re working with .NET / web APIs.

## 1. Key Definitions (Clear Difference)

### Latency

Time taken for **one request → one response**

Measured in:

- ms (milliseconds)
- P50, P90, P95, P99 (percentiles)

Example:

```plaintext
P50 = 120ms
P95 = 450ms
```

### Throughput

Number of requests your API can handle **per second**

Measured in:

- RPS (Requests Per Second)
- TPS (Transactions Per Second)

Example:

```plaintext
Throughput = 2,500 RPS
```

## 2. What You Should Measure

| Metric | Why it matters |
| --- | --- |
| Avg latency | General performance |
| P95 / P99 latency | Real user experience |
| Throughput (RPS) | Capacity |
| Error rate | Stability |
| CPU / Memory | Bottlenecks |
| DB time | Backend limits |

## 3. Simple Local Testing (Quick Checks)

### Using `curl` (Latency only)

```plaintext
curl -w "\nTime_Total: %{time_total}s\n" -o /dev/null -s https://api.example.com/users
```

Good for:

- One request
- Network + server latency

## 4. Apache Benchmark (ab)

### Install

```plaintext
sudo apt install apache2-utils
```

### Test example

```plaintext
ab -n 10000 -c 100 https://api.example.com/users
```

Where:

- `-n` = total requests
- `-c` = concurrent users

### Output to focus on

```plaintext
Requests per second: 2300.15 [#/sec]
Time per request: 43.2 ms
```

## 5. k6 (Highly Recommended – Production Grade)

Best for **throughput + latency + load patterns**

### Install

```plaintext
choco install k6       # Windows
brew install k6        # macOS
```

### k6 Latency Test

```plaintext
import http from 'k6/http';
import { sleep } from 'k6';

export let options = {
  vus: 50,
  duration: '30s',
};

export default function () {
  http.get('https://api.example.com/users');
  sleep(1);
}
```

Run:

```plaintext
k6 run test.js
```

### Metrics you get:

- avg latency
- p90 / p95 / p99
- RPS
- failure %

### k6 Throughput Stress Test

```plaintext
export let options = {
  stages: [
    { duration: '30s', target: 100 },
    { duration: '1m', target: 500 },
    { duration: '30s', target: 0 },
  ],
};
```

Shows:

- breaking point
- max sustainable throughput

## 6. JMeter (GUI + Heavy Testing)

Best when:

- QA teams
- Complex workflows
- Auth flows

### Steps:

- Thread Group → Users
- HTTP Request → API
- Summary Report
- Aggregate Report

Key Metrics:

- Throughput
- 90% Line
- Error %

## 7. Postman (Beginner-Friendly)

### Collection Runner

- Set iterations
- Set concurrency
- View avg response time

## Not accurate for high throughput testing

## 8. Production-Like Testing (Best Practice)

### Run tests from:

- Same region as users
- Separate machine (not API server)

### Monitor during test:

- API CPU
- Memory
- GC pauses (.NET)
- SQL query time
- Thread pool starvation

## 9. Example Targets (Reference Benchmarks)

| API Type | Good Latency (P95) | Throughput |
| --- | --- | --- |
| CRUD API | < 300ms | 2k–5k RPS |
| Auth API | < 200ms | 1k–3k RPS |
| Search API | < 500ms | 500–2k RPS |

## 10. Common Mistakes to Avoid

- Testing from localhost
- Ignoring P95/P99
- Not warming up API
- Forgetting DB limits
- Running load test on production without rate limits

## 11. Recommended Tool Stack (Professional)

| Purpose | Tool |
| --- | --- |
| Quick test | curl |
| Load & stress | k6 |
| Complex flows | JMeter |
| CI integration | k6 + GitHub Actions |
| Monitoring | Grafana + Prometheus |

## 12. Want This Tailored to You?

I can:

- Create **k6 scripts** for your specific API
- Help interpret **test results**
- Recommend **rate limits & scaling strategy**
- Tune **ASP.NET MVC / Web API** performance


---

Original Source: https://answers.mindstick.com/qa/116286/how-to-test-throughput-and-latency-to-api

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
