数据库连接池配置应增大:
datasource:
dynamic:
#设置默认的数据源或数据源组,默认值为master
primary: law
druid:
initialSize: 20
minIdle: 20
maxActive: 3000
maxWait: 60000
queryTimeout: 60000
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 20000
validationQuery: SELECT 'x'
testWhileIdle: true
testOnBorrow: true
testOnReturn: true
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
mysql数据库配置:
max_connections=1000
max_user_connections=500
net_read_timeout = 2000
jmeter配置:
1、添加线程组
2、线程组下添加http请求
3、线程组下添加http信息头管理器
4、线程组下添加查看结果树
5、线程组下添加汇总报告
nginx配置
user www www;
worker_processes auto;
error_log logs/error.log notice;
pid logs/nginx.pid;
worker_rlimit_nofile 20480;
events {
use epoll;
worker_connections 20480;
}
http {
include mime.types;
default_type application/octet-stream;
resolver 114.114.114.114;
server_names_hash_bucket_size 128;
client_header_buffer_size 64k;
large_client_header_buffers 8 128k;
client_max_body_size 100m;
client_body_buffer_size 30M;
limit_conn_zone $binary_remote_addr zone=one:32k;
sendfile on;
tcp_nopush on;
proxy_read_timeout 240s;
keepalive_timeout 600;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
log_format wwwlogs '$remote_addr - remote_user \[time_local] $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';
#access_log logs/access.log;
#log_format access-upstream 'time_iso8601\|request|remote_addr\|upstream_response_time|http_user_agent\|http_x_forwarded_for';
map $time_iso8601 $logdate {
'~^(?<ymd>\d{4}-\d{2}-\d{2})' $ymd;
default 'date-not-found';
}
access_log logs/access-$logdate.log ;
#include default.conf;
include vhost/*.conf;
#upstream配置
upstream springboot{
server 192.168.1.xx:端口;
server 192.168.1.xx:端口;
}
}
代理的location下配置反向代理
location /boot/ {
proxy_pass http://springboot;(upstream的命名的名称)
proxy_set_header Host host:server_port;
proxy_set_header X-Real-IP host:remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
jmeter可能出现的报错或异常
1、java.net.socketException:socket closed(强制停止线程,连接中断产生的错误,正常压测我们等测试结束就好,不用强制停止。)
2、java.net.SocketTimeoutExpetion:Read timed out(这个错误的导致是由于请求接口 设置的请求超时与请求响应超时设置过小所致。)
3、jmeter压测报java.net.SocketException:Connection reset: windows电脑需配置注册表
MaxUserPort:最大动态端口数(Default = 5000, Max = 65534)
TcpTimedWaitDelay:TCP等待延迟时间(30)
TcpNumConnections:TCP最大连接数(Default = 16,777,214)
MaxFreeTcbs:最大TCP控制块(1000-2000)
MaxHashTableSize:最大TCB Hash table数量(64-65536)
解析中值为10进制,下方脚本已全转换为16进制
实际在注册表新增:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters] 新建:
"MaxUserPort"=dword:fffe
"TcpTimedWaitDelay"=dword:1e
"TcpNumConnections"=dword:fffffe
"MaxFreeTcbs"=dword:7D0
"MaxHashTableSize"=dword:10000