jmeter压测 性能提升

先用jmeter工具测试当前服务端并发数下的性能数量,再根据实际情况逐步提升并发数。

常用命令:

查看进程的线程数量:pstree -p 端口号|wc -l

查看进程的线程数量详情:pstree -p 端口号

查看机器的性能详情:top -H

 

 

load average:最近的1min 10min 15min的load数量(IO数量)

us:用户态下CPU耗时

sy:内核空间对系统的占用

 

 

 

server端并发线程数上不去问题:

在jmeter中逐渐提升并发数,直到出现error,查看当前服务器的线程数量,就得到了最大线程数。

解决:

1、增大容量:修改spring内嵌tomcat中spring-configuration-metadata.json文件下各个节点的配置

{ //设置端口号

"sourceType":"org.springframework.boot.autoconfigure.web.ServerProperties",

"defaultValue":8080,

"name":"server.port",

"description":"Server HTTP port",
"type":"java.lang.Integer" },

{ //设置等待队列大小,默认100

"sourceType":"org.springframework.boot.autoconfigure.web.ServerProperties$Tomcat",

"defaultValue":100,

"name":"server.tomcat.accept-count",

"description":"Maximum queue length for incoming connection requests when ...",

"type":"java.lang.Integer" },

{ //设置线程最小等待数量,默认10

"sourceType":"org.springframework.boot.autoconfigure.web.ServerProperties$Tomcat",

"defaultValue":10,

"name":"server.tomcat.min-spare-threads",

"description":"Minimum number of worker threads",

"type":"java.lang.Integer" },

{ //设置最大可被连接数,默认10000

"sourceType":"org.springframework.boot.autoconfigure.web.ServerProperties$Tomcat",

"defaultValue":10000,

"name":"server.tomcat.max-connections",

"description":"Maximum number of connections that the server accepts and processes...",

"type":"java.lang.Integer" },

{ //设置最大支持线程数,默认200

"sourceType":"org.springframework.boot.autoconfigure.web.ServerProperties$Tomcat",

"defaultValue":200,

"name":"server.tomcat.max-connections",

"description":"Maximum number of worker threads",

"type":"java.lang.Integer" }

可在配置文件中修改(按4核8G配置,具体看机器性能):

application.properties: server.port=80

server.tomcat.accept-count=1000

server.tomcat.max-threads=800

server.tocat.min-spare-threads=100 //用于解决突发请求

 

响应时间变长TPS上不去:
经过jmeter测试,单Web容器上限:

线程数量:4核8G内存单进程调度线程数800-1000以上后即花费巨大的时间在cpu调度上

等待队列长度:队列做缓冲池用,但也不能无限长,消耗内存,出队也耗cpu

MySql数据库QPS容量问题:

主键查询(聚簇索引,innoDB也可以设置Buffer缓存):千万级数据 = 1-10毫秒

唯一索引查询:千万级别数据 = 10-100毫秒

非唯一索引查询:千万级别数据 = 100-1000毫秒

无索引(全表扫描):百万级别数据 = 1000毫秒+(不可接受)

非插入更新删除操作:同查询

插入操作:1w~10w tps(依赖配置优化)

posted @   我只吃大碗  阅读(10)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 25岁的心里话
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
历史上的今天:
2015-03-06 【转】android adb命令
点击右上角即可分享
微信分享提示