简体   繁体   English

基准测试方法拦截的框架

[英]framework for method interception for benchmark measurement

before I rush into writing such framework, I would like to know if anyone have encountered or developed such framework. 在我急着编写这样的框架之前,我想知道是否有人遇到或开发过这样的框架。

We've reached a point in our project where focus is on performance improvement. 我们已经在项目中达到了将重点放在性能改善上的地步。 I'm the owner of a spring RESTful microservice, where there are Controllers, delegating to Services, which use spring Repositories. 我是spring RESTful微服务的所有者,那里有控制器,委托给使用spring仓库的Services。 quite standard, nothing special. 很标准,没什么特别的。

Here's what I would like to be able to do. 这就是我想要做的。 I don't want to annotate the methods I measure, neither do I want to add explicit timer calls at the beginning and ending of the methods I would like to check. 我不想注释我测量的方法,也不想在要检查的方法的开头和结尾添加显式的计时器调用。 The code is "dirty" enough as it is with log prints. 该代码足够“脏”,就像日志打印一样。

What I would like to be able to do is to list the methods to be measured in an external configuration file, and with the help of spring have them intercepted and measured. 我想做的是在外部配置文件中列出要测量的方法,并借助spring对其进行拦截和测量。 benchmarks will be collected for different methods in production/evaluation environment. 将针对生产/评估环境中的不同方法收集基准。 Later I would like to have a UI which will visualize the different results of each method. 稍后,我希望有一个UI可视化每种方法的不同结果。 in this UI I could spot the anomalies, the times where the invocation took the longest, or took the shortest. 在此用户界面中,我可以发现异常情况,即调用时间最长或时间最短的时间。 From there I could drill down into the services layer, spotting the soft points in my services, and from there into the poor performing queries invoked by the repositories. 从那里,我可以深入到服务层,发现服务中的软点,然后从那里到存储库调用的性能低下的查询。

In the absence of a designated tool (I refuse to believe there aren't at least hundred available) my plan is to use Spring AOP or AspectJ to intercept the methods I had listed. 在没有指定工具的情况下(我拒绝相信至少没有一百种可用的工具),我的计划是使用Spring AOP或AspectJ来拦截我列出的方法。 In each interception I'll place a log print of the invocation benchmark. 在每次拦截中,我都会记录调用基准的日志。 Later on I'll harness Kibana to spot the soft points of each method and then drill down. 稍后,我将利用Kibana找出每种方法的要点,然后进行深入研究。

I still need to learn the implementation details of how the aspect is done, and also how exactly set up the data visualization using kibana for the sake of that goal. 我仍然需要学习方面的实现细节,以及为实现该目标如何使用kibana精确设置数据可视化。

If anyone can shad some light - offer a framework suitable for my needs, or some experience or code to help with my goal, or maybe offer an alternative or another way to do these tests, I would like to hear about it with great appreciation! 如果有人能提供一些帮助-提供适合我需要的框架,或者提供一些经验或代码来帮助实现我的目标,或者提供替代或另一种方式来进行这些测试,我想非常感激! thanks a head! 谢谢头!

Its not really a code solution but did you tried to use NewRelic ( http://newrelic.com ) in a very easy installation with very low finger print from Memory and CPU the monitor your app servers and gives you a very good dashboard to look at. 它不是真正的代码解决方案,但您是否尝试过在非常简单的安装中使用NewRelic( http://newrelic.com ),并且内存和CPU的指纹非常低,因此可以监控应用程序服务器,并为您提供了一个非常好的仪表板外观在。

There is free and premium (where the free is a very good offer) 有免费和高级(其中免费是一个很好的报价)

Highly recommended to check that out. 强烈建议您检查一下。

Nir 尼尔

It depends if you are trying to profile a production environment or a dedicated one. 这取决于您是要描述生产环境还是专用环境。

in case of a dedicated env you can use profilers such as YourKit / JProfiler or the JDK builtin JVisualVM that gives the basics capabilities. 如果是专用环境,则可以使用分析器,例如YourKit / JProfiler或内置了基本功能的JDK内置JVisualVM。 in my experience JVIsualVM was usually good enough. 以我的经验,JVIsualVM通常足够好。

On production you need a low footprint so you can use hprof in "sample" mode (so it won't instrument all method calls) and later analyse the hprof file using a profiler (the ones I mentioned above or any other) 在生产中,您需要的空间很小 ,因此可以在“采样”模式下使用hprof (这样就不会检测所有方法调用),以后再使用探查器(我上面提到的探查器或其他任何探查器)分析hprof文件。

And one more thing that I would consider is BTrace - allowing dynamic instrumentation on JVM - I found it very useful for investigating issues on production env (not just profiling) 我还要考虑的另一件事是BTrace-允许在JVM上进行动态检测-我发现它对于调查生产环境中的问题(不仅仅是概要分析)非常有用

Spring-Boot / Spring-Boot-Actuator has some simple profiling measurements build in (how long does it take to handle a request). 弹簧启动/弹簧启动-执行器有一些简单的分析测量, 建立 (它需要多长时间来处理请求)。 It is based on the Metrics framework . 它基于Metrics框架

Maybe you should have a look at this short you tube video: Spring Boot Actuator endpoints , about some Spring-Boot-Actuator features (in Minute 2:03 it shows the metric I am talking about). 也许您应该看一下这段简短的视频: Spring Boot Actuator端点 ,有关一些Spring-Boot-Actuator功能(在分钟2:03中,它显示了我正在谈论的指标)。 If this is enough for you then you maybe have a look at this question and answer: Spring Boot Actuator without Spring Boot - they discuss how to use Actuator without Boot. 如果您足够这样做,那么您可以查看以下问题和答案: 不带Spring Boot的Spring Boot执行器 -他们讨论如何使用不带Boot的执行器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM