All notes

Load Testing Starts with a Workload Model

Explain arrivals, task mix, data distribution and recovery before quoting a concurrency number.

English edition, edited for length. Read the complete Chinese original.

The stress test report stated that 1,000 concurrent users did not encounter any errors, but it did not specify the type of requests, the average wait time for each user, or the amount of data in the database. This number alone cannot definitively answer whether the activity will be safe tomorrow. Similarly, the same number of concurrent users could experience significantly different performance when performing light reads versus generating large reports.

First, you need a workload model. This defines what users are doing, at what rate, and how the operations depend on each other. It also specifies how the data is distributed. The tool then translates this model into actual traffic.

Arrival Rate and Concurrency are Not the Same Thing

With a closed model, a fixed set of virtual users are used, and requests are only sent after each user completes their task. When the system slows down, the rate at which requests arrive naturally decreases, which can mask the backlog that occurs during peak times. In contrast, an open model initiates requests based on a fixed or variable arrival rate, more closely mimicking the scenario where external demand doesn’t immediately disappear when the server slows down.

Both models have their uses. A small number of backend staff who perform ongoing operations are well-suited for the user loop, while sudden requests for promotional entry points require a reach model. The choice should be based on business needs, not automatically adopted based on the default use of virtual users.

Concurrency is the result of both arrival rate and service time. A concurrency number alone cannot represent capacity; it is meaningless without information about latency. The report should simultaneously track throughput, in-flight requests, and waiting times.

The Proportion of Each Stage Determines the Bottleneck

Assume that users first open the list and then view the details, with only a small number submitting reports. Testing all requests against the list will ignore the most expensive processes. Generating all reports will also deviate from normal load. Based on known access patterns, create combinations, and set conservative scenarios for unknown peak loads.

Test accounts and data should not share the same object unless there is a genuine need for this in production. If all users access the same record, it could result in very high cache hits, but also create artificial lock contention. It is important to test both scenarios: normal distribution and concentrated access to popular objects.

The data volume, indexing, historical length, and permission scope should be representative. For small tables, fast queries are desirable, while for large tables, different execution plans may be used. It’s important not to simply increase the number of requests while retaining tens of rows of test data.

You can set the list reading to occupy the majority, details to a lesser extent, and report creation to a small amount, and separately include both hot and ordinary data distributions. This proportion is simply a hypothetical assumption and should not be used to represent actual website access statistics. If real data is available, remove personal information and record the observation window; if not, use multiple scenarios to cover the uncertainty. The report should clearly state which conditions have been verified and which are only potential risks.

Each process retains necessary dependencies. To view details, first obtain a valid article ID, and then write it along with usage isolation account and stable operation identifiers. Random non-existent address testing error handling should not consume all normal load. User thinking time has meaning in a closed model, while in an open access model, it is independently arranged according to business needs. Tool configuration must match the explanation, and the natural flow of traffic generated by the loop should not be considered as an external requirement.

Data preparation can utilize anonymized structures or synthetic samples, while preserving important scales, skew, and relationships. It is not possible to copy production private data to uncontrolled machines solely for realistic testing. Pre-warming, cold start, and old cache conditions are recorded separately, and the same method is used before and after optimization. If all test requests target a single object, the conclusions are only applicable to that specific hotspot and do not represent all queries.

The capacity threshold is more important than the largest number

Gradually increase the arrival rate, observing latency, errors, and resource usage as the load changes. The system may start to queue at a certain rate, with throughput increasing only slightly but the “tail” increasing rapidly. This turning point is often more suitable for planning daily capacity than the maximum throughput at the point of failure.

Low-load baseline -> Steady state -> Gradual ramp-up
-> Overload observation -> Return to normal load -> Recovery verification

The recovery phase cannot be skipped. Some systems may remain in a state of retries, queue buildup, or connection leaks after a decrease in traffic, preventing full recovery. The end of a peak period does not necessarily mean that the service has been fully restored. Testing should document the process required to recover to the target latency, rather than simply turning off a tool and declaring the service restored.

Testing tools can also become a bottleneck.

If the pressure machine’s CPU, network, or connection limit is reached, the test traffic will not reach the target. Monitor the actual number of requests started, scheduling latency, and tool discard iterations. If the arrival rate required by the load model is not achieved, it cannot be interpreted as having sufficient service capacity.

