2

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. 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. 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. 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. 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.

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.

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!

kumetix
  • 1,032
  • 1
  • 12
  • 18

3 Answers3

2

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.

There is free and premium (where the free is a very good offer)

Highly recommended to check that out.

Nir

Nir Sagiv
  • 165
  • 3
  • 13
2

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. in my experience JVIsualVM was usually good enough.

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)

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)

2

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.

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). 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.

Community
  • 1
  • 1
Ralph
  • 118,862
  • 56
  • 287
  • 383