微服務場景下性能問題排查神器之xrebel

對於java應用性能跟蹤其實有不少種手段,本文只是針對xrebel的使用作一些簡單講解(單體應用微服務應用)。分佈式跟蹤有不少,好比zipkin等,詳見 分佈式跟蹤系統(一):Zipkin的背景和設計,可是過重了,不適合小規模團隊,開發時期用。html

並且以zipkin爲例,僅僅是A服務調用B服務耗時多少,並不會顯示詳細的線程,堆棧信息。須要搭配其餘手段進行排查。java

示例:android

下載xrebel

目前最新版本 xrebel-3.4.1.zipweb

xrebel 支持的框架及場景

快速安裝

xrebel支持eclipse和idea,同時有eclipse插件,建議使用獨立方式安裝。tomcat

  1. 下載xrebel.zip 並解壓到本地,e.g. D:\xrebel
  2. 在tomcat也好,idea,eclipse也好,修改vm 參數,添加 -javaagent:[path/to/xrebel]/xrebel.jar

下面分別是idea,eclipserestful

默認是能夠試用14天的,建議支持正版,畢竟你們都是吃這行飯的。並且 xrebel jrebel jrebel for android 給你省的時間,絕對值這個價。 jrebel有個免費的社區計劃 my.jrebel.com/框架

web ui

打開 web 服務頁面,xrebel會直接注入到你的頁面中,左下角會出現 xrebeltoolbar,(e.g. http://localhost:8080)eclipse

或者經過 訪問服務/xrebel (e.g. http://localhost:8080/xrebel) 打開單獨頁面,適用於webservice,restful 等無頁面場景分佈式

若是不想注入到頁面中,只想經過服務/xrebel訪問,則能夠添加 -Dxrebel.injection=true|false ,默認爲trueide

其他開關參數 參見 XRebel launch parameters

xrebel 簡單使用教程

參考 Using XRebel




微服務

參考 MicroservicesXRebel 3.0: introducing microservices profiling

確保調用方,和被調用方,都開了xrebel,

效果以下

啓用xrebel調試

參考 Debugging with XRebel enabled

題外話 靜態資源分離的必要性

爲嘛建議將靜態文件分離?經過xrebel就能夠清晰看出來


博客 anjia.ml/2017/11/21/…
掘金 juejin.im/post/5a13e3…
簡書 www.jianshu.com/p/0029c32dd…
相關文章
相關標籤/搜索