When measuring latency, it’s important to understand whether the measurement includes requests that are queued by the client. Some closed testing environments may miss requests that should have arrived during periods of system slowdown, leading to coordination issues. The explanation of the results should specify the model and measurement range, rather than simply showing a percentile.

It’s important to allocate sufficient time for the system to reach a stable state at each stage, allowing the cache, connection pool, and background tasks to fully function. However, the test duration depends on the system’s behavior, and it’s not possible to definitively prove stability simply by running for a fixed period of five minutes.

When service becomes slow, waiting users experience delays in subsequent requests, and requests that don’t materialize are not counted. If real requests continue to arrive, the queue will become longer. This difference is not a bug in the closed model, but rather a question of applicability. Open models can also discard planned requests if there are not enough processing resources, and it’s important to record unfulfilled iterations and not ignore subsequent claims of low error rates.

It needs to be clearly defined from what point the delay is to be calculated. The delay is measured from the initiation of the tool request to the receipt of the response, which may not include scheduling delays. Background business operations also include queue and final file visibility. User-defined metrics are measured from the time the action is accepted, and the HTTP response delay is observed separately. The report returning “200 quickly” does not necessarily mean that the report has sufficient capacity. Stress testing must track the actual completion of the business process.

Resource bottlenecks can occur in the CPU, connection pool, database locks, network, downstream limits, and queues. Monitoring across these layers is essential. A low application CPU usage does not necessarily indicate available capacity; connection waiting times may be the primary factor. The capacity bottleneck is related to the main cause, and optimizing one bottleneck will naturally lead to the emergence of another. Reports should not be interpreted as permanent service capabilities based on a single test result.

Dependencies and Security Boundaries

Testing external payment interfaces will incur real costs, and testing emails or payments could potentially harm users. Prioritize using controlled sandboxes and replaceable dependencies, but also be aware that sandbox delays and limitations do not represent the performance of production vendors.

To conduct production testing, it is essential to clearly define the scope, limits, stopping conditions, and responsible personnel to prevent the experiment from becoming a hazardous situation. Account isolation, data tagging, and cleanup paths must be prepared in advance. If tests are not cleaned up, the results will be affected by the previous data growth in subsequent tests.

The stopping conditions should include error rate, critical latency, and data integrity. The system should stop immediately even if it doesn’t generate errors but produces duplicate orders. Capacity testing should not exceed business safety boundaries in the pursuit of impressive, unrealistic numbers.

Repeat orders, incorrect amounts, permanently suspended tasks, and unauthorized access should be immediately stopped, even if the error rate is low. Test data should use clear prefixes or internal labels, and the cleanup should list the exact targets to avoid deleting real objects. Stopping the pressure does not mean that the background task has stopped; it is necessary to wait for or cancel the controlled task and check the results. The final stage and the initial preparation are both part of the experiment.

External charging interfaces use sandboxes or controlled surrogates, but it’s important to note that the surrogate doesn’t reflect the actual capacity of the vendor. Production testing should only be performed within clearly defined scopes and limits, and not expanded to achieve a complete conclusion. The testing tools must have their own credential management and log anonymization features, and should not include the request body, tokens, or email addresses in the reports. The security boundaries are defined by the experimental design, not by adding a disclaimer after the fact.

During the recovery phase, gradually reduce the flow rate, and observe delays, backlog, and resource recovery. Retrying a failed operation might leave residual load, and connection leaks could lead to ongoing degradation. Confirm that the system has been restored to the user’s desired state, and save any necessary cleanup and maintenance actions. A system that can handle peak loads but cannot recover to its peak capacity cannot be reliably claimed to have that capacity.

Transforming a Business Journey into an Executable Model

Taking reading technical blogs as an example, users first land on the homepage and then open articles. Some users search for tags, while a few subscribe. The homepage, article content, and subscription requests should not be randomly sampled based solely on URL, as real requests have state and dependencies. Article requests should originate from a legitimate content collection, and subscriptions should use isolated addresses. Search should cover both common and rare terms. If the purpose of testing is to simulate edge static caching, do not overload all traffic to the write interface; if the goal is a subscription system, static article throughput should not be used as a substitute.

