Preventing 500 Errors During Sales: Effective Load Testing Strategies
500 errors during sales are a typical pain for e-commerce. If a peak load of 10,000 RPS crashes the server, you lose up to $10,000 per hour. To avoid downtime, we conduct performance testing with Artillery. This tool simulates thousands of simultaneous users, showing how the system behaves under pressure. Before launching promotions or new functionality, we model different test flows: catalog browsing, search, and checkout. As a result, you get not just a report, but specific optimization steps—from caching configuration to database indexes. Our clients save up to $5,000 per incident by timely identifying bottlenecks. Project evaluation takes 1 day, after which we provide a detailed report with recommendations. Contact us to get a consultation.
Load Testing with Artillery Helps Identify Bottlenecks
Artillery is a Node.js tool with YAML configuration, supporting HTTP and WebSocket. It generates load in phases: warm-up, ramp-up, peak. At each stage, we monitor response times, failure rates, and throughput. If p99 exceeds 1 second or 5xx errors >1%—it's a signal to optimize. For example, in one Laravel project, high latency occurred due to an N+1 query to the database when browsing the catalog. A test with 50 RPS revealed p95 growth to 3 s. After adding eager loading, p95 dropped to 200 ms. Learn more about performance testing on Wikipedia.
Why Choose Artillery for Load Testing
Artillery is simpler to configure than K6: no JS code needed for simple scenarios, just YAML. Compared to JMeter, Artillery integrates more easily into CI/CD: one command artillery run and a JSON report. Load can be distributed across multiple workers, achieving up to 100,000 RPS from a single machine (with proper configuration). In our tests, Artillery generates reports 2x faster than K6 under similar load.
Example of a full YAML configuration
# tests/load/basic.yml
config:
target: "http://localhost:3000"
phases:
- duration: 60
arrivalRate: 5
name: Warm up
- duration: 120
arrivalRate: 20
name: Ramp up load
- duration: 300
arrivalRate: 50
name: Sustained load
- duration: 60
arrivalRate: 100
name: Stress test
defaults:
headers:
Accept: "application/json"
Content-Type: "application/json"
ensure:
p99: 1000
p95: 500
maxErrorRate: 1
scenarios:
- name: Browse catalog
weight: 60
flow:
- get:
url: "/api/products"
expect:
- statusCode: 200
- hasProperty: "data"
- think: 2
- get:
url: "/api/products/{{ $randomNumber(1, 100) }}"
- name: Search
weight: 30
flow:
- get:
url: "/api/search?q={{ $randomString() }}"
expect:
- statusCode: [200, 404]
- name: Contact form
weight: 10
flow:
- post:
url: "/api/contact"
json:
name: "Test User"
email: "[email protected]"
message: "Load test message"
expect:
- statusCode: 201
How to Write a Load Test Scenario in 5 Steps
- Identify critical API endpoints: catalog, search, cart, checkout.
- Define SLA: p99 < 1 s, error rate < 1%.
- Write YAML definition with load phases: warm-up, ramp-up, peak.
- Add authorization if required (token capture).
- Run test locally, verify correctness, then integrate into pipeline.
Main Artillery Scenarios
Authenticated Scenario
# tests/load/authenticated.yml
config:
target: "http://localhost:3000"
phases:
- duration: 300
arrivalRate: 20
variables:
users:
- email: "[email protected]"
password: "pass123"
- email: "[email protected]"
password: "pass456"
scenarios:
- name: Authenticated user flow
flow:
- post:
url: "/api/auth/login"
json:
email: "{{ users[0].email }}"
password: "{{ users[0].password }}"
capture:
- json: "$.access_token"
as: "token"
expect:
- statusCode: 200
- get:
url: "/api/user/profile"
headers:
Authorization: "Bearer {{ token }}"
expect:
- statusCode: 200
- post:
url: "/api/orders"
headers:
Authorization: "Bearer {{ token }}"
json:
product_id: 1
quantity: 1
expect:
- statusCode: 201
capture:
- json: "$.id"
as: "orderId"
- get:
url: "/api/orders/{{ orderId }}"
headers:
Authorization: "Bearer {{ token }}"
expect:
- statusCode: 200
Custom JS Processor
# tests/load/custom.yml
config:
processor: "./processor.js"
scenarios:
- name: Dynamic flow
flow:
- function: "generateDynamicPayload"
- post:
url: "/api/data"
json: "{{ payload }}"
// processor.js
module.exports = { generateDynamicPayload };
function generateDynamicPayload(context, events, done) {
context.vars.payload = {
id: Math.floor(Math.random() * 10000),
timestamp: new Date().toISOString(),
data: Array.from({ length: 10 }, (_, i) => ({ key: `item_${i}`, value: Math.random() })),
};
return done();
}
GitHub Actions Integration
- name: Load Test
run: |
artillery run --output results.json tests/load/basic.yml
artillery report --output load-report.html results.json
- name: Check SLA
run: |
ERRORS=$(cat results.json | jq '.aggregate.counters["http.codes.5xx"] // 0')
P99=$(cat results.json | jq '.aggregate.latency.p99')
if [ "$ERRORS" -gt "10" ] || [ "$(echo "$P99 > 2000" | bc)" = "1" ]; then
echo "Load test failed: too many errors or high latency"
exit 1
fi
Comparison of Load Testing Tools
| Tool | Scripting Language | WebSocket | Distributed Load | CI/CD Integration | Our Rating |
|---|---|---|---|---|---|
| Artillery | YAML + JS | Yes | Built-in | Out of box | Excellent |
| Apache JMeter | XML, Groovy | Yes | Via remote servers | Plugins | Good |
| k6 | JS | No | Via workers | Excellent | Good |
Common Mistakes in Load Testing
- Testing only one API endpoint, ignoring business processes.
- Incorrect emulation of user behavior (e.g., missing think time).
- Running load from a single IP (network-level blocking).
- Ignoring application-level caching.
- Lack of server-side monitoring (CPU, RAM, DB connections).
Load Test Development Stages
| Stage | Duration | Result |
|---|---|---|
| Current architecture analysis | 0.5 day | List of critical API routes, SLA parameters |
| Writing test flows | 1–2 days | YAML configurations for 3–5 scenarios |
| Trial run, debugging | 0.5 day | Fix errors, correct emulation |
| Run on staging | 1 day | Collect metrics, prepare report |
| Final report + recommendations | 0.5 day | PDF report with charts and optimization tips |
What's Included
- Documentation: technical specification, scenario description, run instructions.
- Scenarios: 3–5 YAML files with support for authorization, WebSocket, custom processors.
- Report: HTML dashboard with metrics (response time, RPS, errors), JSON data for CI.
- Recommendations: list of bottlenecks and specific improvement steps (indexes, caching, replication).
- Support: 1 month of consultation after delivery.
Our experience: 50+ projects in e-commerce and SaaS. After completion, you'll get a clear understanding of your site's capacity and be able to prevent crashes during peaks. Order load test development and be confident in your site's stability. Get a consultation: we'll test your site under load and give recommendations.
Timeline Estimate
Development of 3–5 turnkey scenarios takes from 2 to 5 days depending on complexity. Cost is calculated individually after analyzing your project.







