全部文档
当前文档

暂无内容

如果没有找到您期望的内容,请尝试其他搜索词

文档中心

压力测试方法

最近更新时间:2023-12-29 17:15:18

性能测试

后端服务

  • 环境:北京6C机房,3台8c16G S6服务器

  • 系统: CentOS Linux release 8.2.2004

  • 软件:openresty-1.21.4.3-1.el8.x86_64

  • 配置:

user  nginx www;
worker_processes  auto;

worker_cpu_affinity auto;

error_log  logs/error.log  error;
pid  nginx.pid;

events {
    use epoll;
    worker_connections  102400;
    accept_mutex off;
}

http {
    default_type  text/html;
    charset utf-8;
    map_hash_bucket_size 128;

    log_format  main  '$remote_addr - $scheme [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$host" "$upstream_addr" "$upstream_cache_status" $request_time $upstream_response_time';

    access_log  logs/access.log main buffer=32k flush=3s;
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;

    keepalive_timeout  30;
    keepalive_requests  1000;
    client_header_timeout 60s;
    client_body_timeout 60s;

    proxy_connect_timeout 3s;

    gzip  on;
    gzip_static on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;
    gzip_comp_level 5;
    gzip_min_length 1024;
    gzip_buffers 4 32k;
    gzip_types text/plain application/json application/x-javascript application/javascript text/css;

    server_names_hash_max_size 1024;
    server_names_hash_bucket_size 512;

    client_max_body_size 100M;
    client_body_buffer_size  2m;
    large_client_header_buffers 4 128k;
    client_header_buffer_size 32k;
    variables_hash_bucket_size 1024;

    proxy_temp_path   /dev/shm/proxy_temp_dir 1 2;
    proxy_cache_path  /dev/shm/proxy_cache levels=1:2 keys_zone=cache1:1024m inactive=1d max_size=10g ;

    server {
        listen 80   backlog=102400 reuseport default_server;

        listen [::]:80   ipv6only=on backlog=102400 reuseport default_server;

        location / {
            echo "$http_name(RS:$server_addr:$server_port)";
        }
        
        location = /ping {
            echo "ok";
        }
    }

}

客户端及工具

  • 环境: 北京6C机房,8台8c16G S6服务器

  • 系统: CentOS Linux release 8.2.2004

  • 工具:wrk

  • 命令: wrk -c 1024 -d6000 -t8 http(s)://<vip:vport>/ping

测试方案

  1. 创建服务器组,后端服务器组选择长连接或者自适应

  2. 创建ALB和http/https监听器

  3. 逐次在客户端上使用wrk打流,观察流量平稳上升

  4. 在ALB监控上查看统计数据

  5. 在一台客户端上通过curl命令获取延时数据

curl -k -o /dev/null -s -w "http_code:%{http_code}\ntime_appconnect:%{time_appconnect}\ntime_connect:%{time_connect}\ntime_namelookup:%{time_namelookup}\ntime_pretransfer:%{time_pretransfer}\ntime_starttransfer:%{time_starttransfer}\ntime_total:%{time_total}\n" http(s)://<vip:vport>/ping

命令输出

http_code:200
time_appconnect:0.041642
time_connect:0.001290
time_namelookup:0.000026
time_pretransfer:0.041720
time_starttransfer:0.044321
time_total:0.044392

100s内连续执行上面curl请求,获取100s内的结果,计算均值

测试结果

性能指标

公网ipv4-http

公网ipv4-https

私网ipv4-http

私网ipv4-https

qps(w)

125

132

127

112

控制台延时(ms)

1.44

2.7

2.6

2.24

curl延时(time_starttransfer, ms)

4.95543

76.7073

28.7019

116.99

文档导读
纯净模式常规模式

纯净模式

点击可全屏预览文档内容
文档反馈