Performance and load testing
Testing safely and realistically
A load test is real traffic and can do real harm — or produce numbers that mean nothing. Permission, where to test, data, rate limits, and how to make a test look like real use.
A load test sends real requests to a real system. Done carelessly, it can take a system down for real users, get your network blocked, fill a database with junk — or cost a day and produce numbers that describe nothing real. A few habits prevent all of that.
Permission first
- Only load-test systems you own, or have written permission to test. To the system, a load test and an attack look the same. Testing someone else's API without permission can break its terms of use — and, in many countries, the law.
- Tell the people who run it. Operations, the database team, whoever is on call: when you'll test, from where, how hard. Otherwise they may spend an hour chasing your "incident" — or block you halfway through.
- Third-party APIs inside your system (payments, SMS, maps) usually have their own rules and costs. Mock them or use their test mode — never load-test a payment provider's live API.
Where to test
| Environment | Good for | Careful with |
|---|---|---|
| Your computer | Learning, checking the test works | Numbers describe your laptop |
| Test / staging | Most load tests | Often smaller than production; shared with others |
| A dedicated performance environment | Serious capacity tests | Costs money; must resemble production |
| Production | The only fully real numbers | Real users are affected; only with care, at quiet times, with a stop plan |
Testing production can be right — some problems only exist there — but plan it: start small, ramp slowly, watch monitoring, know how to stop, and have someone from operations with you.
Firewalls, CDNs and rate limits
Public APIs and sites usually sit behind protection — a CDN (Cloudflare, Akamai), a WAF (web application firewall) or an API gateway — that limits how many requests one address may send. Exceed it and you'll get 429 Too Many Requests or 403 Forbidden, sometimes for every request, sometimes after a burst — and your address may stay blocked for a while.
When that happens, the numbers describe the guard, not the API: 429s come back instantly, so response times look superb. A good report calls this out. To test the API itself, test from inside the protection (a staging address, an allowed list for your test machines) — ask the team that runs it.
Data and side effects
- GET is safe; POST isn't. A thousand POSTs create a thousand orders, send a thousand emails, charge a thousand cards. Know what each request does.
- Use test accounts and test data made for the purpose — never real customers.
- Clean up what the test creates, or test in an environment you can reset.
- Watch for side effects downstream: notifications, webhooks, reports, analytics — they all see your test traffic.
Making it realistic
A test that doesn't look like real use measures something else:
- Mix the requests like real users do. Real traffic is mostly reads with some writes — say 80% browsing, 15% searching, 5% ordering. Hammering only the login endpoint tests the login endpoint.
- Vary the data. The same product a thousand times is served from a cache. Use test data and built-in values so requests differ.
- Pause like people. Realistic think time — or, for capacity tests, a realistic rate.
- Ramp up, don't switch on at full force (unless a spike is the question).
- Test long enough to get past warm-up: minutes, not seconds — and hours for soak tests.
- Test from where users are, when the network matters — or close to the API when you want to measure the API alone.
Have a stop button
Before any test of a shared system, know: how to stop it (and that stop works), what makes you stop (error rate above X, response times above Y — or a phone call), and who to call if something breaks. Tools that can abort automatically when a goal is clearly missed are a good safety net.
Key takeaways
- Permission first, and tell the people who run the system — a load test looks like an attack.
- 429s and 403s mean a guard is answering, not your API; test from inside the protection.
- Know what each request does (POST creates), use test data, and make the load realistic: a mix of requests, varied data, pauses, ramp-up — and always a stop plan.
In the app: Good habits · Blocked: 429 or 403 · Before it starts