When documenting a journey in a table or configuration, clearly indicate whether the proportions are based on real observations or assumptions, and also specify the cache status, article size, access region, and login status. Different regions may experience different networks and edge caches, and a single local generator can only verify a portion of the paths. When real data is unavailable, you can create a few specific scenarios:

  • Typical access focused on article reading: This scenario involves frequent access to articles, with varying proportions for different articles.
  • A specific article experiencing a surge in popularity: This scenario involves a single article that is being widely accessed, with a high proportion of traffic directed towards that article.
  • Cold start after cache refresh: This scenario involves a situation where the cache has been recently refreshed, and the proportion of traffic is initially low.

Each scenario presents its own set of challenges, and the goal is to address these challenges individually, rather than trying to create a single, idealized average.

The test must also clearly indicate whether each request corresponds to a new business intent. If all virtual users share an idempotent key, the system may only perform a single real write, with the rest being retries; if each retry uses a new key, this will create duplicate business operations that should not exist. Generate a stable identity for each intent, use the same identity for failed retries, and then create a new intent after completion. The test report should count the number of unique successful completions to avoid treating idempotent retries as a new order processing capability.

For pagination, the data set should include different page depths, permission ranges, and hot spots. If only the first page is tested, it may all hit the cache; if only random, non-existent cursors are tested, the primary focus is on verifying error handling. First, define the real query families that need to be covered, and then generate valid inputs. Set up separate scenarios for error traffic to test input limits and degradation, but without obscuring whether normal business operations can complete under the same pressure.

Using Queue Relationships to Explain Curves

When stable conditions and consistent statistical ranges are met, the Little Law can be used to establish a relationship between the average number of tasks in transit, the arrival rate, and the average dwell time. For example, if 20 tasks are accepted per second with an average dwell time of 2 seconds, this corresponds to an average of approximately 40 tasks within the system. This relationship helps to identify measurement errors, but it does not guarantee capacity simply by increasing the number of concurrent tasks to 40. Applying it directly in cases of unstable overload, dropped requests, or only tracking execution time will lead to incorrect conclusions.

If the acceptance rate continues to increase after a load increase, while the completion rate plateaus, the backlog will accumulate as unprocessed work. The chart should simultaneously display acceptance, completion, rejection, and queue age. Focusing solely on completion throughput may obscure the fact that the system has committed to tasks that cannot be completed in a timely manner; focusing solely on queue length may obscure the fact that a small number of older tasks are consistently being starved. Task age and the actual completion status will connect these signals back to the user’s goals.

Overload protection should proactively refuse tasks that cannot be reliably fulfilled, rather than simply queuing them indefinitely. Load testing should confirm that rejections occur at the correct thresholds, that responses are understandable, and that retry attempts are limited. Furthermore, tasks that have already been accepted should still be protected. It is not acceptable to claim that a service is error-free after removing all rejections from the failure report. The conclusions regarding capacity should clearly state the acceptance rate and completion deadlines at the target arrival rate, and should explicitly define the actual service received by the user.

Waiting times for connection pools, database locks, and vendor rate limiting can all produce similar long-tail distributions. Resource curves can help pinpoint the source. By changing a variable, such as reducing report concurrency or using controlled slow dependencies, observe whether the assumptions hold true. A single test case should only support the interpretation under that specific condition, and should not be attributed to the database simply because the CPU is overloaded, or to code improvements simply because the system has been scaled up.

Assessing and Managing Isolated Outbreaks, Long-Tail Risks, and Debt Recovery

Beyond the normal steady-state load, simulate a limited burst of activity, and then return to the baseline. Observe whether the system can clear the backlog within a specified timeframe, whether tasks are repeatedly re-submitted, and whether automatic scaling leaves resources behind after traffic decreases. Before ending the test, count the number of intentions that are still in progress or awaiting confirmation. Do not assume that stopping HTTP requests means the experiment is complete.

The duration of long-term tests is determined by the test cycle. Caching, periodic reconnection, background archiving, or cleanup operations can introduce load that is not visible in short-term tests. First, list these cycles, and then decide which ones should run naturally and which ones can be shortened in a controlled environment. Shortening the cycle changes the conditions for the test, and the report should state that accelerated experiments should not be directly considered as proof of real, long-term, and stable behavior.

For systems with retry mechanisms, record the original request and subsequent attempts. After an initial failure, the tool sends a new request, while the application’s internal retry mechanism increases. The overall downstream pressure may still be high. The load model needs to account for this feedback loop. It should first allow for complete failure, followed by controlled recovery, and then check the retry limits, jitter, and task fairness to ensure that the system does not create a second peak during recovery.

