Skip to content

Performance testing before a sales peak: a step-by-step plan

B2Bnetwork team · · 6 min

System performance

In brief

Performance testing before a sales peak starts with a business forecast turned into numbers: orders per hour, sessions, path proportions. On that basis you build a traffic model, scripts and data, and then a series of tests checks the system at the forecast level, above it and over many hours. The last step is a plan for peak day: a change freeze, ready decisions in case of overload and monitoring. It is worth starting a few weeks earlier, because fixes also have to be tested.

Step 1. The business forecast in numbers

The first question is: how much of what, in the worst hour. An online store before Black Friday, an insurer before a motor third-party liability campaign or an operator before a smartphone launch needs the same numbers from the business:

  • the expected number of orders, policies or activations in the peak hour,
  • conversion, that is, how many sessions per order,
  • the worst few minutes, e.g. the start of a promotion at midnight or a newsletter send,
  • changes in traffic compared with last year: new channels, a new mobile app, new payment methods.

An example calculation, explicitly just an example: the business assumes 6,000 orders in the peak hour at a 3% conversion. That is 200,000 sessions per hour, or on average about 56 new sessions per second. If in the first 10 minutes after the promotion starts traffic is twice the hourly average, the test must show that the system can handle about 110 new sessions per second.

Step 2. The traffic model: paths and proportions

The traffic model describes what customers do and in what proportions. For a store it is usually: home page and categories, search, product page, cart, login, payment. Proportions come from traffic analytics from the previous peak, not from intuition, because customer behavior changes at the peak: more searches and refreshing of the promotion page, more abandoned carts.

The model also records the arrival rate of customers, not only the number of concurrent users. Customers from the internet arrive regardless of whether the server keeps up, so the test should hold the specified rate of new sessions. The differences between test types are described in the article Load, stress and endurance tests.

Step 3. Environment, data and external dependencies

A test gives a reliable result only on an environment that behaves like production: the same architecture, configuration and a similar data size. A catalog with 500 products instead of 200,000 will produce different query plans and different cache hits. The details are described in the article An environment for performance tests.

External dependencies are a separate topic: the payment gateway, courier, anti-fraud system, SMS provider. Their test environments often have their own traffic limits or will not accept load at all. In the test they are replaced with stubs that respond with a realistic delay, and separately you agree with the providers what traffic they will accept on peak day.

Step 4. Scripts and pass criteria

Scripts replay the paths from the model with unique data: different customers, different products, different discount codes. Before the first test you write down pass criteria, so that after the test nobody argues whether the result is “good enough”. Example criteria:

  • p95 of add-to-cart and payment times within the set thresholds,
  • error rate below the set threshold,
  • CPU and memory use on every layer below the set headroom,
  • no growing queues after the test ends.

Times are written in percentiles, not averages; why is explained in the article Percentiles instead of averages.

Step 5. A series of tests and fixes

Order of tests

Tests run in an order in which each next one uses the previous one:

TestLoadWhat it checks
Smokea few percent of the forecastwhether scripts, data and monitoring work
Load100% of the forecast, approx. an hourwhether we meet the pass criteria
Stressin steps up to 150–200% and beyondwhere the limit is and what breaks first
Spikea jump to a multiple of traffic within secondspromotion start, autoscaling, warmed-up caches
Endurancetypical traffic for many hoursmemory leaks, nightly jobs, growing tables

During every test the team looks not only at the generator report but at the metrics of all layers: application servers, database, queues, cache, load balancing. The most common bottlenecks sit in the database and connection pools; how to find them is described in the article Bottlenecks in the database.

Fixes and a rerun

Every fix changes the system, so after it you repeat the load test and compare the result with the first run. Typical fixes before a peak are indexes and rewritten queries, larger connection pools, a cache for the catalog and prices, moving email sending to a queue, traffic limits for bots. The schedule should leave time for at least two rounds of fixes, because the first fix often uncovers the next bottleneck.

Step 6. A plan for peak day

The last step carries test results into operations. The plan for peak day includes:

  • a freeze on changes in sales systems for a few days before the peak and during it,
  • adding capacity in advance if autoscaling reacts more slowly than the traffic jump,
  • a list of features that can be switched off under overload, e.g. recommendations or in-store availability lookup,
  • a waiting room or a traffic limit, if the stress test showed a hard limit,
  • a dashboard with a few key measures and an on-call duty with a clear division of decisions.

After the peak you compare the forecast and the actual traffic with the test results. That difference is the best input to capacity planning for the next year. The article JMeter, Gatling or k6 helps choose a tool for such a series of tests, and the course of a project for an online store is described in the case study Preparing an online store for Black Friday.

Questions and answers

How long before the peak should we start performance testing?

Early enough to fit preparing scripts and data, a first series of tests, at least two rounds of fixes and a rerun before the change freeze. In practice that means a few weeks. A test done a week before the peak will show problems but leave no time to remove them safely.

Is it enough to test for 20% more than last year?

Usually not. Last year's traffic is a good starting point, but the forecast must account for changes: a new campaign, a new app, new payment methods and a different distribution of traffic over time. In addition, the stress test should go clearly above the forecast, because forecasts on promotion day are sometimes exceeded.

What should we do when the payment provider does not allow a load test?

In the test, replace the gateway with a stub that responds with a delay close to production, and separately confirm with the provider what traffic it will accept on peak day. It is also worth checking how the system behaves when payments slow down: whether the order queue grows without end, or whether the customer gets a clear message.

Can tests be done in production before the peak?

Some companies run careful tests in production at night, with test accounts and a plan for immediate abort, to check things that do not exist in the test environment, e.g. a content delivery network. Stress and spike tests are done on a test environment, because their purpose is to reach the system's limit.

What it looks like in a project

Your system slows down under load? We'll find where it loses time.

Let's talk

Read more: System performance