Skip to content

An environment for performance testing: how close to production it must be

B2Bnetwork team · · 6 min

System performance

In brief

A performance test environment must be identical to production in whatever affects bottlenecks: architecture, versions, configuration, the size and distribution of data, and the way layers communicate. It can differ in the number of nodes, provided you know which resource is shared and how the system scales horizontally. A scaled-down environment gives reliable results for a single node, but you cannot extrapolate them linearly to the whole of production, especially when the database is the bottleneck.

What must match production

The test environment must reproduce the elements that decide where the system will clog. A difference in any of them can make the test show a different bottleneck than the one that will appear in production.

ElementMust match productionMay differ
Architecturethe same layers, the same request path, load balancing, cache, queuesthe number of nodes in each layer
Versions and configurationapplication and database versions, JVM parameters, pool sizes, timeoutshost names, addresses, credentials
Datatable sizes, data distribution, number of customers and historythe content of personal data (anonymization)
NetworkTLS encryption, firewalls, latency between zonesthe exact topology of the corporate network
External dependenciescall method, timeouts, retriesthe service itself (a stub with realistic latency)
Monitoringthe same metrics, traces, and logs as in productionthe data storage system

The most common mistake is an environment that matches production in code but not in configuration: a smaller connection pool, a disabled cache, different database parameters. So you compare the configuration before every major series of tests, ideally automatically.

Data: size and distribution matter more than content

A database query plan depends on table sizes and value distribution, so a test on a small database may not reveal any problem. For a banking system, what counts is the number of accounts, several years of transaction history, and an uneven distribution: a few corporate customers with millions of operations next to millions of customers with a handful. What such problems look like in practice is described in the article Database bottlenecks.

There are three main sources of data:

  1. An anonymized copy of production. It best reproduces size and distribution, but requires an anonymization process compliant with GDPR; it is described in the article Test data and GDPR.
  2. Synthetic data generated according to a production profile. Safe, but you have to deliberately reproduce the distributions and the relationships between tables.
  3. A combination of both. Structure and volume from the copy, sensitive fields from the generator.

Whatever the source, data is restored to its initial state before every series of tests, so that consecutive runs are comparable.

A scaled-down environment: when it is enough

A full copy of production is expensive, so many organizations test on a scaled-down environment, e.g. with two application servers instead of eight. This approach gives reliable results under several conditions:

  • the architecture and configuration of a single node are the same as in production,
  • shared resources (database, queue, cache) are at full scale, or the test deliberately measures only the capacity of a node,
  • the team knows from a scalability test how the system behaves as nodes are added.

Results from a scaled-down environment are not extrapolated linearly. If two application servers handle 100 transactions per second, eight need not handle 400, because the shared database and locks will start limiting throughput earlier. A scaled-down environment is well suited to detecting regressions between versions and to measuring node capacity; final confirmation before a major event, such as a core system migration or a sales peak, requires a full-scale environment or a test in production with safeguards.

External dependencies and substitute services

The systems of banks, operators, and insurers call dozens of external services: a credit bureau, a payment gateway, a network system, an SMS provider. Their test environments usually will not accept the load or have traffic limits. In performance tests you replace them with substitute services that:

  • respond with latency close to production, with a distribution rather than a constant value,
  • can simulate slowdowns and errors, to check timeouts and retries,
  • do not become a bottleneck themselves at heavy traffic.

Such a stub also lets you test a scenario that cannot be safely triggered on a real service: the provider responds in five seconds instead of half a second. The test then shows whether the application's threads and connections will be exhausted.

On-demand environments and testing in production

A cloud environment created from infrastructure code solves two problems at once: you pay for it only while the test runs, and it has the same configuration every time. The condition is that the infrastructure code is shared with production and that the differences are explicitly described by parameters; more in the article Infrastructure as code. In banks this setup is often combined with a hybrid cloud, as in the case study Migrating a bank's development and test environments to a hybrid cloud.

A test in production is a supplement, not a substitute. It is done carefully: outside traffic hours, on test accounts and data, with load rising in steps and a plan for immediate abort. It lets you check elements that cannot be reproduced elsewhere, e.g. a content delivery network or the actual links. How to choose a tool for such tests is described in the article JMeter, Gatling, or k6.

Questions and answers

Is a UAT environment suitable for performance testing?

Rarely. An acceptance testing environment usually has fewer resources and a small database, and functional testers work on it at the same time, so the results are unstable and the load test disturbs others. Performance tests need an environment where nothing else happens during the test and which has production-scale data.

How much does a full-scale environment cost?

As much as the corresponding part of production, which is why it is worth creating it from infrastructure code for the duration of the tests and removing it after the series ends. Licenses counted per core or per server can cost more than the infrastructure itself, so you check them before planning the environment.

Can I test in production instead of building an environment?

Only to a limited extent. In production you run careful load tests outside traffic hours, but not stress tests, whose goal is to reach the system's limit. In addition, a test in production leaves data that has to be removed afterward and may trigger external processes, such as sending SMS messages or payments.

How do I check that the environment configuration matches production?

Most simply, automatically: a script compares the parameters of the application, database, connection pools, and virtual machines in both environments and lists the differences before every series of tests. When environments are created from the same infrastructure code, differences are visible directly in the parameters and go through change review.

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