开发基础
开发基础笔记
mybatis-plus通用的service方法
通过jenkins配置前后端自动打包及发布
mybatis-plus实现分页的方式
Java极客技术公众号PDF
狂神说SpringBoot
Hashids java 版使用
SpringBoot
1、Web快速开发
2、结果集的封装
3、集成MyBatis实现数据库操作
4、Springboot @Validated参数校验
5、SpringBoot全局异常处理
6、拦截器HandlerInterceptor
7、集成Swagger实现API自动生成
8、集成knife4j实现API自动生成
9、Springboot集成MyBatis-Plus快速入门
10、springboot自定义注解及AOP切面使用
11、使用Shiro实现登陆和权限认证,基于MyBatis
12、集成SpringSecurity实现授权认证
13、SpringBoot集成EasyExcel实现数据导入与导出
14、Spring Task定时任务的实现
15、Quartz快速上手与实践
16、如何用代码实现Spring IOC
17、SpringBoot集成JWT,实现接口的鉴权交互
SpringCloud
Nacos作为服务注册中心
seata1.6.1 结合springcloud实现分布锁的技术笔记
一些技术博客推荐
前端面试相关
看这一篇就够了
java.util包常用的类和接口
CountDownLatch介绍与使用
Common-lang3使用入门
Hutool简单使用入门
lombok 介绍及基本使用方法
git项目统计成员代码行数和提交的次数
mysql 逗号分隔的数据 like查询
使用sonar进行代码质量检查
线上使用jmeter进行压测的时候,使用Arthas诊断工具排查响应慢的接口
php结合phpstudy8、vscode开启xdebug进行代码调试
node-red使用入门
本文档使用 MrDoc 发布
-
+
首页
线上使用jmeter进行压测的时候,使用Arthas诊断工具排查响应慢的接口
> 模拟了100个线程 执行的下单的操作,结果 接口响应时间最大超过了60秒,导致nginx直接报504响应超时。 首先调整了nginx的一些配置参数: ~~~ worker_processes 16; ~~~ http{}中添加: ~~~ fastcgi_connect_timeout 600; fastcgi_send_timeout 600; fastcgi_read_timeout 600; fastcgi_buffer_size 128k; fastcgi_buffers 8 128k; fastcgi_busy_buffers_size 256k; fastcgi_temp_file_write_size 256k; ~~~ API反向代理接口 把timeout时长加大: ~~~ location ~*/api { proxy_pass http://192.168.28.103:7011; #proxy_set_header Host $http_host; proxy_connect_timeout 70s; proxy_send_timeout 70s; proxy_read_timeout 70s; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; client_max_body_size 10m; rewrite "^/api/(.*)$" /$1 break; } ~~~ 调整后无果,70秒以内如果能响应出来结果 ,确实不报504了,但是仍然存在部分接口响应时长超过70秒,一味的增加响应时长也不是 最终解决办法,只能从接口代码下手。 通过使用阿里出品的`Arthas` ~~~ wget https://arthas.aliyun.com/arthas-boot.jar java -jar arthas-boot.jar ~~~ ~~~shell [root@localhost mydata]# java -jar arthas-boot.jar [INFO] JAVA_HOME: /usr/local/jdk1.8.0_311/jre [INFO] arthas-boot version: 3.6.7 [INFO] Process 24976 already using port 3658 [INFO] Process 24976 already using port 8563 [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER. * [1]: 24976 canteen-server-web-1.0.jar [2]: 28967 sync-server-web-1.0.0-RELEASE-20230227.jar ~~~ 输入1,选择监视canteen-server-web-1.0.jar这个服务的运行情况。 ~~~ [root@localhost mydata]# java -jar arthas-boot.jar [INFO] JAVA_HOME: /usr/local/jdk1.8.0_311/jre [INFO] arthas-boot version: 3.6.7 [INFO] Process 24976 already using port 3658 [INFO] Process 24976 already using port 8563 [INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER. * [1]: 24976 canteen-server-web-1.0.jar [2]: 28967 sync-server-web-1.0.0-RELEASE-20230227.jar 1 [INFO] arthas home: /root/.arthas/lib/3.6.7/arthas [INFO] The target process already listen port 3658, skip attach. [INFO] arthas-client connect 127.0.0.1 3658 ,---. ,------. ,--------.,--. ,--. ,---. ,---. / O \ | .--. ''--. .--'| '--' | / O \ ' .-' | .-. || '--'.' | | | .--. || .-. |`. `-. | | | || |\ \ | | | | | || | | |.-' | `--' `--'`--' '--' `--' `--' `--'`--' `--'`-----' wiki https://arthas.aliyun.com/doc tutorials https://arthas.aliyun.com/doc/arthas-tutorials.html version 3.6.7 main_class pid 24976 time 2023-04-12 10:53:26 [arthas@24976]$ ~~~~ 通过trace命令,进相应的方法进行追踪: >可以使用 trace命令 监控服务接口方法中调用的其它方法的耗时;trace 命令能主动搜索 class-pattern/method-pattern 对应的方法调用路径,渲染和统计整个调用链路上的所有性能开销和追踪调用链路。具体命令格式:trace [全限定类名][类中的方法名] ~~~ [arthas@24976]$ trace com.sgcc.canteen.service.impl.CtnGoodsServiceImpl inventoryReduction ~~~ - com.sgcc.canteen.service.impl.CtnGoodsServiceImpl 是完整的类名 - inventoryReduction是具体的方法名。 这个时候可以启动 jmeter压测工具,看最终的追踪结果 :  红色框内的两个方法就是 执行过慢的,进行代码中可以进一步 分析,对代码进行优化。 Arthas有很多命令可以用,trace只是其中一个,还有比如 `dashboard` 可以查看监控的面板:  其他用法自行百度或google。
superadmin
2023年4月12日 14:29
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
Markdown文件
分享
链接
类型
密码
更新密码