Profiler for a Grails Application - grails

Are there any tools that can identify the total memory usage, cpu, and other information on resources of a specific grails web application deployed in a Tomcat server?
Also, if my grails app is using Quartz plugin, can anyone tell me how to profile a specific job instance?
Thanks!

I am using a bunch of tools for profiling and monitoring my own grails application. Here are the plugins/tools that help me to achieve this and work without any problems:
JavaMelody plugin : this tool is a must-have. Just install the plugin and go to /myapp/monitoring and you're done. You'll get all information you need on cpu, mem usage, sql queries, http errors...It should be enough for your needs described in your question
Application Info plugin : this very recent plugin is very useful and almost indispensable. It gives you various info about your application status. For your concerns, you will have access to graphs describing memory usage, information about sessions (opened or closed), detailed information on every aspect of your hibernate layer (cache, tables, entities...). Above all, this plugin is developped and supported by Burt Beckwith, member of SpringSource team.
Perf4j plugin : This plugin helps you collecting performance statistics with minimal effort. I am using it but it has better use whe tuning your application
You can also use other plugins/tools like : p6spy (for logging of SQL queries), Grails Audit Logging plugin (for tracking changes of domain objects) or Profiler plugin for which I can guarantee that they work correctly (not the case for all plugins!).
All of these plugins you can find by tag performance in Grails plugins portal
I hope it helps.

Here is some useful articles about performance tuning:
Tune the performance of Grails apps
GR8Conf 2011: Tuning Grails Applications by Peter Ledbrook
Profiling Grails Applications With VisualVM

http://grails.org/Profiler+Plugin

The profiler plugin that MTH mentions only gives you timing info for various parts of the Grails app. For monitoring resource usage, you're better off using JMX; here are a couple of links that should help.
Tomcat monitoring with JMX
Grails JMX plugin

Related

"OutOfMemoryError: PermGen space" with Grails webapps