Organizing Raw Results into Boundary-Defined Decisions

The results should at least retain the load script, configuration, data generation method, and key time series. When plotting, the failure phase and the delay and response category of failed requests should also be indicated. Since some failures return quickly, the decrease in average delay may actually be due to more rejections, so it is necessary to separately explain the successful, rejected, and unknown results.

The optimization experiment should first establish a baseline, then modify a key variable, and repeat the experiment using the same data seed and load curve. If automatic scaling, shared databases, or vendor status cannot be reliably fixed, retain the relevant observations, and repeat the experiment if necessary, without fabricating statistical significance. When the difference is smaller than environmental fluctuations, it should be stated that the evidence is insufficient, rather than selecting the fastest result as an improvement.

The final answer to capacity planning should address whether the required activity demand falls within the validation range, which assumptions are most vulnerable, how to manage or scale down after a turning point, and what to observe during on-call. Even without achieving the maximum concurrency number, these answers can support deployment. Conversely, a limit value without an input model, correctness checks, and recovery records is difficult to guide any specific action.

The test threshold should be clearly defined before the test begins. Even if the planned peak value is not reached, the test should be stopped and the evidence saved honestly, without continuing to increase the load until the desired number is achieved. Before each repetition, explain the initial limitations, whether they come from the service, the generator, or security boundaries. Each experiment should answer a verifiable question.

Conditions for Maintaining Capacity Decisions and Safety Margins

The highest achievable arrival rate that meets the target does not necessarily mean that production can operate indefinitely at that level. Factors such as traffic ratios, latency, and data growth introduce uncertainty, and the plan should include reasonable margins and specify the sources. A change in a database hotspot can shift the critical point, and it should be reviewed regularly with updated scenarios. The conclusion about capacity is a conditional statement, not a permanent commitment of the product.

It is possible to test under steady-state, sudden spikes, and long-term operation conditions. Steady-state testing focuses on resource usage and latency, while sudden spike testing focuses on queue length and recovery. Long-term testing focuses on connection leaks, memory usage, and background maintenance. A fixed five-minute test may not cover cache expiration and cleanup tasks, so the duration is determined by the mechanism’s cycle. When the experimental cost is high, it is advisable to start with smaller diagnostic tests and then extend them based on specific concerns, rather than applying unlimited pressure without a clear understanding.

Optimize comparisons using the same data and version-specific variables. Performance variations due to caching warm-up, automatic scaling, or different vendor performance should be recorded and explained. If complete control is not possible, report the uncertainty range and avoid presenting single-instance differences as definitive improvements. Performance charts should retain errors and maintain business integrity; they should not only show successful delays after filtering out failed requests.

The load curve is associated with the user’s target. For example, if a report is created quickly but ultimately fails to meet the deadline, it should be treated as a business failure. Details read, return error. Content 200, also cannot be considered a success. The test script incorporates response structure and key content verification, and the background task confirms the reconciliation results. The goal of the capacity test is to achieve a higher number of correct tasks, not a higher number of requests.

After the test, verify and clean up the scope and account fees. Temporary resources, messages, and files should be handled according to a clear list. Do not delete the entire database or object bucket solely because the stress test is complete. The preparation, execution, stopping, recovery, and cleanup stages form a complete experimental lifecycle. Missing any stage will reduce the reliability of subsequent data. The tools and reports are versioned together to allow for verification of the current environment before an activity, rather than relying on outdated numbers.

Preserve code versions, database sizes, dependency configurations, load curves, testing tool versions, and resource environments. Compare the performance before and after optimization using the same model, and discuss whether the changes are due to caching or data differences.

The best way to express the conclusion is in a conditional statement: Under a certain data scale and workload, a specific arrival rate range meets the target; what are the main bottlenecks when it exceeds this range? This type of conclusion can support capacity decisions, and a simple statement like “supports 1000 concurrent users” can only be used for marketing purposes.

The delay and abandonment of iterations within the load testing tool itself should be documented. If the target traffic does not generate, the scenario test is not completed. Do not mask the tool’s resource limitations by adding virtual users. First, verify the CPU, network, and connection limits of the generator, and then use the correct curve to recover. Separate service capabilities from tool capabilities to establish a clear boundary.

References