Stress testing

更新时间:
复制 MD 格式

Application Load Balancer (ALB) has four performance metrics, each requiring a specific connection type and testing approach. Mismatched settings, tooling limitations, or client-side bottlenecks cause inaccurate results.

Test topology

Use the following test architecture:

image

Key metrics and connection types

ALB has four performance metrics. Use the recommended connection type for each.

Metric

Connection type

Notes

New connections

Short connections

Use a heartbeat service to minimize bandwidth impact. Watch for client port exhaustion.

Concurrent connections

Long connections

Keep connections alive with a heartbeat service. Watch for client port exhaustion at high concurrency.

Data throughput

Long connections

Set a short timeout (for example, 5 seconds). A long timeout inflates the average response time and obscures whether you reached the target load. A short timeout surfaces issues through the success rate, making the actual load easier to identify.

Requests per second

HTTP short, HTTP long, HTTPS short, or HTTPS long connections

Measures request processing capacity. Any of the four connection types works.

Stress testing tools

  • Use Alibaba Cloud Performance Testing Service (PTS). PTS supports high concurrency and distributes traffic from public IP addresses across various locations. Integrate Cloud Monitor with PTS for real-time performance data.

  • Do not use Apache ab. Under high concurrency, Apache ab pauses at 3-, 6-, and 9-second intervals. It also validates responses by content length — when ALB distributes traffic across multiple backend servers, varying content lengths cause inaccurate results.

Stress test example with PTS

The following example shows a basic ALB stress test setup.

Environment setup

Create an ALB instance with the following configuration:

Component

Configuration

Listeners

HTTP on port 80 and HTTPS on port 443

Backend servers

Two ECS instances per listener, backend protocol set to HTTP and backend port set to 80

ECS specifications

2 vCPUs, 2 GiB memory, CentOS 7.9 64-bit

Install the web service

Log on to each ECS instance (ECS remote connection guide) and set up a web service.

  1. Install Apache Web Server:

    sudo yum install -y httpd
  2. Create a default homepage:

    echo "testvm" | sudo tee /var/www/html/index.html
  3. Start the HTTP service:

    sudo systemctl start httpd
  4. Verify that the web service is running on port 80:

    curl http://localhost

    Or run:

    curl http://127.0.0.1:80
  5. Create a test scenario in PTS and start the stress test. For more information, see Start a stress test in one minute.

Disable health checks during stress tests

Disable health checks on the server group before running stress tests. Health check traffic adds extra requests to backend servers and skews measurements. If a backend server flaps between healthy and unhealthy states, ALB repeatedly adds and removes it from the rotation, which reduces measured performance.

Troubleshoot low performance

If stress test results are lower than expected, check for these common causes.

Client port exhaustion

ALB strips the TCP timestamp attribute by default, which prevents tw_reuse (TIME_WAIT connection reuse) from working in the Linux protocol stack. Connections in TIME_WAIT state accumulate and exhaust available client ports.

Solution:

  • Replace short connections with long connections.

  • Use RST packets to close connections by setting the SO_LINGER socket option.

Backend server accept queue full

When the backend server accept queue is full, the server cannot send SYN_ACK packets, causing client-side timeouts.

Solution: The default value of net.core.somaxconn is 128. Increase this value and then restart the application on the backend server:

sysctl -w net.core.somaxconn=1024

Application dependency bottleneck

Backend server load may appear normal, but dependent services such as databases can bottleneck and degrade overall performance.

Solution: Remove unnecessary applications from backend servers, or scale out dependent services.