Our team has been working with Grails (version 2.3.5) for a little under a year now, and the delivery team managing our servers has little to no experience related to applications written in Grails.
We have several Tomcat 7 instances, both in the test and production environments, with a certain amount of webapps. While some of the instances only containing webapps developed in Java (w/ Spring, Hibernate) sometimes get up to something like 20 contexts with no major issue, it seems like anything past 6 Grails applications (applications much similar to their Java counterparts) starts regularly causing the dreaded PermGen space issue.
The PermGen allocated is currently 536Mb, and the delivery team obviously suggests either using a separate instance for the new applications, or increasing the allocated memory; at the same time they are urging us to verify how these few apps are saturating the memory.
Our impression is that this is normal with Grails apps, but not having any senior Grails developer we have no way to confirm it from experience or better knowledge.
Is 536Mb too little allocated space in PermGen for 8 "regular" Grails webapps?
Update:
To specify what I mean by "regular", these are all couples of front-end + back-end for different services, where the front-end has nothing much more than a list of requests, a wizard to go from zero to a completed request, validates data, persists it, calls a webservice to get a protocol number, and in a couple cases calls an external payment gateway.
The back-end is used to manage requests and performs similar operations.
Every app has maybe around 20 entities with respective controllers, services, and views, and on top of that we have a few classes to handle security w/ Spring Security and an external infrastructure.
That's how it is. You have basically two options.
Migrate on Java 8 (see http://www.infoq.com/articles/Java-PERMGEN-Removed)
Increase the PermGen space further.
And a quick background. Unlike regular Java with Spring, Groovy and Grails generate quite a lot of classes in the runtime (GSPs being one example). Groovy also generate huge amount of classes itself - each closure is a class. All this put pressure on the permgen.
To ease off the pressure get rid of all unnecessary plugins, consolidate GSPs, rethink closures, use AOP only when absolutely needed etc.
We used to have similar problems, so our team started using one tomcat per app. We also separated credentials from security purposes. Now it's easier to manage them, monitor logs and make periodical updates.
Hint: it's easier (imho and cleaner) to train your admin in creating users, home_dirs with tomcats instances and just providing credentials.

Process Monitor > Name Not Found for I/O > Grails Application

I'm trying to speedup the startup of a grails 2.3.7 application.
Part of this has been to move stuff over to a RamDrive and start the project and inteli-j from there.
I have noticed though that grails tries to read many files, and in many cases these files are not there or the path is not there.
It seems very hectic and disorganized.
Does anyone have any idea how to improve and avoid these redundant and inefficient system calls as well as how to speedup startup?
Is it a matter of grails itself or the specific plugins being included?
Picture available at screenshot as well.
Additionally, below please find the graphs for the various operations performed during startup. Unfortunately the CPU usage is never up to 100% meaning grails startup may not be optimized to use all cores.

performance counters tips for server

I have an mvc4 application that communicates to my sql server database via a wcf layer. Each layer is co located on the same server with the database located on a different server.
I am seeing CPU issues on my server which holds the applications, in particular with my mvc4 application. The server is windows server 2008 R2¬ running IIS7.5.
I would like to put some performance counters on my server to analyze where the problem on the server may be and is causing the high cpu problems.
I am new to setting up such and looking for pointers as to what counters to set up that may assist me, how I should analyze and best plan in gaining more knowledge on such.
Performance counters are generally good for production monitoring. On dev environnement (and I suppose you are at this stage), there are many profiling tools & apis.
On Sql Server
The best tool is Sql Server Profiler. You can find and diagnose slow-running queries by capturing all Transact-SQL statements and/or Sql Server Events.
On Asp.net MVC
I highly suggest you install a profiler like asp.net mini-profiler or Glimpse. When browsing you website, this will tell you which controller/action/partial/ajax is slow and sometimes why.
Visual Studio includes a Profiler. This let you measure, evaluate, and target performance-related issues in your code. It's fully integrated into the IDE. Once you have ran a performance session, several reports are available to help visualize and detect performance issues from the data gathered.
If you can't find why, you could run a load test using Visual Studio Web & Load Tests. You will rarely have performance issues for a single user, but for many concurrent users it's not generally the case.

Grails app performance degrades over time

I have noticed that after my Grails app has been deployed for about 2 weeks, performance degrades significantly, and I have to redeploy. I am using the Spring Security plugin and caching users. My first inclination is that it has something to do with this and the session cache size, but I'm not sure how to go about verifying this.
Does it sound like I'm on the right track? Has anyone else experienced this and narrowed down the problem? Any help would be great.
Thanks!
Never guess where to optimize, it's going to be wrong.
Get a heap dump and a profile it a little (VisualVM worked fine for me).
It might be a memory leak, like it happened to me. What is your environment - OS, webserver, Grails?
I would recommend getting YourKit (VisualVM has limited information) and use this to profile your application in production (if possible).
Alternatively you could create a performance test (with JMeter for example) and performance test the pieces of your application that you suspect is causing the performance degredation.
Monitoring memory,cpu,threads,gc and such while running some simple JMeter performance tests will definitely find the culprit. This way you can easily re-test your system over time and see if you have incorporated new "performance killing" bugs.
Performance testing tools/services:
JMeter
Grinder
Selenium (Can performance test with selenium grid, need hw though)
Browsermob (Commercial, which uses Selenium + Selenium-Grid)
NeoLoad by NeoTys (Commercial, trial version available)
HP Loadrunner (Commercial, The big fish on the market, trial version available)
I'd also look into installing the app-info plugin and turning on a bunch of the options (especially around hibernate) to see if things are getting out of control there. Could be something that's filling the hibernate session but never closing a transaction.
Another area to look at is if you're doing anything with the groovy template engine. That has a known memory leak, that's sort of unfixable if you're not caching the class/results. Recently fixed a problem around this on our app. If you're seeing any perm gen errors, this could be the case.
Try to install Javamelody plugin. In our case it helped to find problem with GC.

Monitor Multiple Rails Applications

Are there any tools that I can run on my server to monitor multiple rails applications?
I need to monitor the number of requests each application receives, how much memory each application is using, how much of the cpu is being used and other stats similar to those. I need to see the stats for each individual rails application.
I recommend you try NewRelic RPM.
The free version:
RPM Lite is the most widely used
solution for basic web application
monitoring. RPM Lite provides
application monitoring for unlimited
Java, Ruby or JRuby applications, for
unlimited users, for an unlimited
time. What a deal! With RPM Lite you
can identify overall app health, app
response time, throughput, Apdex SLA
scoring, cluster breakdown, and Notes.
You can also see where web
transactions are spending the most
time, isolate the worst offenders, and
determine where to focus your
remediation efforts
Later edit:
An alternative to NewRelic RPM is ScoutApp, that has a lot of plugins covering all your required features.
If you need something that can be run on your server, there is also the munin plugins gem that you may try. If you need a users monitoring tools (kind of like Google Analytics)m you can use the RailStat gem.
The Request Log Analyzer gem can be useful, is free, and works by analyzing Rails log files. Thus, there's no chance of it having any negative impact on your application's performance.

Resources