E-Commerce Peak Checkout Load Test Generator
Generate production-ready k6 load test scripts simulating high-concurrency retail flash sales and inventory checkout paths.
Use this template when preparing retail platforms for high-volume sales events like Black Friday. It builds resilient performance testing scripts that evaluate cart reservation, payment gateway integration, and stock validation under peak load.
Role: Senior Quality Engineering Specialist with 12+ years of expertise in retail e-commerce scalability and performance stress testing.
Context
- Target Platform Architecture: {{ecommerce_platform}}
- Target Concurrency Volume: {{target_concurrency}}
- Critical Checkout Route: {{checkout_endpoint}}
- Active Test Stock Keeping Units: {{inventory_skus}}
- Payment Simulation Provider: {{payment_gateway_mock}}
- Latency SLA Threshold: {{p95_latency_threshold}}
Task
Author a fully executable k6 load test automation script that simulates realistic customer checkout funnels, validates concurrent stock reservations, and isolates latency bottlenecks across the {{ecommerce_platform}} infrastructure to ensure platform stability under {{target_concurrency}}.
Method
- Define stage-based load ramp-up, steady-state peak, and ramp-down execution profiles aligned with {{target_concurrency}}.
- Configure explicit threshold assertions enforcing {{p95_latency_threshold}} for HTTP response times and a sub-1% transaction error rate.
- Implement parameterized user persona data pools utilizing {{inventory_skus}} to simulate dynamic cart addition and SKU contention.
- Script multi-step transaction flows spanning catalogue search, cart addition, stock lock acquisition, and checkout payload dispatch to {{checkout_endpoint}}.
- Integrate mock header authentication and payload payload verification targeting {{payment_gateway_mock}} without triggering production billing loops.
- Embed custom metric counters and trend tracking for stock collision errors, session drops, and payment gateway round-trip latency.
- Implement intelligent retry mechanics with exponential backoff on transient network failures while logging unrecoverable server errors.
- Structure modular tear-down logic to release dangling inventory reservations created during execution.
Constraints
- Scripts MUST be written in syntactically valid modern JavaScript for k6 runtime execution.
- Scripts MUST NOT hardcode plaintext payment tokens, private keys, or static customer sessions.
- Handlers MUST explicitly verify HTTP 200/201 response status codes before proceeding through multi-step checkout gates.
- Custom metrics MUST track distinct tag boundaries for inventory lock versus payment settlement phases.
Output format
Executable k6 JavaScript test script formatted inside a single code block, followed by:
- Environment variable configuration guide (table of key, type, default, purpose)
- Scenario breakdown detailing virtual user ramp-up schedules and duration
- Error handling table listing caught status codes and alert conditions Total response length must remain between 450 and 850 lines of combined code and technical documentation.
Self-review
- Confirm all 6 context variables ({{ecommerce_platform}}, {{target_concurrency}}, {{checkout_endpoint}}, {{inventory_skus}}, {{payment_gateway_mock}}, {{p95_latency_threshold}}) are actively referenced in script logic.
- Verify syntax avoids non-k6-compatible Node.js standard library imports.
- Check that threshold boundaries strictly reflect {{p95_latency_threshold}}.
Explicit role, a named task, and discrete steps the model can follow.
Background, inputs and variables the model needs before it starts.
Hard boundaries — what the model must and must not do.
A named, field-level shape for the response.
Ordered work items that force analysis before an answer.
Length and structure that travel across frontier models.
Signal density — instruction weight without padding.
Documented variables so the scaffold adapts to new inputs.
Quality bar, assumptions and behaviour when inputs are thin.
How much real usage the template has behind it.