Preslav Rachev
Preslav Rachev

Reputation: 4003

Stuck on a Spring performance issue

I am kind of stuck on an issue. I have a Spring + Hibernate app, which for the last few days has been behaving really strange.

Normally, even on Debug mode, it bootstrapped for around 15 seconds.

As of a couple of days, without any significant errors or problems being shown, it started running twice, if not three times as slowly.

I thought maybe the problem was in Tomcat, but even when I ran the series of unit tests which I've written, they went amazingly slow (we are talking 8+ sec on a test + 20sec for the initial context bootstrapping). I use a local PostgreSQL database for the tests which is normally not so bad (around one second on a test)

I am stuck. I know that the last thing I did was to add support for @Transactional on my @Controller classes. Could this be the reason? I doubt, because when I deployed the transactional modifications to the stable server and restarted it, it ran just as fast as before.

I am completely stuck

Upvotes: 0

Views: 216

Answers (3)

kukudas
kukudas

Reputation: 4934

Maybe profiling will help you to gain more information. There is a nice tool which comes shipped with JDK called jvisualvm (you can find it within the bin folder of your jdk installation). It's pretty much self explanory. You can connect to you applciation and start sampeling.

Upvotes: 0

Eran Harel
Eran Harel

Reputation: 2365

My guess is that your DB is the root cause for this.

Probably you have some query that is taking longer than it used to due to data size growth, schema changes, or the like.

Here are some tips:

  • Try to check the startup logs to see what seems to be slower.
  • Can you try to start an older version of the app, and see if it's faster?
  • Can you see which tests are slower now?

Upvotes: 1

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340743

You are aware that based on your description we can only guess. Obviously if you are using , build times of subsequent builds will reveal which code change could be the reason. If you identify the code, diagnosing will be much simpler.

Chances are it wasn't really caused by code change but by the environment change. E.g.:

  • Spring fetches some external resource on bootstrap (XML schemas, DTDs, etc.)
  • there is some extra network overhead (router/switch reconfiguration, firewall)
  • Database is fragmented or somehow slow. Try vacuuming

Investigating:

  • Capture few stack traces during bootstrap. No need for full-blown profiling, I bet there is a single blocking/waiting operation slowing things down
  • Enable every logging statement you can. Every. Investigate which pieces of your application are slow.

Upvotes: 2

Related Questions