Prompt
I'm building an API and need to simulate concurrent users
Latest observation
Oct 20, 2026
OpenAI APIWeb search: off
To simulate concurrent users for an API, you have a few good options depending on whether you want:
- quick load testing
- repeatable scripted concurrency
- realistic user behavior
- distributed/high-volume testing
Good tools
1. k6 — great modern choice
Fast, scriptable, and easy to run in CI.
Example:
import http from 'k6/http';
import { sleep } from 'k6';
export const options = {
vus: 50, // concurrent virtual users
duration: '30s', // test length
};
export default function () {
http.get('https://api.example.com/health');
sleep(1);
}
Run:
k6 run script.js
2. Locust — good if you like Python
Useful for writing user flows in Python.
Example:
from locust import HttpUser, task, between
class ApiUser(HttpUser):
wait_time = between(1, 3)
@task
def health(self):
self.client.get("/health")
Run:
locust -f locustfile.py
3. JMeter — older but widely used
GUI-based, powerful, but heavier and more cumbersome.
4. artillery — simple and effective for Node.js users
Good for API load testing and scenarios.
What “concurrent users” means
Usually this means:
- multiple clients sending requests at the same time
- each user may have a session, think time, and repeated actions
- you can control:
- number of users
- ramp-up rate
- request frequency
- test duration
Important tips
- Start with a small number of users and ramp up gradually.
- Test against a staging environment, not production.
- Track:
- latency (p50/p95/p99)
- error rate
- throughput
- CPU/memory/db load
- If the API depends on a database, your bottleneck may be the DB, not the API server.
If you just want to generate concurrent requests quickly
You can also use curl in parallel, but it’s not ideal for real testing.
Example:
seq 1 100 | xargs -n1 -P10 -I{} curl -s https://api.example.com/endpoint > /dev/null
If you want, I can give you:
- a k6 script for your specific API,
- a Locust test plan,
- or a Dockerized setup for running concurrent load tests.