微服务场景下性能问题排查神器之xrebel「建议收藏」

idea (31) 2023-03-24 22:20

大家好,我是编程小6,很高兴遇见你,有问题可以及时留言哦。

对于java应用性能跟踪其实有很多种手段,本文只是针对xrebel的使用做一些简单讲解(单体应用微服务应用)。分布式跟踪有很多,比如zipkin等,详见 分布式跟踪系统(一):Zipkin的背景和设计,但是太重了,不适合小规模团队,开发时期用。

而且以zipkin为例,仅仅是A服务调用B服务耗时多少,并不会显示详细的线程,堆栈信息。需要搭配其他手段进行排查。

示例:

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第1张

下载xrebel

目前最新版本 xrebel-3.4.1.zip

xrebel 支持的框架及场景

快速安装

xrebel支持eclipse和idea,同时有eclipse插件,建议使用独立方式安装。

  1. 下载xrebel.zip 并解压到本地,e.g. D:\xrebel
  2. 在tomcat也好,idea,eclipse也好,修改vm 参数,添加 -javaagent:[path/to/xrebel]/xrebel.jar

下面分别是idea,eclipse

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第2张

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第3张

默认是可以试用14天的,建议支持正版,毕竟大家都是吃这行饭的。而且 xrebel jrebel jrebel for android 给你省的时间,绝对值这个价。 jrebel有个免费的社区计划 my.jrebel.com/

web ui

打开 web 服务页面,xrebel会直接注入到你的页面中,左下角会出现 xrebeltoolbar,(e.g. http://localhost:8080)

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第4张

或者通过 访问服务/xrebel (e.g. http://localhost:8080/xrebel) 打开单独页面,适用于webservice,restful 等无页面场景

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第5张

如果不想注入到页面中,只想通过服务/xrebel访问,则可以添加 -Dxrebel.injection=true|false ,默认为true

其余开关参数 参见 XRebel launch parameters

xrebel 简单使用教程

参考 Using XRebel

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第6张

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第7张

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第8张

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第9张

微服务

参考 Microservices 和 XRebel 3.0: introducing microservices profiling

确保调用方,和被调用方,都开了xrebel,

效果如下

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第1张

启用xrebel调试

参考 Debugging with XRebel enabled

题外话 静态资源分离的必要性

为嘛建议将静态文件分离?通过xrebel就可以清晰看出来

微服务场景下性能问题排查神器之xrebel「建议收藏」_https://bianchenghao6.com/blog_idea_第11张

博客
anjia.ml/2017/11/21/…

掘金
微服务场景下性能问题排查神器之xrebel

简书
www.jianshu.com/p/0029c32dd…

发表回复