7 Java Performance Metrics to Watch After a Major Release
After those major releases, you need to keep track of several metrics. Here are the most important Java performance metrics to watch, including response time, and load average.
Join the DZone community and get the full member experience.Join For Free
the java performance metrics you need to follow for understanding how your application behaves in production.
unlike the days when software used to be shipped in boxes and there was no way of knowing how it will perform in production, today almost any metric you can think of can be tracked down and reported. the problems we’re now dealing with are coming from information overload and scale, rather than not having enough information. with tens or hundreds of servers at play, this becomes even harder to keep track of. one thing that remained from those boxed software days are logs, which stayed pretty much the same for over 20 years now. most developers still depend on those for insights into their production systems, but now they’re gradually being replaced.
for this post we’ve decided to gather some of the most insightful metrics you can follow to understand how your application behaves in production, without relying on log files in any way. aside from external factors like user loads (or… aws downtime), new deployments are probably the most common influence on how java performance indicators behave. so following up on them becomes even more critical right at those sensitive times following new deployments.
if it has numbers in it, then it must be true!
before we move on to discussing each metric, let’s highlight one major caveat. there’s this notion that if you back yourself with data, then you must be right. the problem here is that it’s really easy to misrepresent data. much easier than to prove it wrong when presented to you. let’s distinguish here between measures coming from looking at simple time-series data, seeing how a certain basic metric behaves over time, versus looking at the data from a different angle and keeping your performance percentiles in check. the bottom line is that we need to be mindful to the impact of the metrics we care about, and have some sanity check to assess them.
for example, say we’re looking at median / 50th percentile transaction response time. a popular indicator that many companies use as one of their main kpis. in practice, when a single pageview has tens or more of these requests (usually well over 40), it means that the user is 99.999…% likely to experience a result worse than the median (it’s simple math: 1 – (0.5 ^ 40)). so which percentile does it make sense to focus on? even if we’re looking at the 95th percentile, since you probably have well over 40 requests per page, most of your users will experience a response even worse than that. multiply over several pageviews, and it gets even tougher. to read more about percentiles and just how misleading data, check out gil tene’s blog right here .
now, let’s take a closer look at our metrics of choice, see exactly what do they stand for, and how you can get a hold of them:
1. response times and throughput
the application response time measures how long does it take for the transactions in your application to complete. it can also be looked at from the http requests level, or say, the database level. allowing you to narrow down on the slowest queries that may need some help with optimization. the throughput indicator looks at transactions from another angle, and displays how many requests your application is processing at any given time, usually per minute (rpm).
one way to measure this is using apms like new relic or appdynamics (which we compared head to head on a previous blog post ). on these kind of tools you can follow up on the average response time and compare it to that of yesterday’s or last week’s straight from the main reporting dashboard. this helps us see how new deployments affect our application’s health. another view allows you to look at the web transaction percentiles, measuring how long does it take to http requests to complete.
it’s also possible to monitor this in-house, but may require hard coding, like sending out data with dropwizard metrics and publishing it to graphite. it seems though that the most useful insights come when you correlate this data with other metrics. more on that in the following measures we’re covering here.
takeaway #1: make sure the collection methods you use allow you to look at the data from different angles and get down to the percentile level.
tools to check:
2. new relic
web transaction percentiles and throughput reporting in new relic
2. load average
the second metric we extensively follow is the load average on our servers. load average is a metric that’s traditionally divided to 3, showing its result for the last 1, 5 and 15 minutes (left to right). as long as your score is under the number of cores your machine has – you’re in the clear. once it goes over the number of cores. it means your machine is under stress.
beyond the simple measure of cpu utilization, load average takes into account how many processes each core has in its queue. a state where a core is 100% utilized, but will soon finish up with a task, versus a state where it has 6 more tasks in the queue is quite different. cpu utilization alone doesn’t cover that, but load average takes the bigger picture into account.
an awesome way to follow up on your server load average on linux is with htop by hisham muhammad . great colorful and live visualization that makes your command line feel much like a nasa dashboard
takeaway #2: utilization of a resource is not enough to determine its load, you need to be mindful of the tasks in its queue to be fully informed.
tools to check:
running htop to examine the loads on one of our servers, load average appears on the top right
3. error rates (and how to solve them)
there are several different ways to look at error rates, and most developers go with the high level metrics – looking at error rates at the whole application level, total failed http transactions out of the overall http requests for instance. but there’s an often overlooked in-depth layer to this with immediate implications for your application health: error rates for specific transactions. showing the number of times a certain method in your code fails and produces a logged error or exception out of the overall times it has been called.
error rate breakdown by specific events in takipi, narrowing down on the root cause for a peak in error volume
but this data doesn’t mean much on its own, right? the second step after prioritizing the most urgent events that you should address, be it logged errors or exceptions, is to get down to their real root cause and fix them. and we’ve built a solution to this problem as well. with takipi in play, you don’t need to pull up log files and start looking for clues. all the information about the state of the server is accessible from the same screen. this includes the stack trace, the actual source code, and the variable values, across multiple instances of each faulty call.
takeaway #3: high level data is not enough to get down to the real root cause of increased error rates. you need to favor collection methods that produce the richest data about the metrics you care about.
tools to check:
zooming on the error analysis down to the specific variables that caused each error
4. gc rate and pause duration
a misbehaving garbage collector is one of the main reason that can cause your application throughput and response time to take a deep dive. so when digging in to find the cause for these symptoms, a common resolution would be that the application was in the middle of a stop the world gc pause. to learn more about the process of optimizing garbage collection and its associated metrics you can check out this post we published around solution strategies for gc issues .
the key to understanding the frequency and duration of gc pauses goes through analyzing gc log files. it’s not a metric you can get out of the box without analyzing it on your own, or using tools like jclarity. to analyze this you’ll need to make sure to turn on gc log collection with the appropriate jvm arguments.
takeaway #4: keep in mind to have a broad view correlate the data between different metrics to see how they affect each other.
tools to check:
1. jclarity censum
5. business metrics
the performance of your application doesn’t solely depend on how fast it responds, and neither on its error rate. the flipside is business metrics, and the responsibility for those is not at the hands of the product / sales people only. measures like revenue, user counts, and interactions with specific areas of your application are critical for understanding how it performs. having those side by side with the timestamps of new deployment is important to see how the fixes and new features you deploy impact the bottom line in terms of the business. hopefully for the better of course, but if it goes for the worse – it’s super easy to know what needs fixing once you have all your data in one place.
moreover, the ability to tie those business metrics, in real time, together with data about error rates and latency, is extremely powerful. this allows you to drill down to understand exactly which error or exception is causing you the most trouble, so you can prioritize them by their impact on business goals. making sense of all the exceptions and log errors that are flying around. the way to do to this is using monitoring tools that are open to integrations and play well with the other kids in the neighborhood. this is why it’s super important to keep all data open and have the option to export it to our service of choice.
say you’re using graphite to centralize the business metrics that you’re reporting on, you’ll need the tool you’re using to be open to sending data to it. for example, the way our engineering team enabled this is by opening the metrics we report on to publishing through statsd , so they can be then directed to any reporting dashboard our users choose to use.
takeaway #5: siloed data is a thing of the past. the methods you choose to pull metrics by should also let you correlate it with data from different sources.
tools to check:
2. the elk stack
6. uptime and service health
this one metric sets the tone for the whole shebang. beyond using it as an alerting medium, it also lets you define your slas over time. seeing what percent of the time you’re providing a fully functioning service to your users.
the way we follow up on this is through a health check we run with a single servlet using pingdom. the check looks into all of the services that take part in the transactions in our application, including the database and s3.
takeaway #6: uptime might be a binary indicator but there’s a lot of value in looking at in an aggregate matter to locate the weak spots in your stack.
tools to check:
monitoring uptime and application health in pingdom
7. log size
all the metrics we’ve discussed so far skip logging altogether, well, except for gc logs. but we still can’t ignore logs altogether. a side effect of logs is that they never stop growing. if you don’t keep an eye on their size and the process you have in place for keeping them in check – bad things can happen. when logs get loose, hard drives cry. your server start filling up with junk, and everything slows down. so it’s important to keep a close eye on them. it’s a neverending source of havoc.
the most popular solution approach is partitioning the logs on the server using services like logstash and sending them out to storage with splunk, elk, other log management tools , or plain storage on s3 for example. another way could be just to rollover or truncate them at some point, but then we’re risking information loss since like most developers, we haven’t cut our dependence on logs just yet.
takeaway #7: logs are a huge pain, especially since you’re being charged by the gbs if you’re having some external service take care of them for you. it’s time to rethink the problem and start reducing log sizes.
we see a trend in how data collection from applications in production is slowly moving away from complete reliance on log files. the new world of software analytics is more open, with smarter data that goes beyond plain numbers and holds rich contextual information. it’s exciting to to see how will it all turn out, and we look forward to building this new future together with you.
Published at DZone with permission of Alex Zhitnitsky, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.