<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: FusionReactor</title>
    <description>The latest articles on DEV Community by FusionReactor (@fusion_reactor).</description>
    <link>https://dev.to/fusion_reactor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F391732%2F0fa14bc1-5b3f-4142-b34a-69c024eb8485.jpeg</url>
      <title>DEV Community: FusionReactor</title>
      <link>https://dev.to/fusion_reactor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fusion_reactor"/>
    <language>en</language>
    <item>
      <title>Why are multithreading and multiprocessing used?</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Tue, 09 Feb 2021 15:01:50 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/why-are-multithreading-and-multiprocessing-used-3c3n</link>
      <guid>https://dev.to/fusion_reactor/why-are-multithreading-and-multiprocessing-used-3c3n</guid>
      <description>&lt;h2&gt;Why are multithreading and multiprocessing used?&lt;/h2&gt;

&lt;p&gt;&lt;span&gt;Simultaneously executing programming tasks before now had always been daunting. But today, many programming languages support Multithreading and Multiprocessing, which aids concurrent execution of code.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Multithreading and Multiprocessing solve this problem by providing a technique whereby different tasks can be managed simultaneously from a central system. However, as progressive as these techniques are, they are not all-encompassing as they both have their limitations and advantages over each other.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Hence, it is critically necessary for you to know each of them’s limitations to aid your focus. Some of such critical areas include; The number of threads available when the code is running. Also, the duration and number of tasks that are being executed.  All these and many more will be addressed while accessing the multi-threading process and multi-processing. The previous article highlighted a high overview of what&lt;/span&gt;&lt;a href="https://www.nerd.vision/post/multithreading-and-multiprocessing"&gt; &lt;span&gt;Multithreading and Multiprocessing&lt;/span&gt;&lt;/a&gt;&lt;span&gt; are and how they help developers.&lt;/span&gt;&lt;/p&gt;


&lt;h1&gt;&lt;span&gt;What is Multithreading?&lt;/span&gt;&lt;/h1&gt;

&lt;p&gt;&lt;span&gt;Multithreading is an operating system’s capacity to monitor its use by more than one user and handle multiple requests by the same user without running numerous copies of programming on the computer. As the name implies, Multithreading utilizes threads that are individual lines of codes or execution units in the computer system to execute multiple tasks concurrently. These threads share the resources of a single core or a core in a numerous core operating system, including the computing units, the CPU caches, and the translation lookaside buffer (TLB).&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;This concurrence cumulates into a system processing technique that is fast, reliable, and efficient. It achieves this in the following ways:&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Resource Sharing: multithreading processes share resources via: ‘message passing’ and ‘shared memory.’ Most languages allow threads to share memory and resources of the process they belong to by default.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Economic: Multithreading is a time and energy-efficient technique in programming. The allocation of pooled memory and resources to different threads in the same process limits the time, space, and resources needed to execute a task.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Scalability: Multithreading increases parallelism as the threads can be distributed over a series of processors to scale, dividing the processes into smaller tasks.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Responsiveness: Multithreading provides better interaction with the user as it allows a program to continue running irrespective of whether a part of it is blocked or performing a lengthier operation.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;As advantageous as the multithreading technique presents itself, it is not without its limitations. First, memory and resources are shared, affecting the threads’ safety as the concurrence can make the data from one into the other. Another issue to look out for is deadlocking. Here two threads wait to complete their operation, and this delay usually results in the program failing. For these situations, it is important to have tools in place (such as&lt;/span&gt;&lt;a href="https://fusion-reactor.com"&gt; &lt;span&gt;FusionReactor&lt;/span&gt;&lt;/a&gt;&lt;span&gt;) to alert you to these situations.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Finally, it could result in a ‘race condition’ where two threads simultaneously access a shared variable. The first thread reads the variable, and the second thread reads the same value from the variable. There is Thread A for reading operation and Thread B for writing operation in word processing. They both attempt these operations simultaneously, and Thread B writes before Thread A could carry out the read operation, Thread A would fail to receive the file’s updated value in use.&lt;/span&gt;&lt;/p&gt;


&lt;h2&gt;&lt;span&gt;What is Multiprocessing? &lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span&gt;This technique, also referred to as process forking, inherently alleviates these problems that Multithreading poses as a computer can use two or more processors for operations.  Unlike Multithreading, Multiprocessing utilizes a particular program for each task, thereby using more memory and resources. It shares the processes and resources dynamically among the processors in a CPU.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;This fact comparatively gives Multiprocessing an advantage as there can be no data corruption, deadlocking, or race condition. For clarity, the benefits of Multiprocessing are, but not limited to:&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Multiprocessing is cost-efficient, unlike single processor systems, as it shares peripherals and power supplies.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;It can be used when very high speed is required to process a large volume of data.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Takes advantage of multiple CPUs &amp;amp; cores.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;However, this technique, as good as it sounds, is not without its limitations, which are:&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;IPC (Inter-Process Communication) can be more involved with more overhead required.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;It has a larger memory footprint.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;&lt;span&gt;Definitions of Multithreading and Multiprocessing&lt;/span&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span&gt;A multiprocessing system has more than two processors, whereas Multithreading is a program execution technique that allows a single process to have multiple code segments.&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Multiprocessing improves the system’s reliability, while in the multithreading process, each thread runs parallel to each other.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;In Multiprocessing, creating a process is slow and resource-specific, whereas, in Multiprogramming, creating a thread is economical in time and resource.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;&lt;span&gt;Multithreading or Multiprocessing &lt;/span&gt;&lt;/h1&gt;

&lt;p&gt;&lt;span&gt;There is a bit of leeway to both multithreading and multiprocessing, in the two cases, they can be utilized to improve the performance and quality of applications. There are numerous considerations to deciding what is the best choice for the application. Ultimately there is no better way, each approach has preferences and difficulties and will rely upon the workload of the application deciding which approach is ideal. &lt;/span&gt;&lt;/p&gt;



&lt;br&gt;

</description>
      <category>multithreading</category>
      <category>multiprocessing</category>
    </item>
    <item>
      <title>Why Load Test ColdFusion Apps (4 Reasons)</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Tue, 02 Feb 2021 10:09:48 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/why-load-test-coldfusion-apps-4-reasons-447n</link>
      <guid>https://dev.to/fusion_reactor/why-load-test-coldfusion-apps-4-reasons-447n</guid>
      <description>&lt;p&gt;&lt;span&gt;Let’s make sure that your new ColdFusion app doesn’t crash immediately after launch – by effective load testing.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;In this article, we will look at 4 reasons why load test ColdFusion Apps. You will learn:&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Why do you need to load test?&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;How to Easily Load Test and Make it a Routine&lt;/span&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;span&gt; Pick a load testing tool&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt; Write testing scripts that simulate real life&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt; Assess the results of the test&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt; Rinse and repeat your tests and fixes&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;span&gt;The Long-term Benefits of Load Testing&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;About the Author&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;If you don’t plan ahead with load testing when too many users hit your newborn app at the same time, then it can become &lt;/span&gt;&lt;b&gt;very slow or even crash your CF server&lt;/b&gt;&lt;span&gt;. Leading to upset users, lost revenue for your company, and serious egg on the faces of everyone in your IT department. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;In performance tuning circles, we call it “&lt;/span&gt;&lt;b&gt;The Wall&lt;/b&gt;&lt;span&gt;”. It’s hard to see it coming. But you’ll know when you’ve hit it.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;span&gt;“The Wall, in web applications, is that perfect storm of occurrences that suddenly, and within seconds, brings a web application to its knees. It is almost always caused by one thing: a stacking up of all available ColdFusion application threads. Which to be fair, is preceded, rather quickly, with a slow down in performance. &lt;/span&gt;&lt;/i&gt;&lt;/p&gt;

&lt;p&gt;&lt;i&gt;&lt;span&gt;There can be many reasons, a successful marketing campaign, a major event, an unexpectedly successful launch. Whatever the cause, it is possible to architect and build infrastructure that can cope with any load”&lt;/span&gt;&lt;/i&gt;&lt;span&gt; – my colleague Mike Brunt (CF performance expert) &lt;/span&gt;&lt;a href="http://www.cfwhisperer.com/post.cfm/the-wall-ouch" rel="noopener noreferrer"&gt;&lt;span&gt;says&lt;/span&gt;&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span id="Why-Do-You-Need-To-Load-Test-?"&gt;It’s a wall similar to the one faced by marathon runners. It’s when your body decides to call it quits and all systems fall apart.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Fortunately, you can avoid The Wall with load testing. Done properly, it can save you and your company a lot of time, money, and frazzled nerves. Let’s look in more detail at why you should load test.&lt;/span&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Why Do You Need To Load Test ColdFusion Apps?&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span&gt;No ColdFusion team wants their new app to crash after launch. But sometimes under pressure, or due to lack of knowledge, you launch it too soon. Before it has been stress-tested under real load conditions. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;There are a few nasty side-effects of poorly-planned app launches that lead to crashes. This is typically caused by a sudden influx of traffic or users, spiking demand at times when resources are limited. It can bring your web app crashing down. It happens when you are stacking up all available application threads that collapse under their own weight.&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Crashes can spook users, leading them to jump to your competitors. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;It will slow down your company’s critical operations that are dependent upon the app. This all leads to added costs.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Inevitably, you will have to call in the fire brigade to squeeze out new load capacity.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Perhaps worst of all: Bugs and server crashes will chase away customers and kill productivity. This, in tandem, hurts your company’s image. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;span id="How-To-Easily-Load-Test-And-Make-It-A-Routine"&gt;With proper load testing, you can discover your app’s weak points before the curtain opens on your launch to a live audience. With the right set up, you can enjoy pushing your app and server architecture to the limit, breaking them, and then fixing the resulting mess. All in a consequence-free setting. Makes me feel like a kid again!&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span id="Pick-A-Load-Testing-Tool"&gt;Load testing your code and app is the most effective, least costly way to expose any weaknesses or mistakes in your work. &lt;/span&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;How To Easily Load Test ColdFusion Apps and Make It A Routine&lt;/strong&gt;&lt;/h2&gt;

&lt;h4&gt;&lt;strong&gt;1. Pick a load testing tool&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;&lt;span id="Write-Testing-Scripts-That-Simulate-Real-Life"&gt;Start with a load testing tool such as the free open-source &lt;/span&gt;&lt;a href="https://jmeter.apache.org/" rel="noopener noreferrer"&gt;&lt;span&gt;Apache JMeter&lt;/span&gt;&lt;/a&gt;&lt;span&gt;. It lets you write and playback user scripts that simulate real users running your app. You can include userIDs/passwords or other user data from data files to make the simulated users more realistic. And include random “thinking time”, just as humans delay between clicks or form submits. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;As you progress in load testing, you can consider the many paid load testing tools which add more features, with prices ranging from $100 to $100,000.&lt;/span&gt;&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;2. Write Testing Scripts That Simulate Real Life&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;&lt;span&gt;Write a testing script that mimics real users interacting with your web app. &lt;/span&gt;&lt;span&gt;&lt;br&gt;
&lt;/span&gt;&lt;span&gt;Make sure the “users” are as active and numerous as real-world users would be. They should be clicking, updating, refreshing, downloading, and generally frantically chewing over every inch of your app.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Turn up the load of simulated users through 3 levels:&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Ramp up the number of users until your app slows down. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span id="Assess-The-Results-Of-The-Test"&gt;Take it to the normal expected number of users and see how it performs.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;
&lt;span&gt;Then get “a little bit naughty” – keep ramping up users until it finally breaks the server with a total crash. This is called a &lt;/span&gt;&lt;b&gt;stress test&lt;/b&gt;&lt;span&gt; and lets you find the ultimate limits to your code, architecture, and hardware setup. &lt;/span&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;span&gt;Note you should have fixed all regular bugs before you start load testing. I wrote about &lt;/span&gt;&lt;a href="https://teratech.com/thorough-test-coldfusion-web-applications/" rel="noopener noreferrer"&gt;&lt;span&gt;Testing and automated testing&lt;/span&gt;&lt;/a&gt;&lt;span&gt; to help with that.&lt;/span&gt;&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;3. Assess The Results Of The Test&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;&lt;span&gt;Now that your digital army of simulated users has done a great job of slowing down or crashing your app, you can get to work in analyzing why it happened. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Load issues are usually caused by a combination of factors:&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;Software configuration issues, either for CF, IIS, JVM, databases&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Poorly optimized software code that cannot handle an influx of activity&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Badly designed database tables, indices, or queries&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Speed issues with external services called by CFHTTP or REST API calls&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Poor network configurations which get bogged down by increased demand&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span id="Rinse-And-Repeat-Your-Tests-And-Fixes"&gt;Incorrectly configured clustering and load balancing&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;Insufficient hardware (CPU, RAM, and disk space), which cannot meet the overall demands of running the app at peak load&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;span&gt;You can learn more about fixing issues in this podcast interview I did with &lt;/span&gt;&lt;a href="https://teratech.com/podcast/scaling-your-coldfusion-applications-clusters-containers-and-load-tips-with-mike-collins/" rel="noopener noreferrer"&gt;&lt;span&gt;CF scaling expert Mike Collins&lt;/span&gt;&lt;/a&gt;&lt;span&gt;.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;I use a performance monitoring tool such as FusionReactor during load tests to make tracking down the cause of problems easier.&lt;/span&gt;&lt;/p&gt;

&lt;h4&gt;&lt;strong&gt;4. Rinse and Repeat Your Tests and Fixes&lt;/strong&gt;&lt;/h4&gt;

&lt;p&gt;&lt;span&gt;Keep load testing your app until:&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span id="The-Long-Term-Benefits-Of-Load-Testing"&gt;You’re sure the expected number of users won’t slow down your app.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;You can handle reasonable surges in users, of say 100% above the expected load. &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;You are comfortable that the point that your server crashes under load is a high number of users. And given user growth predictions, that it is far enough into the future that you could buy extra hardware to prevent problems before they happen.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;&lt;strong&gt;The Long-term Benefits of Load Test ColdFusion Apps&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span id="About-The-Author"&gt;Load testing remains one of the more overlooked aspects of CF development. Many treat it as an afterthought. But it’s an early decision that could have long-term ramifications for the success of your web app, as well as the financial health of your company. Load test properly, or it could cost you big time. In the worst case, it can cause a company to go out of business.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Run tests that push the limits of your web apps and servers. This stress test will show your app’s breaking point, which will help you spot trouble ahead of time.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Be optimistic! Load testing is a part of coding where not planning for failure leads to ultimate failure after launch.&lt;/span&gt;&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;About the Author&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Wx9LMHdq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2021/01/Screenshot-2021-01-21-at-09.42.43.png" class="article-body-image-wrapper"&gt;&lt;img class="alignleft wp-image-61797 size-full" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Wx9LMHdq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2021/01/Screenshot-2021-01-21-at-09.42.43.png" alt="Why Load Test ColdFusion Apps (4 Reasons), FusionReactor" width="125" height="176"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;b&gt;Michaela Light&lt;/b&gt;&lt;span&gt; is the host of the &lt;/span&gt;&lt;a href="https://teratech.com/podcast/" rel="noopener noreferrer"&gt;&lt;span&gt;CF Alive Podcast&lt;/span&gt;&lt;/a&gt;&lt;span&gt; and has interviewed more than 100 ColdFusion experts. In each interview, she asks “What Would It Take to make CF more alive this year?” The answers still inspire her to continue to write and interview new speakers. Michaela has been programming in ColdFusion for more than 25 years. She founded &lt;/span&gt;&lt;a href="https://teratech.com/" rel="noopener noreferrer"&gt;&lt;span&gt;TeraTech &lt;/span&gt;&lt;/a&gt;&lt;span&gt;in 1989. The company specializes in ColdFusion maintenance, application development, security, and optimization. She has also founded the CFUnited Conference and runs the annual State of the CF Union Survey.&lt;/span&gt; &lt;/strong&gt;&lt;/p&gt;



</description>
      <category>coldfusion</category>
      <category>cfml</category>
      <category>loadtest</category>
    </item>
    <item>
      <title>Why Do I Need an Application Performance Monitor (APM) Tool?</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Tue, 02 Feb 2021 09:49:55 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/why-do-i-need-an-application-performance-monitor-apm-tool-23md</link>
      <guid>https://dev.to/fusion_reactor/why-do-i-need-an-application-performance-monitor-apm-tool-23md</guid>
      <description>&lt;h2&gt;Why Do I Need an Application Performance Monitor (APM) Tool?&lt;/h2&gt;


&lt;p&gt;&lt;span&gt;Application Performance Monitoring (APM) is a technique that is a must-have for every serious-minded DevOps team. When it comes to employing the best practices for present-day software development, application Performance Monitoring procedures always top the list. &lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/07/metrics.gif" ref="magnificPopup" class="w-image-h"&gt;&lt;img width="1024" height="592" src="https://res.cloudinary.com/practicaldev/image/fetch/s--AqPLfWIS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/07/metrics-1024x592.gif" class="attachment-large size-large" alt="Why Do I Need an Application Performance Monitor (APM) Tool?, FusionReactor"&gt;&lt;/a&gt;&lt;p&gt;&lt;span&gt;The sole purpose of monitoring an application’s performance on a routine basis is to portray visual imagery of the developed application or software’s internal operations while providing users with an excellent user experience. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;&lt;a href="http://www.fusion-reactor.com/features/apm/"&gt;Application Performance Monitoring&lt;/a&gt; (APM) tools are handy instruments that provide software administrators with the insight required to make a useful inference, figure out if the system works in semblance with the proposed blueprint, and implement fixes to issues that negatively impact the overall performance of the software.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Given the complexity of deploying software applications across multiple infrastructures (both cloud and on-premise), the DevOps team devised a means to keep track of their deployed apps’ operability. Taking into consideration the following reasons;&lt;/span&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span&gt;To represent a concise image of the developed platform to all stakeholders.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span&gt;To state where there is an issue and what is needed to be adjusted. &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;&lt;span&gt;Why is Application Performance Monitoring (APM) is Important to Organizations?&lt;/span&gt;&lt;/h2&gt;
&lt;br&gt;
&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2021/01/cloud-computing-2001090_1920.jpg" ref="magnificPopup" class="w-image-h"&gt;&lt;img width="1024" height="576" src="https://res.cloudinary.com/practicaldev/image/fetch/s--dnSwQI8E--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2021/01/cloud-computing-2001090_1920-1024x576.jpg" class="attachment-large size-large" alt="Why Do I Need an Application Performance Monitor (APM) Tool?, FusionReactor"&gt;&lt;/a&gt;&lt;p&gt;&lt;span&gt;Application Performance Monitoring (APM) is an IT and software development best practice dedicated to ensuring application functions as expected. Application Performance management entails tracking the availability and &lt;a href="/features/performance-troubleshooting/"&gt;performance&lt;/a&gt; of the various components of software applications such as a codebase, user experience, and other application dependencies. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;For any business entity, the first step to ultimately wielding control over your applications’ performance is crucial to clearly understand what you would like to measure and how best to interpret it regarding your business model.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Every DevOps team in a well-structured organization must set up toolsets that allow them to measure performance metrics like each request and transaction in their codebase and the deployed app. Having such an observatory system permits organizations to baseline user experience and duly notify the DevOps team when the deployed software moves out of the project’s initial scope and the overall response time agreements.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;With the help of super-efficient Application Performance Monitoring Platforms like FusionReactor, organizations can seamlessly monitor multiple applications on a grouping data concerning client CPU usage, constant network, data output, memory demands, and overall bandwidth.&lt;/span&gt;&lt;/p&gt;


&lt;h2&gt;&lt;span&gt;Why is an APM a No Brainer For Organisations&lt;/span&gt;&lt;/h2&gt;
&lt;br&gt;
&lt;img width="1024" height="683" src="https://res.cloudinary.com/practicaldev/image/fetch/s--ynIQuvcR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2021/01/artificial-intelligence-3382507_1920-1024x683.jpg" class="attachment-large size-large" alt="Why Do I Need an Application Performance Monitor (APM) Tool?, FusionReactor"&gt;&lt;p&gt;&lt;span&gt;Following the above definitions, using an APM can be a walk in the park if well implemented. This section is slated for developers, and DevOps teams keen on transcending their organizational needs to the next level. In this guide, I would be highlighting the key factors that would aid any organization in transforming their overall business model with the help of a well-suited Application Performance Monitoring tool.&lt;/span&gt;&lt;/p&gt;
&lt;br&gt;
&lt;h3&gt;&lt;span&gt;Insight in your Environment&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span&gt;Learning the application workflow and entire development environment is the very first advantage that an APM provisions an organization. As the starting point for any APM implementation, APM provides visual imagery of how the application runs and who is using it. On the other hand, the DevOps team – and the administrative arm of an organization – has become accustomed to tracking different usage volumes from various timeframes (e.g., from 12:00 pm to 12:00 am). Using an APM helps in the scheduling of resource-intensive jobs and capacity planning.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;Customer Satisfaction&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span&gt;Every business unit’s goal is to gain 100% customer satisfaction – and this is why performance monitoring becomes even more necessary long after the application has been deployed. Once a clear understanding of how the environment operates is established, you and your organization are a step closer to increasing user satisfaction. &lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;Given users’ interactions are the crucial components of any system, as you increase your customer’s efficiency, you boost overall customer satisfaction and subsequent retention.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;Reduces Firefighting&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span&gt;A useful APM tool routinely locates application &lt;a href="/features/performance-troubleshooting/"&gt;performance bottlenecks&lt;/a&gt; on the fly. With this information at hand, project managers do not necessarily need to assemble all the application teams to address an issue. All that is required to be done is to have only the required personnel to troubleshoot and fix that issue—allowing the other half of the workforce to focus and take additional responsibilities.&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;Builds Credibility&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span&gt;Building customer credibility is a prerequisite for every business model. Developing healthy customer credibility for your brand takes time to develop yet can be lost in an instance. Management thrives on proactivity. As businesses get better at being proactive and communicating problems to their customers, they tend to build more customer confidence in the brand. Ultimately eliminating any negative perceptions of the business organization and the barrier of competition with similar service providers&lt;/span&gt;&lt;/p&gt;

&lt;h3&gt;&lt;span&gt;Issue Isolation&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;&lt;span&gt;Once complete proactivity and a proper monitoring and alert system are set in place, there would be no more need to have multiple staff monitor and validate the entire application. Although you would still need to maintain a handful of staff to respond to alerts, the amount of staff needed would be the barest minimum. This allows administrative-level employees to focus more on project work, leaving daily tracking and monitoring to the junior team.&lt;/span&gt;&lt;/p&gt;


&lt;h2&gt;So Why Do I Need an Application Performance Monitoring (APM) Tool?&lt;/h2&gt;
&lt;br&gt;
&lt;p&gt;&lt;span&gt;In conclusion, it is pertinent for every organization to establish a well-implemented APM solution as it aids DevOps teams (and the organizations at large) resolve issues and bottlenecks at a brisk pace and reduces the organization’s &lt;a href="http://www.fusion-reactor.com/how-to-maximise-apm-roi-and-reduce-time-to-fix/"&gt;Mean Time To Resolution&lt;/a&gt; (MTTR). By a wide margin, this impacts the overall business bottom line to a reduced state.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;span&gt;An organization that studies its application’s development and deployment environment can seamlessly harness useful insights while monitoring resource-intensive projects. Besides providing structural planning for project execution, a good A.P.M. bolsters customers’ satisfaction and initiates more users’ engagement. Your organization does not need to employ an in-house Q.A. team – given most of the processes involved in quality control and analysis are automated and handled on the go. Corporations can now focus more energy on what matters. Organizations can now say goodbye to the unnecessary hassle involved in maintaining and an extensive software analysis team. In the long run, cutting down extra expenses required to maintain these staff – and &lt;a href="http://www.fusion-reactor.com/how-to-maximise-apm-roi-and-reduce-time-to-fix/"&gt;increasing the overall Return On Investment&lt;/a&gt; (R.O.I) through this and more user interaction.&lt;/span&gt;&lt;/p&gt;


&lt;p&gt;Start your free &lt;a href="https://app.fusionreactor.io"&gt;FusionRector APM trial&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Observability Vs. Monitoring: Why A Developer Needs Both</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Tue, 02 Feb 2021 09:39:02 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/observability-vs-monitoring-why-a-developer-needs-both-5ejp</link>
      <guid>https://dev.to/fusion_reactor/observability-vs-monitoring-why-a-developer-needs-both-5ejp</guid>
      <description>&lt;h1&gt; Observability Vs. Monitoring: Why A Developer Needs Both &lt;/h1&gt;

&lt;p&gt;Given the complexity of distributing the evolving cloud-based services and infrastructures across a diverse range of users, IT service providers consistently observe and monitor metrics, datasets, and logs. Establishing system reliability and the predictability of backend IT infrastructure operations all spawn from systems observability and &lt;a href="https://www.fusion-reactor.com/features/apm/"&gt;monitoring&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Software solutions often deliver a wide range of IT infrastructures and services from distant geographical locations to companies – in the semblance of cloud-based services such as containers and microservices. These services are distributed across multiple layers of infrastructure and platform services.&lt;/p&gt;

&lt;p&gt;Due to consumers’ high expectancy for software-driven and enterprise IT, service providers to effect rapid feature updates through new releases on the internet. For this, IT providers frequently lookout for the best approaches to streamline performance while improving efficiency and maintaining system stability.&lt;/p&gt;

&lt;h2&gt;What Is The Difference Between Observability And Monitoring&lt;/h2&gt;

&lt;p&gt;Observability and monitoring are two terms that are often used interchangeably in the programming sphere. The critical difference between these two buzzwords lies in the ability to infer a system’s internal state against the actions involved in observing the quality of system performance over a stipulated timeframe.&lt;/p&gt;

&lt;p&gt;While observability is performed based on a system’s external outputs, monitoring describes the health, performance, efficiency, and other essential features relative to the internal state.&lt;/p&gt;

&lt;p&gt;Just as monitoring refers to all processes involved in translating infrastructure log metrics data into actual and discerning visual abstraction, observability engenders control of the internal states through external inputs.&lt;/p&gt;

&lt;h2&gt;Every Developer’s Greatest Asset&lt;/h2&gt;

&lt;p&gt;A developer or a development team’s ability to imbibe observability and monitoring as a traditional approach to development entails the deployment of more efficient codes, quicker product release, and streamlined deliverables. Practical monitoring approaches cannot be implemented without observability.&lt;/p&gt;

&lt;p&gt;Given the concept of observability is inherent in present-day software development life cycle (SDLC) methodologies. With greater complexity comes an even greater need to observe and monitor the processes and tools employed during the development and deployment of these applications and services.&lt;/p&gt;

&lt;p&gt;Monitoring IT infrastructures and services; from the blend of applications to manage, building, and deploying these services (containers, microservices, cloud-based ecosystem), through to the hassle involved in delivering these infrastructures (virtual, mobile, SaaS, cloud), are becoming more and more complicated.&lt;/p&gt;

&lt;h2&gt;What Is The Difference Between Observability And Monitoring&lt;/h2&gt;

&lt;p&gt;While observability is a procedure utilized by DevOps teams to query a system at every phase of the development-deployment process, an efficient monitoring technique informs whether the system functions as defined. Observability entails the dissemination of information gathered from the system. On the other hand, monitoring is a failure-centric approach that provisions a collection of metrics and logs from the system.&lt;/p&gt;

&lt;p&gt;I am considering that every Developer’s greatest asset is reliant on building scalable and maintainable code over time. Hence, combining new Application Performance Monitoring tools – like &lt;a href="https://www.fusion-reactor.com/technologies/java-monitoring/"&gt;FusionReactor&lt;/a&gt;, with data derived from industry-leading observability techniques is a win-win situation.&lt;/p&gt;

&lt;p&gt;Conclusively, an adept developer or DevOps team can provide insightful access into the code’s intent while performing thorough traces and providing end-to-end transaction flow representation, drill-down tables &amp;amp; visual display of the various IT functions in the system. By employing sufficient metadata context provisioned by the observability and monitoring processes.&lt;/p&gt;

&lt;p&gt;Originally posts here &lt;a href="http://www.fusion-reactor.com/blog/what-is-the-difference-between-observability-and-monitoring/"&gt;http://www.fusion-reactor.com/blog/what-is-the-difference-between-observability-and-monitoring/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>observability</category>
      <category>apm</category>
      <category>monitoring</category>
      <category>performance</category>
    </item>
    <item>
      <title>Find bugs and performance issues faster</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Fri, 05 Jun 2020 15:41:19 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/with-fusionreactor-hybrid-apm-you-will-find-bugs-and-performance-issues-faster-46kp</link>
      <guid>https://dev.to/fusion_reactor/with-fusionreactor-hybrid-apm-you-will-find-bugs-and-performance-issues-faster-46kp</guid>
      <description>&lt;h2&gt; Instantly see what's behind critical production issues&lt;/h2&gt;

&lt;p&gt;Deliver features faster and spend less time maintaining your application&lt;/p&gt;

&lt;p&gt;FusionReactor provides real-time visibility into instrumentation data and code execution metrics, enabling developers to get to the root of issues and performance problems in the shortest possible time. FusionReactor is the only tool that can be effectively used for performance analysis across the whole Software Development Life Cycle. Over 5000 customers trust FusionReactor to monitor their Java applications, enabling them to identify and respond faster to performance and stability problems.  &lt;/p&gt;

&lt;h2&gt;Configurable Metrics Dashboards&lt;/h2&gt;

&lt;p&gt;Cloud enables you to combine metric graphs so that you can build your own unique Dashboard views of how you want to see your data.&lt;/p&gt;

&lt;h2&gt;Application / Transaction breakdown&lt;/h2&gt;

&lt;p&gt;For each application being monitored, FusionReactor Cloud will automatically break down requests into individual transactions (including automatic framework recognition).&lt;/p&gt;

&lt;p&gt;Transactions are measured so that you can quickly gauge how much time each transaction is taking in %, on average, which are slowest, the overall request throughput and how many errors/exceptions occurred.&lt;/p&gt;

&lt;h2&gt;Advanced Alerting Capability&lt;/h2&gt;

&lt;p&gt;FusionReactor Cloud includes advanced alerting capability, to enable you to set alerts based on different metrics available.&lt;/p&gt;

&lt;p&gt;We have integrated support for many standard alerting tools, such as PagerDuty, Slack, HipChat, VictorOps – as well as supporting alerts via email and HTTP webhooks.&lt;/p&gt;

&lt;h2&gt;Auto Detect Errors &amp;amp; Important Transactions&lt;/h2&gt;

&lt;p&gt;FR Cloud is constantly monitoring individual request to determine if they’re interesting for you e.g. slow running requests, requests which generated an error or threw an exception.&lt;/p&gt;

&lt;p&gt;Drill into the details of these requests and even save them for review at a later date.&lt;/p&gt;

&lt;h2&gt;Low-Overhead Production Java Profiler&lt;/h2&gt;

&lt;p&gt;FusionReactor Cloud Ultimate Edition includes an integrated low-overhead Java Profiler – which is the perfect tool for identifying poorly performing code in your production environment.&lt;/p&gt;

&lt;p&gt;You can profile any requests or transactions which are running on the JVM – e.g. Tomcat, JBoss, WildFly, Glassfish, Jetty, etc. ColdFusion applications can also be profiled.&lt;/p&gt;

&lt;h2&gt;Metrics Explorer&lt;/h2&gt;

&lt;p&gt;Using the Metrics Explorer inside FusionReactor Cloud &lt;a href="https://www.fusion-reactor.com/technologies/java-monitoring/"&gt;Java monitoring &lt;/a&gt;allows you to begin examining all of the metrics FusionReactor has collected from your instances or application.&lt;/p&gt;

&lt;p&gt;On the left of the screen, you can see the query configuration panel, this allows you to configure the queries used to generate the graphs that will appear on the right-hand side of the screen.&lt;/p&gt;

&lt;p&gt;Clicking the metric dropdown shows a searchable list of all of the metrics available for your account.&lt;/p&gt;

&lt;p&gt;Free 14 day trial &lt;a href="https://www.fusion-reactor.com/technologies/java-monitoring/"&gt;Java monitoring &lt;/a&gt;&lt;/p&gt;

</description>
      <category>technicaldebt</category>
      <category>java</category>
      <category>cfml</category>
    </item>
    <item>
      <title>What is Polymorphism, Encapsulation, Data Abstraction and Inheritance in Object-Oriented Programming?</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Fri, 05 Jun 2020 14:46:08 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming-14cc</link>
      <guid>https://dev.to/fusion_reactor/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming-14cc</guid>
      <description>&lt;p&gt;Object-oriented programming refers to the concept in high-level languages such as Java and Python that uses Objects and classes in their implementations. OOP has four major building blocks which are, Polymorphism, Encapsulation, Abstraction, and Inheritance.  There are other programming paradigms such as Procedural programming in which codes are written in sequentially. Python and Java are multi-paradigm high-level programming languages that means they support both OOP and procedural programming. A programmer decides on the paradigm to use based on his expertise and the problems his trying to solve. However, there is no controversy that OOP makes programming easier, faster, more dynamic, and secured. This is a major reason Java and Python are the top most popular programming languages in the world today&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foop.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foop.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you want to learn Java and Python or any other object-oriented programming languages, then you must understand these Object-Oriented Programming paradigms which are a relatively easy concept to understand. Let’s take a look at them.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;What is Inheritance?&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;In Java and Python, codes are written in objects or blocks if you are adopting OOP methodology. Objects can interact with one another by using the properties of each block or extending the functionalities of a block through inheritance.  Inheritance ensures that codes are reused. There are millions of Java and Python libraries that a programmer can use through inheritance. The properties of a class can be inherited and extended by other classes or functions. There are two types of classes. One is the Parent or base class, and the other is the child class which can inherit the properties of the parent class. Inheritance is a major pillar in Object-Oriented programming. It is the mechanism by which classes in Java, Python, and other OOP languages inherits the attribute of other classes&lt;/p&gt;

&lt;p&gt;A parent class can share its attributes with a child class. An example of a parent class implementation is in DDL (Dynamic-link library). A DDL can contain different classes that can be used by other programs and functions&lt;/p&gt;

&lt;p&gt;A real-world example of inheritance is a mother and child. The child may inherit attributes such as height, Voice patters, color. The mother can reproduce other children with the same attributes as well&lt;/p&gt;

&lt;p&gt;You can create a function or class called “Move Robot,” which controls a robot to move. And you could create method and functions in other programs that can inherit the ” Move Robot” Class without rewriting the codes over and over again.  You can also extend this class by inheriting it and writing few more codes to it that would instruct a robot to move and also run in some specific circumstances using if and else statement.  With inheritance, you can create multiple robots that would inherit the attributes of the parent class “Move Robot,” which ensures code reusability.&lt;/p&gt;

&lt;p&gt;In summary, Inheritance is concerned with the relationship between classes and method, which is like a parent and a child. A child can be born with some of the attributes of the parents. Inheritance ensures reusability of codes just the way multiple children can inherit the attributes of their parents.&lt;/p&gt;

&lt;p&gt;When we want to create a function, method, or class, we look for a superclass that contains the code or some of the code we want to implement. We can then derive our class from the existing one. In Java, we do this by using the keyword “Extends”, and in Python, we achieve this by inheriting the attributes of a class by calling up the class name.&lt;/p&gt;

&lt;p&gt;Here is an example : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foutfile-2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foutfile-2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A vehicle class would define fields for speed.  All vehicles are capable of traveling at some speed (even if 0 when stationary).&lt;/p&gt;

&lt;p&gt;All boats would define buoyancy and draft and then the specific types (sailing, paddle, speed) would define its method of propulsion. &lt;/p&gt;

&lt;p&gt;Cars define type of fuel, engine size etc.&lt;/p&gt;

&lt;p&gt;Airplanes would have logic for flight, i.e.  weight limits etc.&lt;/p&gt;

&lt;pre&gt;public class Vehicle {
    public float speedInKPH;
}
public class Car extends Vehicle {
    public int numberOfWheels;
    public int numberOfSeats;
}
public class Plane extends Vehicle {
     public long maximumTakeoffWeight;
}
public class SportsCar extends Car {
     boolean hasSoftTop;
}&lt;/pre&gt;

&lt;h2&gt;What is Encapsulation?&lt;/h2&gt;

&lt;p&gt;This is a programming style where implementation details are hidden. It reduces software development complexity greatly. With Encapsulation, only methods are exposed. The programmer does not have to worry about implementation details but is only concerned with the operations. For example, if a developer wants to use a dynamic link library to display date and time, he does not have to worry about the codes in the date and time class rather he would simply use the data and time class by using public variables to call it up. In essence encapsulation is achieved in Python and Java by creating Private variables to define hidden classes in and then using public variables to call them up for use. With this approach, a class can be updated or maintained without worrying about the methods using them. If you are calling up a class in ten methods and you need to make changes, you don’t have to update the entire methods rather you update a single class. Once the class is changed, it automatically updates the methods accordingly. Encapsulation also ensures that your data is hidden from external modification. Encapsulation is also known as Data-Hidden.&lt;/p&gt;

&lt;p&gt;Encapsulation can be viewed as a shield that protects data from getting accessed by outside code.&lt;/p&gt;

&lt;p&gt;In essence, Encapsulation binds data and code as a single unit and enforces modularity.&lt;/p&gt;

&lt;h2&gt;What is Polymorphism&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foop2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.fusion-reactor.com%2Fwp-content%2Fuploads%2F2020%2F06%2Foop2.png" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Polymorphism means existing in many forms. Variables, functions, and objects can exist in multiple forms in Java and Python. There are two types of polymorphism which are run time polymorphism and compile-time polymorphism. Run time can take a different form while the application is running and compile-time can take a different form during compilation.&lt;/p&gt;

&lt;p&gt;An excellent example of Polymorphism in Object-oriented programing is a cursor behavior. A cursor may take different forms like an arrow, a line, cross, or other shapes depending on the behavior of the user or the program mode. With polymorphism, a method or subclass can define its behaviors and attributes while retaining some of the functionality of its parent class. This means you can have a class that displays date and time, and then you can create a method to inherit the class but should display a welcome message alongside the date and time. The goals of Polymorphism in Object-oriented programming is to enforce simplicity, making codes more extendable and easily maintaining applications.&lt;/p&gt;

&lt;p&gt;Inheritance allows you to create class hierarchies, where a base class gives its behavior and attributes to a derived class. You are then free to modify or extend its functionality. Polymorphism ensures that the proper method will be executed based on the calling object’s type.&lt;/p&gt;

&lt;p&gt;Program codes would run differently in a different operating system. The ability of program code exhibiting different behaviors across the operating system is known as polymorphism in OOP.  You can create a class called “Move” and then four people create animals that would inherit the move class. But we don’t know the type of animals that they would create. So polymorphism would allow the animals to move but in different forms based on the physical features&lt;/p&gt;

&lt;p&gt;A creates a Snail that inherits the move class, but the snail would crawl&lt;/p&gt;

&lt;p&gt;B creates a Kangaroo that inherits the move class, but the Kangaroo would leap&lt;/p&gt;

&lt;p&gt;C creates a Dog that inherits the move class, but the dogs would walk&lt;/p&gt;

&lt;p&gt;D creates a Fish that inherits the move class, but the Fish would swim.&lt;/p&gt;

&lt;p&gt;Polymorphism has ensured that these animals are all moving but in different forms. How the programs would behave would not be known until run time.&lt;/p&gt;

&lt;h2&gt;What is Abstraction?&lt;/h2&gt;

&lt;p&gt;Abstraction in Java and Python is a programming methodology in which details of the programming codes are hidden away from the user, and only the essential things are displayed to the user. Abstraction is concerned with ideas rather than events. &lt;/p&gt;

&lt;p&gt;Its like in our vehicle example some of the vehicles need to be started before they can move.&lt;/p&gt;

&lt;pre&gt;public interface Startable {
    void start();
}
public class Car extends Vehicle implements Startable {
    public int numberOfWheels;
    public int numberOfSeats;
    public void start() {
       // some implementation
    }
}&lt;/pre&gt;

&lt;p&gt;You don’t need to care about how to start a car, plane, boat etc, if it implements Startable you know it will have a start method.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Polymorphism, Encapsulation, Data Abstraction and Inheritance in Object-Oriented Programming&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;The main idea behind Object Oriented Programming is simplicity, code reusability, extendibility, and security. These are achieved through Encapsulation, abstraction, inheritance, and polymorphism. For a language to be classified as OOP, it must have these 4 OOP blocks.  Abstraction has to do with displaying only the relevant aspect to the user, for example, turning on the radio, but you don’t need to know how the radio works. Abstraction ensures simplicity. Inheritance has to do with methods and functions inheriting the attributes of another class. The main aim is code reuse which ensures that programs are developed faster. DRY (don’t Repeat yourself) is a concept in inheritance which imply that in a program, you should not have different codes that are similar. Instead, have one class and use other methods to call them and extend the functionalities where necessary. Polymorphism allows program code to have different meaning or functions while encapsulation is the process of keeping classes private so they cannot be modified by external codes.&lt;/p&gt;

&lt;p&gt;This article was originally posted &lt;a href="https://www.fusion-reactor.com/blog/technical-blogs/polymorphism-encapsulation-data-abstraction-and-inheritance-in-object-oriented-programming/" rel="noopener noreferrer"&gt;in the FusionReactor blog&lt;/a&gt; where you will find many interesting articles written by our developer team.&lt;/p&gt;

&lt;h3&gt;What is FusionReactor?&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://fusion-reactor.com" rel="noopener noreferrer"&gt;FusionReactor is an APM&lt;/a&gt; for Java applications that features low-level &lt;a href="/ultimate-edition/"&gt;capabilities &lt;/a&gt;including profilers, automated root cause analysis, and production debugger. &lt;/p&gt;

</description>
      <category>polymorphism</category>
      <category>encapsulation</category>
      <category>abstraction</category>
      <category>oop</category>
    </item>
    <item>
      <title>the Eclipse Performance Monitor</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Thu, 21 May 2020 09:44:58 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/the-eclipse-performance-monitor-b7i</link>
      <guid>https://dev.to/fusion_reactor/the-eclipse-performance-monitor-b7i</guid>
      <description>&lt;h2&gt;Introducing the Eclipse Performance Monitor&lt;/h2&gt;

&lt;p&gt;Eclipse IDE (Integrated Development Environment) is a multi-lingual development setting for almost any programming language you could think of – Java, C, C++, Clojure, Groovy, Haskell, JavaScript, Julia, Perl, PHP, Ruby, Rust, and much more. Nonetheless, eclipse is famous for being a dedicated Java IDE&lt;/p&gt;

&lt;p&gt;Listed as one amongst the top three Java IDEs, this next-generation IDE is available in both desktop and cloud editions, hence its extensive clientele. But as the saying goes; “&lt;em&gt;To Whom much is given much is expected.&lt;/em&gt; With an increasing large user community, the requirement for certain functionality becomes more needful over time. &lt;/p&gt;

&lt;p&gt;For a renowned IDE like Eclipse, the feasibility of such serviceability as debugging, performance monitoring, profiling etc., has to be treated with a specific degree of sensitivity. Which is why we would be discussing on how to perform one of the most crucial aspects in the software development life cycle on an eclipse environment – performance monitoring on an Eclipse IDE. &lt;/p&gt;

&lt;h2&gt;How to Execute Performance Monitoring on An Eclipse IDE&lt;/h2&gt;

&lt;p&gt;For web artisans who are well-versed in the Java programming language, looking to include distinctive functionalities on the Eclipse IDE, a PDE (Plugin Development Environment) is conveniently available for this. This PDE allows the IDE to flaunt robust tools that aid developers in speeding up the entire development process. Yet, for more in-depth capabilities, it is best to utilize an exclusive eclipse performance monitor viz &lt;a href="https://www.fusion-reactor.com/java-eclipse-apm/eclipse-performance-monitor/"&gt;FusionReactor&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;The UI Freeze Monitor&lt;/h2&gt;

&lt;p&gt;Eclipse IDE is providing an all-inclusive application programming interface. And as earlier mentioned, it comes fully packed with its own performance and profiling toolset in addition to an external plugin additive – all thanks to the PDE. Consequently, before we go into the details of using the dedicated performance tracing facility of the Eclipse IDE, we ought to talk about the interactive UI monitoring tool that comes with the Eclipse IDE. To activate this responsive UI performance measurement feature you would have to navigate to the preference tab on your window. You can do this by following these few steps below.&lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;Steps: –&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt; 1 Click on Windows &lt;strong&gt;&amp;gt; &lt;/strong&gt;Preference &lt;strong&gt;&amp;gt;&lt;/strong&gt; UI Responsiveness Monitoring. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eDhHBpU4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/pl_JKeQUHrxgLQ68u1yAyzIyCQYHw0DKqkKWIFcmzi4MU-NK_xyy_xpqxopFoE42Ye-GwKWpp7YBodK9vcVSPBjU10ZMTcMTlSWOrTLSy_zaCG3rcOKhOb6z4vz8ebIY3dlOPuZuYYP5MZsL3w" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eDhHBpU4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/pl_JKeQUHrxgLQ68u1yAyzIyCQYHw0DKqkKWIFcmzi4MU-NK_xyy_xpqxopFoE42Ye-GwKWpp7YBodK9vcVSPBjU10ZMTcMTlSWOrTLSy_zaCG3rcOKhOb6z4vz8ebIY3dlOPuZuYYP5MZsL3w" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; 2 Once activated, a window would pop on where a stack trace would write to the Errorview, in case there is an occurrence of a UI freeze just like the window below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v7q2ISfn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/i4EpKt-laBGShTZ1VAYFsebV0StVI8C8ykDCHQig4H8r3kESjTrOeIwUPT9nGiVH8tZticwlKqqQ0qY-SgbRFXAItYclR-0eiLmrBerVRe_HHLP0cLmg1mv_lLBkwwsfGSnBmQbN38Qlq6EpwA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v7q2ISfn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/i4EpKt-laBGShTZ1VAYFsebV0StVI8C8ykDCHQig4H8r3kESjTrOeIwUPT9nGiVH8tZticwlKqqQ0qY-SgbRFXAItYclR-0eiLmrBerVRe_HHLP0cLmg1mv_lLBkwwsfGSnBmQbN38Qlq6EpwA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;During the event of a deadlock, it is best that you report such freezes &lt;a href="https://bugs.eclipse.org/"&gt;&lt;em&gt;https://bugs.eclipse.org/&lt;/em&gt;&lt;/a&gt;, so that the team can fix these.&lt;/p&gt;



&lt;p&gt;For the rest of this guide we would be highlighting on the integrated performance inspecting facilities of Eclipse. Along with steps on how to implement this scrutiny in the most detailed way possible. Let’s immediately get into the nitty-gritty of using a custom-built performance checker. &lt;/p&gt;

&lt;h2&gt;Utilizing the In-built Tracing Instruments of Eclipse.&lt;/h2&gt;

&lt;p&gt;The Eclipse IDE proffers a tracing proficiency which can be activated on demand. Upon activation, additional plug-in information is written to the console at runtime. You can activate the native tracing feature through the -debug start parameter. At which time the IDE would search for the .options file in the directory where the installation file for Eclipse is being held up. The file would then be set to the &lt;em&gt;‘one key=value pair per line’&lt;/em&gt; property.&lt;/p&gt;

&lt;p&gt;The plugin is designed such that you can see the tracing option in the preference settings by default. It is also possible to initiate this tracking options at runtime. An example of the Eclipse IDE preference is shown in the following screenshot.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jhCJ9403--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/FRS1jBQp7YFEiv0d55_jixRbEF_1d4F62L1AKvsRk2U6FwFuWVjQf1qefWK3YHmYgbega-neLop9PcKs34yqR3M0aD-hQo3En2x4vaWZbWsoldTnRBOzXb3xpVfzss3NNf2ixOaIwpSWzD48uw" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jhCJ9403--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/FRS1jBQp7YFEiv0d55_jixRbEF_1d4F62L1AKvsRk2U6FwFuWVjQf1qefWK3YHmYgbega-neLop9PcKs34yqR3M0aD-hQo3En2x4vaWZbWsoldTnRBOzXb3xpVfzss3NNf2ixOaIwpSWzD48uw" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These tracing options are also available for a launch configuration. The following examples are going to be slated for specific tracing functions.&lt;/p&gt;

&lt;h2&gt;Tracing the Start-up Time of Plug-ins&lt;/h2&gt;

&lt;p&gt;In this example, we would trace the start time of each plug-in during start-up. For this, we would be creating a distinct .options file just like we did in the last instance, but this time with a different content as shown below;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WkRTHjKb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/kjyJ3DS_cxmV8FpYQxRhgqTjVkvkIcNfi14Cz3HfJfa7atF6uD-pTER72ORNSZnwM_PJoZU6BIlWrnB8OVlQGImQmVqtUh5mhc0cH9eKJiJ46IgCKO0hBVH4-fyobt9OT5gq3Wpejh3S7qUl5A" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WkRTHjKb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/kjyJ3DS_cxmV8FpYQxRhgqTjVkvkIcNfi14Cz3HfJfa7atF6uD-pTER72ORNSZnwM_PJoZU6BIlWrnB8OVlQGImQmVqtUh5mhc0cH9eKJiJ46IgCKO0hBVH4-fyobt9OT5gq3Wpejh3S7qUl5A" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Use the underlisted command to start Eclipse;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mkEtKy6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/fnb4nnMvzhOuSVIImyrb7D_roqA3NfiA5nFYukhFTp31uqI1Q7H1NgVXJpSSlVhnifOkzHYY_nIDJFBFstpKfMa6mUThYtt3w2MiYeC9vGhwJnvdcP7A0T7VQ6GxfZbJYdqx9lKjOfyKsp_fPA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mkEtKy6X--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/fnb4nnMvzhOuSVIImyrb7D_roqA3NfiA5nFYukhFTp31uqI1Q7H1NgVXJpSSlVhnifOkzHYY_nIDJFBFstpKfMa6mUThYtt3w2MiYeC9vGhwJnvdcP7A0T7VQ6GxfZbJYdqx9lKjOfyKsp_fPA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;‘Starting application timestamp’ &lt;/em&gt;describes when OSGI (Open Service Gateway Initiative) is done with its activation process. Subsequently, its &lt;em&gt;‘Application Started’ &lt;/em&gt;time reference indicates when the application starts, just as the name imply. After which you extract the information you are most interested in. For instance, the above example is only a small script that extracts the time of the activator of each bundle. Thereafter, sorting every bundle by this time.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--03SM0FoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/ThZjwDTqMLurPfVoF6nvmzVQPcUHEl6XC9hyqYaWMtwAfLBYKJ9yBpIHDT23eaSjM1ia4e3V5uCs1Zo0CeU2BXlorikJ3-VxHqT2AagbtV8Q8EGuSowaqbgKCzTDZa-m_Ad-ZdTKi6194Ue1gg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--03SM0FoM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/ThZjwDTqMLurPfVoF6nvmzVQPcUHEl6XC9hyqYaWMtwAfLBYKJ9yBpIHDT23eaSjM1ia4e3V5uCs1Zo0CeU2BXlorikJ3-VxHqT2AagbtV8Q8EGuSowaqbgKCzTDZa-m_Ad-ZdTKi6194Ue1gg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Monitoring the Resource Plugin.&lt;/h2&gt;

&lt;p&gt;The following example uses the same .option file to trace resources.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VDBqOEIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/x8Lcvk7ImKK2jAazu2xpmqAH9eBaa_olJgjKBSTq22AM32f96bS1GO0bb2oKczgtxT3m9XnVU8jdUUmfnnc4yLpABHC48gO04zZ98oYSFQjQUv5hUpZoo8qIZZPtOYf3xCba_yQ5eZom0YjL5g" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VDBqOEIR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/x8Lcvk7ImKK2jAazu2xpmqAH9eBaa_olJgjKBSTq22AM32f96bS1GO0bb2oKczgtxT3m9XnVU8jdUUmfnnc4yLpABHC48gO04zZ98oYSFQjQUv5hUpZoo8qIZZPtOYf3xCba_yQ5eZom0YjL5g" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QB_CtuE8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/QCpRRceDKW7SUNHsA8fRrtKYcRpzDuo8eEP_2D9l0Rw8Dm-XXbxtMFcDVBe6CfJ0KEFOsY1BXypxllVL5qRYyiM2yQEQ0DGgjAVUzzr32A6urJIPz0yuz5rHQ45nqogmgFnvNL7qWNDUbpoDog" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QB_CtuE8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/QCpRRceDKW7SUNHsA8fRrtKYcRpzDuo8eEP_2D9l0Rw8Dm-XXbxtMFcDVBe6CfJ0KEFOsY1BXypxllVL5qRYyiM2yQEQ0DGgjAVUzzr32A6urJIPz0yuz5rHQ45nqogmgFnvNL7qWNDUbpoDog" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wmGzuAy---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/jHW0ZAxUQetnoMaHSuoaqtCTbns9vL3QGj2Zywz2po7RXkyxsjvrn7_08BBF7zFgDv3ZFWAWC6mCQieb9f3zCyXT_5dUBFvJDjEgG6zgH_4acB8GvFxz-86TCiClU5cLpePSm4R867F0nRQ8HA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wmGzuAy---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/jHW0ZAxUQetnoMaHSuoaqtCTbns9vL3QGj2Zywz2po7RXkyxsjvrn7_08BBF7zFgDv3ZFWAWC6mCQieb9f3zCyXT_5dUBFvJDjEgG6zgH_4acB8GvFxz-86TCiClU5cLpePSm4R867F0nRQ8HA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Implementing Tracking for your Custom Plugin&lt;/h2&gt;

&lt;p&gt;By means of the &lt;a href="https://www.winklerweb.net/index.php/blog/12-eclipse/10-finding-the-almost-new-eclipse-tracing-api"&gt;Eclipse Tracing API&lt;/a&gt;, users can also implement tracing for their custom plugins. To enable users, include their tracing options to the preference page, they would have to turn them on at run time. Using the extension to route to the org.eclipse.ui.trace.traceComponents. See the TracingPreferencePage&lt;strong&gt; &lt;/strong&gt;for more details on how to implement this.&lt;br&gt;&lt;/p&gt;

&lt;h2&gt;Tracing for Key Binding&lt;/h2&gt;

&lt;p&gt;The tracing functionality of Eclipse allows one to trace which commands are associated with certain key binding. The following listing contains the trace options to enable that.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R350oLxH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/j3pNfA6VHvVL0W95lCMZcx-vLwFcEsm0dbzONn432OdK2KS3II2oL-YHb4GXQIQITPItCthTaKUJLp3earnkDfh7amvRXMhTtZQAfophCDDNByPPCzhm_7euXho7-Lhz9tpqyyALbxHla1VxvQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R350oLxH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/j3pNfA6VHvVL0W95lCMZcx-vLwFcEsm0dbzONn432OdK2KS3II2oL-YHb4GXQIQITPItCthTaKUJLp3earnkDfh7amvRXMhTtZQAfophCDDNByPPCzhm_7euXho7-Lhz9tpqyyALbxHla1VxvQ" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;Eclipse Sleak&lt;/h2&gt;

&lt;p&gt;The Sleak monitor tracks the creation and disposal of SWT (Standard Widget Toolkit) graphics resources. You can get this feature directly from &lt;a href="http://www.eclipse.org/swt/tools.php"&gt;SWT Development Tools&lt;/a&gt; or install the Eclipse plugin via the &lt;a href="http://www.eclipse.org/swt/updatesite.php"&gt;SWT Tools Update Sites&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;To activate the Sleak functionality, you can use the &lt;em&gt;‘Tracing’&lt;/em&gt; tab in your Eclipse runtime configuration.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QezLC814--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/O3-MdcmMDVbh6xiS7lBhYNHEyEvnirxQ8gC4QlSkF8E1NgZPmdGbQ3ikkiAemO8d00bHEQ3iqhuOwpefQp32DIw_K0BdedjuprYlLQme-aQGP7BxEVSrPYM_llpmOCp8TLUCBaFOVdECXnEwKA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QezLC814--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/O3-MdcmMDVbh6xiS7lBhYNHEyEvnirxQ8gC4QlSkF8E1NgZPmdGbQ3ikkiAemO8d00bHEQ3iqhuOwpefQp32DIw_K0BdedjuprYlLQme-aQGP7BxEVSrPYM_llpmOCp8TLUCBaFOVdECXnEwKA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bDWoSVcu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/W46kGTDpDXHdGAJK2T50VsB0eAw1nGP8DWAMdfB_yRWq4m6DGrl1vlLgvCjvxJ693BcOY4WzCWvKCb0-zaP9PlbrNNOHrAa3Ipki-fR-CD1byZcN5DJna24N103NgEWTpimfkXUtsdha5Di52Q" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bDWoSVcu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/W46kGTDpDXHdGAJK2T50VsB0eAw1nGP8DWAMdfB_yRWq4m6DGrl1vlLgvCjvxJ693BcOY4WzCWvKCb0-zaP9PlbrNNOHrAa3Ipki-fR-CD1byZcN5DJna24N103NgEWTpimfkXUtsdha5Di52Q" alt=""&gt;&lt;/a&gt;&lt;/p&gt;



&lt;p&gt;You could also use active this component on the Eclipse IDE. To do this, you would have to start Eclipse with the -debug option from the command line terminal. You would also need to create a .options file in the Eclipse installation directory with the following entries;&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Mt_R7kO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/dbsjmAOJh3TRkjcUPi0o-Tjx--NcxL3Uxkw5fGecVkJVNW4SBvN86nddmWJ-W_DCZqe5D89f7sLI3shT0E8_5xXvxTrDSgcyYtpk_jy5xo8k10P7uabgmkry9RJSQ-QJ3OfPJnngZ3ksdc1ELA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Mt_R7kO6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/dbsjmAOJh3TRkjcUPi0o-Tjx--NcxL3Uxkw5fGecVkJVNW4SBvN86nddmWJ-W_DCZqe5D89f7sLI3shT0E8_5xXvxTrDSgcyYtpk_jy5xo8k10P7uabgmkry9RJSQ-QJ3OfPJnngZ3ksdc1ELA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you start the Eclipse IDE, you could find the Sleak view under;&lt;br&gt;&lt;/p&gt;

&lt;p&gt; Window &lt;strong&gt;&amp;gt; &lt;/strong&gt;Show View &lt;strong&gt;&amp;gt;&lt;/strong&gt; Other…&lt;strong&gt; &amp;gt;&lt;/strong&gt; SWT Tools &lt;strong&gt;&amp;gt;&lt;/strong&gt; Sleak.&lt;/p&gt;

&lt;p&gt;Sleak allows you to take snapshots and conveniently creates a difference for comparison. You could click on &lt;em&gt;‘Stacktrace’&lt;/em&gt; to access the stack trace utility that lets you view where the resource was allocated.&lt;strong&gt; &lt;/strong&gt;Other tools that could be used for Eclipse performance monitoring includes &lt;a href="https://profiler.netbeans.org/"&gt;NetBeans profiler&lt;/a&gt;&lt;strong&gt;, &lt;/strong&gt;&lt;a href="https://www.fusion-reactor.com/java-eclipse-apm/eclipse-performance-monitor/"&gt;FusionReactor&lt;/a&gt;&lt;strong&gt;, &lt;/strong&gt;&lt;a href="http://www.tagtraum.com/gcviewer.html"&gt;GC Viewer&lt;/a&gt;, &lt;a href="https://visualvm.github.io/"&gt;VisualVM&lt;/a&gt;, &lt;a href="http://jiprof.sourceforge.net/"&gt;&lt;strong&gt;JIP&lt;/strong&gt;&lt;/a&gt;, to name a few.&lt;/p&gt;

&lt;h2&gt;Minimize server downtime&lt;/h2&gt;

&lt;p&gt;The overall idea of monitoring performance in your Eclipse environment is to ensure you actively minimize server downtime, and speed up the time to resolve the issue. Even though there is an endless list of tools for performance monitoring on a Java development environment such as Eclipse, FusionReactor stands out amidst the crowd. Reason being that FusionReactor outstrips conventional monitoring since it actively tunes the Eclipse IDE, minimizes server downtime and accelerates time to resolution unlike any other Eclipse Performance Monitoring tool obtainable.&lt;/p&gt;

&lt;p&gt; &lt;a href="https://www.fusion-reactor.com/java-eclipse-apm/eclipse-performance-monitor/"&gt;Fusion Reactor’s&lt;/a&gt; performance monitor comes with a unique package that outclasses many conventional monitoring platforms. It gives you a broad and instant view of what is going on within your Eclipse environment so you can evaluate how much time is needed for each transaction.&lt;/p&gt;

</description>
      <category>eclipse</category>
      <category>performance</category>
      <category>monitoring</category>
    </item>
    <item>
      <title>Spring Boot Performance Monitoring</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Thu, 21 May 2020 08:56:36 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/spring-boot-performance-monitoring-1a9k</link>
      <guid>https://dev.to/fusion_reactor/spring-boot-performance-monitoring-1a9k</guid>
      <description>&lt;p&gt;&lt;strong&gt;Spring Boot Performance Monitoring.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Modern applications are highly distributed in nature, and thus they are often bundled with various dependencies like Database, caching and much more. Monitoring becomes essential due to the complexity of the implementation scheme that comes amid such advanced software. The Spring Boot Performance Monitor is a library kit that comes preinstalled with any Java Agent. It utilizes HTTP endpoints or JMX beans – because you can also configure the proxy profile to display Spring Boot JMX metrics, to enable us to interact with it. By way of this, we get firsthand reading of operational information about the running application&lt;strong&gt; &lt;/strong&gt;– health, metrics, info, dump, env, etc.  &lt;/p&gt;

&lt;p&gt;The Spring Boot Monitoring toolset provides you with an immediate and extensive insight into your Java applications running on the Spring MVC Framework. In its essence, the Spring Boot Performance Actuator is a unifier that introduces production-ready features into our application. With this dependency manager, such functionalities as gathering metrics, monitoring our apps, understanding traffic in addition to the state of our Database becomes inconsequential. The Spring Actuator discovers the application name through of the spring.application.name, property located in the application.properties file or the SpringBoot Application startup class, if the spring.application.name property is not defined.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;The Spring Boot Actuator&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Notably, Spring Boot supports many additional features that help you manage and monitor your application, from the development stage, extending to production. Such auditing exercise as metrics and health gathering are seamlessly implemented through the Spring Boot Performance Monitor. Once installed onto the classpath, this dependency supplies us with several endpoints right out of the box. &lt;/p&gt;

&lt;p&gt;As with several other Spring modules, we can extend and configure the Spring Boot Actuator in a variety of ways, of which we would be looking into shortly.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Getting Started&lt;/strong&gt;&lt;/h2&gt;

&lt;p&gt;Typically, a monitoring system would have three core components which include;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Dashboard for the visualization of data stored in the Database.&lt;/li&gt;
&lt;li&gt;A Metric Store – Time-series Database. For example, &lt;a href="https://prometheus.io/docs/introduction/overview/"&gt;Prometheus&lt;/a&gt;, &lt;a href="https://docs.influxdata.com/influxdb/v1.7/introduction/getting-started/"&gt;InfluxDB&lt;/a&gt;, &lt;a href="https://docs.timescale.com/latest/introduction"&gt;TimescaleDB&lt;/a&gt; etc.&lt;/li&gt;
&lt;li&gt;Applications that periodically supplies the Metric store with metrics data from the application’s local state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We can go on ahead to have other components installed as well like alerting – where the alert channel could be via Email, Slack or other conventional media. Alerting components would be sending alerts to the application owners or subscribers of events. For this guide, we would be using &lt;a href="https://grafana.com/oss/grafana/"&gt;Grafana&lt;/a&gt; as a dashboard and alerting system, &lt;a href="https://prometheus.io/"&gt;Prometheus&lt;/a&gt; as a metrics store system.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;The Requirements&lt;/strong&gt;&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;An IDE&lt;/li&gt;
&lt;li&gt;Java Development Environment&lt;/li&gt;
&lt;li&gt;Gradle&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we create a project from the &lt;a href="https://start.spring.io/"&gt;Spring Boot initializer&lt;/a&gt;, after which we add dependencies – as much as we want to. Next, we use the &lt;a href="https://micrometer.io/"&gt;Micrometer&lt;/a&gt; library, which is an instrumentation façade that provides bindings for many metric stores like Prometheus, New Relic, Datadog, to mention a few.&lt;/p&gt;

&lt;p&gt;Micrometre provides the following functionalities ready for use;&lt;/p&gt;

&lt;p&gt;1. JVM.&lt;/p&gt;

&lt;p&gt;2. Database.&lt;/p&gt;

&lt;p&gt;3. HTTP request.&lt;/p&gt;

&lt;p&gt;3. Cache system and related metrics.&lt;/p&gt;

&lt;p&gt;While some of these metrics are enabled by default, others are subject to customized settings. For this feature; we would employ the application.properties file to handle enabling, disabling and customization. We would also need to use the Spring Boot Actuator to expose the endpoint of the Metric Store – Prometheus.&lt;/p&gt;

&lt;h2&gt;&lt;strong&gt;Steps: –&lt;/strong&gt;&lt;/h2&gt;

&lt;ol&gt;&lt;li&gt;Add these following dependencies in build gradle file just as done in &lt;em&gt;line 7&lt;/em&gt; of figure 1.:&lt;/li&gt;&lt;/ol&gt;

&lt;ul&gt;&lt;li&gt;io.micrometer:micrometer-registry-Prometheus.&lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;org.springframework.boot:spring-boot-starter-actuator.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WBwxJpHd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/iPeJ5ufvZXxxfuORyHhTvLOxBVVG-RJV1a4DtSq3HC14e5-jTYyjyT3mo5Nb2dLGS2z-3FN250BFJkfTCICQBBjfFbUNBDB4TS7wG051oHSY42KIKKUxxSnq0ja5U0HGV7fGxUROg4JSXvGoSw" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WBwxJpHd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/iPeJ5ufvZXxxfuORyHhTvLOxBVVG-RJV1a4DtSq3HC14e5-jTYyjyT3mo5Nb2dLGS2z-3FN250BFJkfTCICQBBjfFbUNBDB4TS7wG051oHSY42KIKKUxxSnq0ja5U0HGV7fGxUROg4JSXvGoSw" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1:&lt;/em&gt;&lt;/p&gt;

&lt;ol start="2"&gt;&lt;li&gt;We would enable the Prometheus export functionality by adding the following line to the properties file.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--00RTvEJt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/pMJlK2dCzZr54Llcq1d7GSf059TunqUOMME5lwah_3el067COrmP3yy0lGGYITPFU8XFfft3H_GBf6LVWtUtHKP4N5DyaAiY9MnXhwDwMRyK_qtjMBvKWIoERFAvpHkR28WxcDrlwGMIVz30eA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--00RTvEJt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/pMJlK2dCzZr54Llcq1d7GSf059TunqUOMME5lwah_3el067COrmP3yy0lGGYITPFU8XFfft3H_GBf6LVWtUtHKP4N5DyaAiY9MnXhwDwMRyK_qtjMBvKWIoERFAvpHkR28WxcDrlwGMIVz30eA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2:&lt;/em&gt;&lt;/p&gt;

&lt;ol start="3"&gt;&lt;li&gt;As soon as the above command is enabled Micrometer automatically accumulates data about the application. This data can be viewed by visiting the &lt;em&gt;actuator / Prometheus &lt;/em&gt;endpoint – which is used in the Prometheus script to fetch data from our application servers.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;Although we have included the line mentioned above of code into the properties file, we still won’t be able to browse the Prometheus endpoint since it is disabled by default. For that, we head on to the management endpoint and add Prometheus in the list.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--frAAqDbH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/kDD6UESDEwHilGVPdp6G5oVMy9vNa-DJsi_5yUhXu9bqJ2XKI4Zu6cxts46XWk9vM-TxoSxaFs98qNuHzskcFiEaimJUEl_X4rcWgH360GZRv9pbnLyN3apir53FR3GieU4xZXWROkoYErfU1w" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--frAAqDbH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/kDD6UESDEwHilGVPdp6G5oVMy9vNa-DJsi_5yUhXu9bqJ2XKI4Zu6cxts46XWk9vM-TxoSxaFs98qNuHzskcFiEaimJUEl_X4rcWgH360GZRv9pbnLyN3apir53FR3GieU4xZXWROkoYErfU1w" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not all endpoints are enabled from actuator&lt;strong&gt; &lt;/strong&gt;as this could lead to a security loophole. Hence, we choose endpoints selectively, especially in a production environment. Even though we need to use these endpoints, it is not advisable to expose certain endpoints to the whole world as we place a whole lot of sensitive application data at risk. Therefore, it is best to use some proxy to hide these endpoints from the real world.&lt;/p&gt;

&lt;p&gt;Also, various components of the HTTP requests are customizable much like the &lt;a href="https://en.wikipedia.org/wiki/Service-level_agreement"&gt;SLA&lt;/a&gt; (Service&lt;strong&gt; &lt;/strong&gt;Level Agreement), percentile histogram should be computed or not. This can be done through the metrics—distribution properties.&lt;/p&gt;

&lt;p&gt;A sample application.properties can contain the following lines;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QYCmanAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/1UmRZ69kQTOjS1YxA9TOJBSZdErPAqE3c0uB6bCsYjAiHSBf90MZ_eavJhgnybCByoYbyoYCOVu9RUMzM7Kt0ZJHe8gZzjYq9Mf4PRR7hg7EnzGkzG5iqIZc8t4aca0Po4ozYiuYFXeLnmn8WQ" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QYCmanAe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/1UmRZ69kQTOjS1YxA9TOJBSZdErPAqE3c0uB6bCsYjAiHSBf90MZ_eavJhgnybCByoYbyoYCOVu9RUMzM7Kt0ZJHe8gZzjYq9Mf4PRR7hg7EnzGkzG5iqIZc8t4aca0Po4ozYiuYFXeLnmn8WQ" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 4:&lt;/em&gt;&lt;/p&gt;

&lt;ol start="4"&gt;&lt;li&gt;We can now run the application and navigate to the page &lt;a href="http://locahost:8080/actuator/prometheus"&gt;http&lt;em&gt;://locahost:8080/actuator/prometheus&lt;/em&gt;&lt;/a&gt;&lt;em&gt; &lt;/em&gt;on a browser&lt;em&gt;,&lt;/em&gt; to view our data.&lt;/li&gt;&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dVr3ZhTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/WhLFS2ApGgJ-CqYSDsQ4rjjtjEvk62ZHYTUeFXImF_TVgGfZiM8QdDAai3ULR8eO6ChP-I_LmVvgF51BnUWD9lMdnlcI-nuRWoQhWuA8l8Cw1lOdLS0NjR0GKWzwssuo1SOv1N0mY-EEc0NdFA" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dVr3ZhTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/WhLFS2ApGgJ-CqYSDsQ4rjjtjEvk62ZHYTUeFXImF_TVgGfZiM8QdDAai3ULR8eO6ChP-I_LmVvgF51BnUWD9lMdnlcI-nuRWoQhWuA8l8Cw1lOdLS0NjR0GKWzwssuo1SOv1N0mY-EEc0NdFA" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 5:&lt;/em&gt;&lt;/p&gt;

&lt;ol start="5"&gt;&lt;li&gt;The above data displays HTTP request detail, such as&lt;/li&gt;&lt;/ol&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;exception=None,&lt;/strong&gt; which means there is no exception just as the name implies. If any, we can use that to filter how many requests have failed due to that exception handler.&lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;method=GET &lt;/strong&gt;HTTP method name. &lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;status=200 &lt;/strong&gt;HTTP status code is 200.&lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;uri=/&lt;/strong&gt;&lt;a href="http://localhost:8080/actuator/prometheus"&gt;&lt;strong&gt;actuator/prometheus&lt;/strong&gt;&lt;/a&gt; displays the URL path.&lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;le=xyz &lt;/strong&gt;displays the processing time.&lt;/li&gt;&lt;/ul&gt;

&lt;ul&gt;&lt;li&gt;
&lt;strong&gt;N.0 &lt;/strong&gt;displays the number of times that endpoint was called.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;This data can be represented as a pie-chart or histogram that can be plotted in Grafana, for example, to &lt;em&gt;plot p95 over 5 minutes&lt;/em&gt; we can use the following query.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kd6BGSSc--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/3MP_qT_18aQWyr6-lCmh9ubYaw20umm4ehq7HlzZEUAU3eBNZFK0pxjaNdrAKKbo_RPO7c_2GVkapBGWkaptuGu0WIGxUF8OhEvW_OyVzEFU0maxj6fWZLhcOz2M5mBzCG8nfATPKdfDveah5A" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 6:&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;Custom Metrics&lt;/h2&gt;

&lt;p&gt;Most times, we might need to customize our metrics where some of such use-cases include the number of logged-in users, number of orders in the order queue, currently available stock details etc. Certain business use cases can be solved using custom metrics. Thus, Micrometer supports multiple kinds of metrics like Gauge, Counter, Timer, Long task timers, Distribution summaries etc. But for the scope of this walkthrough, we would focus mainly on Gauge and Counter. Gauge gives us instantaneous data like the length of a queue, whereas the counter is much like a uniformly increasing number, starting from one.&lt;/p&gt;

&lt;p&gt;For this, we’re going to create a demo stock manager that will store details in memory and would provide two functionalities:&lt;/p&gt;

&lt;p&gt;1. Add items.&lt;/p&gt;

&lt;p&gt;2. Get items.&lt;/p&gt;

&lt;p&gt;By that, we’ve created a single counter and an available gauge in&lt;strong&gt; the &lt;/strong&gt;init&lt;strong&gt; &lt;/strong&gt;method. Therefore, whenever getItems is called, we increase the counter as well as to measure the stock size. While a call to addItems updates the gauge.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6irXtCr6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/J7sn6r4rYkCuzyZfGlvmm-8d4FoRcKbqWcFo59CRTZxmQTnHciXMMiepHMgFcslfRxtF0IcD9etNIYvrQ60jBOOWAtGcJO2VFOYHfj-XUYcOacwKChv9SbiVY4gGtR3Tpa1wo7XTylJ3FxOiyg" alt=""&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DjKtuGff--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/uAYK9n4YGsPYDsKnl3ucCJpZzg5-0AHLTU__xaWn7shs-S4Pgu9_o0Hw4LlBppet08k_jD-u8T5_4tYqOVNfJ_GWrUU6aXYJZVlvlIv8W6-VPGrwAJKGMOa6OMiA2f_r7F-qztHNBei6Fg_wRg" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 7:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For demonstration purposes, we’ll add two endpoints to add items and get items.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--E8N6b6yL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/UcGM4z5qyEu9tYxKwcnP5GFut_oFPJaJp1M78UDXQ8eaBVv7nzuEVYIce5hyWOQweoQLGOVqcB-WY7Ch117q8GWD2t07tMiIcsTJaMdwvAAOlMNiCAH6BHUNAg4dWS6uBOXpq7HkfGmmpTyhwQ" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 8:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Firstly, we add ten items using two API calls.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Curl -X POST http://localhost:8080/stocks?items=1,2,3,4&lt;/li&gt;
&lt;li&gt;Curl -X POST http://localhost:8080/stocks?items=5,6,7,8,9,10&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now if we browse to Prometheus endpoints, then we can see the following data indicating that we currently have 10 items in the stock.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OSNGU8zS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/bYwedouuKPF15dulbyg4J87e6ybtsSIv-dHHOQ2r4_s87OjGQ7aGB7P1C3rQ3_En3Mr6YMbgwyWuw6afmSwB8SMPko8rgd-1ZLWJKyjp7jpcDXP-Bcp80EcUcy18Xppkl1f4vvy9R9K0u8lSyw" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 9:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, we’re going to place an order of size three;&lt;/p&gt;


http://localhost:8080/stocks?size=3


&lt;p&gt;Then again, if we browse Prometheus endpoint, then we get the following data that indicates stock size has been changed to seven.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xw8hgchd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/0PzUf170Fa0Ze_FT5H2ldAuR9v7xsudyUDsnPgQEiNJV0EKZcLXxY_-1OWN-1KKctt-mtKLt0_HQPu1s9ofSl_do-BpbrxNN3sCQSQSt4iNwcyGL1km95WDwY0nR_03ADlS2GEt2BzEDrZsKTw" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 10:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;We could also see that the counter has been updated with a value of 1. This indicates that just a single order has been placed.&lt;/p&gt;

&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3fTAvpMl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/fjE1vtZw68n9lH-IyQmdFoRUqgHPwrd34PPshk-Pjp49MDnln9RbdYkcU6cLAwkWJzE90klhPiYOmcONLwjY-DzTjx2SdNNbmW8qWUms6c6Y9lEEIYdtXjK8AAYhFT5mf3lB06Elk9nCYgU4hw" alt=""&gt;

&lt;p&gt;&lt;em&gt;Figure 11:&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Troubleshooting with Spring boot performance monitoring&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Other tools like FusionReactor permits you to troubleshoot the most complex of application performance issues. They were giving you instant insight into where problems are occurring or where your application is performing poorly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Critical Features for Spring Boot Performance Monitoring Tools&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Below are some of the critical features that FusionReactor provisions, along with the Spring Boot Performance Monitoring Tools.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://www.fusion-reactor.com/production-debugger"&gt;Production Debugger&lt;/a&gt; – Production, Safe / User, Controlled enclosed debug environment.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.fusion-reactor.com/production-java-profiler/"&gt;Code Profiler&lt;/a&gt; – Production Safe / instantly see performance bottlenecks.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.fusion-reactor.com/memory-profiler/"&gt;Memory Profiler&lt;/a&gt; – Production Safe / Real-time heap analysis to locate memory leaks.&lt;/li&gt;
&lt;li&gt;Instant Code decompilation.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.fusion-reactor.com/fusionreactor-metrics"&gt;JMX MBeans&lt;/a&gt; Support.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.fusion-reactor.com/crash-protection/"&gt;Crash Protection&lt;/a&gt; – Constant application availability and performance checking.&lt;/li&gt;
&lt;li&gt;Generate alerting for poor performance or when resource thresholds (memory/CPU) are reached.&lt;/li&gt;
&lt;li&gt;Isolate Long Running threads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One essential Actuator software for monitoring and interacting with your application is &lt;a href="https://www.fusion-reactor.com/spring/spring-boot-performance-monitoring/"&gt;FusionReactor&lt;/a&gt;, as it goes beyond “just monitoring”. FusionReactor instruments web-based transactions within the Spring 2.x and 3.x MVC Framework, hence provisioning a seamless transaction identification process. Also, proactively mitigates server downtime while expediting time to a resolution just like no other Spring Boot Performance Actuator on the market.&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>performancmonitoring</category>
    </item>
    <item>
      <title>Finding and fixing Spring Data JPA performance issues with FusionReactor</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Thu, 21 May 2020 08:20:42 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/finding-and-fixing-spring-data-jpa-performance-issues-with-fusionreactor-2df2</link>
      <guid>https://dev.to/fusion_reactor/finding-and-fixing-spring-data-jpa-performance-issues-with-fusionreactor-2df2</guid>
      <description>&lt;p&gt;Finding and fixing Spring Data JPA performance issues with FusionReactor&lt;/p&gt;

&lt;p&gt;For several years, &lt;a href="https://spring.io/projects/spring-data-jpa"&gt;Spring Data JPA&lt;/a&gt; has established itself as one of the most commonly used persistence frameworks in the Java world. It gets most of its features from the very popular &lt;a href="http://hibernate.org/orm/"&gt;Hibernate&lt;/a&gt; object-relational mapping (ORM) implementation. The ORM features provide great developer productivity, and the basic functionality is very easy to learn. &lt;/p&gt;

&lt;p&gt;But as so often, you need to know a lot more than just the basic parts if you want to build enterprise applications. Without a good understanding of its internals and some advanced features, you will struggle with severe performance issues. Spring Data’s and Hibernate’s ease of use sometimes make it way too easy to build a slow application.&lt;/p&gt;

&lt;p&gt;But that doesn’t have to be the case. With the right tools in place, you can identify performance problems easily and often even before they cause trouble in production. In this article, I will show you 3 of Hibernate’s and Spring Data’s most common performance pitfalls, how you can find them using &lt;a href="/java-monitoring/application-performance-monitor-for-java/"&gt;FusionReactor’s Java Monitoring&lt;/a&gt; or Hibernate’s statistics, and how you can fix them.&lt;/p&gt;

&lt;h2&gt;Pitfall 1: Lazy loading causes lots of unexpected queries&lt;/h2&gt;

&lt;p&gt;When you learn about Spring Data JPA and Hibernate performance optimizations, you always get told to use &lt;a href="https://thoughts-on-java.org/entity-mappings-introduction-jpa-fetchtypes/"&gt;FetchType.LAZY&lt;/a&gt; for all of your applications. This tells Hibernate to only load the associated entities when you access the association. That’s, of course, a much better approach than using FetchType.EAGER, which always fetches all associated entities, even if you don’t use them.&lt;/p&gt;

&lt;p&gt;Unfortunately, FetchType.LAZY introduces its own performance issue if you use a lazily fetched association. Hibernate then needs to execute an SQL query to get the associated entities from the database. This becomes an issue if you work with a list of entities, as I do in the following code snippet. &lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;[Code]
@RestController
@RequestMapping(path = "/concert")
public class ConcertController {

    Logger logger = Logger.getLogger(ConcertController.class.getSimpleName());

    private ConcertRepository concertRepo;

    @GetMapping
    public List getConcerts() {
        List concerts = this.concertRepo.findAll();

        for (Concert c : concerts) {
            logger.info("Concert "+c.getName()+" gets played by "+c.getBand().getName());
        }

        return concerts;
    }
}
[/Code]
&lt;/pre&gt;

&lt;p&gt;The findAll method of Spring Data’s JpaRepository executes a simple JPQL query that gets all Concert entities from the database and returns them as a List. Each of these concerts is played by band. If you set the FetchType of that association to FetchType.LAZY, Hibernate executes a SQL query to fetch the Band when you call the getter method on the Concert entity. If you do that for each Concert entity in the List, Hibernate will execute an SQL query for each Band who plays a concert. Depending on the size of that List, this will cause performance problems.&lt;/p&gt;

&lt;h2&gt;Find unexpected queries&lt;/h2&gt;

&lt;p&gt;This issue is relatively hard to find in your code. But it gets pretty easy if you monitor the queries executed by your application. &lt;/p&gt;

&lt;p&gt;Using FusionReactor, you can easily see all the SQL statements, which were performed by the getConcerts method. Based on the code, you would probably expect that Hibernate only performs 1 SELECT statement. But as you can see in the screenshot, Hibernate executed 10 SELECT statements because it had to get the associated Band entity for each Concert.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/05/ListOfSelectStatements.png" rel="prettyphoto"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--In7ReqFL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/05/ListOfSelectStatements-1024x555.png" alt="" class="wp-image-44358"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Or you can activate Hibernate’s statistics component and the logging of SQL statements. Hibernate then writes a log message at the end of each session, which includes the number of executed JDBC statements and the overall time spent on these operations.&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;[Code]
2020-04-11 15:28:04.293 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select concert0_.id as id1_2_, concert0_.band_id as band_id6_2_, concert0_.event_date_time as event_da2_2_, concert0_.name as name3_2_, concert0_.price as price4_2_, concert0_.version as version5_2_ from concert concert0_
2020-04-11 15:28:04.338 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.354  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 1 gets played by band 1
2020-04-11 15:28:04.355 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.358  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 2 gets played by band 2
2020-04-11 15:28:04.358 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.361  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 3 gets played by band 3
2020-04-11 15:28:04.362 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.364  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 4 gets played by band 4
2020-04-11 15:28:04.364 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.367  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 5 gets played by band 5
2020-04-11 15:28:04.367 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.369  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 6 gets played by band 6
2020-04-11 15:28:04.370 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.372  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 7 gets played by band 7
2020-04-11 15:28:04.372 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.375  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 8 gets played by band 8
2020-04-11 15:28:04.376 DEBUG 23692 --- [nio-7070-exec-1] org.hibernate.SQL                        : select band0_.id as id1_1_0_, band0_.description as descript2_1_0_, band0_.founding_date as founding3_1_0_, band0_.name as name4_1_0_, band0_.version as version5_1_0_ from band band0_ where band0_.id=?
2020-04-11 15:28:04.378  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 9 gets played by band 9
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 10 gets played by band 1
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 11 gets played by band 2
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 12 gets played by band 3
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 13 gets played by band 4
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 14 gets played by band 5
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 15 gets played by band 6
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 16 gets played by band 7
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 17 gets played by band 8
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 18 gets played by band 9
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 19 gets played by band 1
2020-04-11 15:28:04.379  INFO 23692 --- [nio-7070-exec-1] ConcertController                        : Concert concert 20 gets played by band 2
2020-04-11 15:28:04.463  INFO 23692 --- [nio-7070-exec-1] i.StatisticalLoggingSessionEventListener : Session Metrics {
    4769200 nanoseconds spent acquiring 1 JDBC connections;
    0 nanoseconds spent releasing 0 JDBC connections;
    2552200 nanoseconds spent preparing 10 JDBC statements;
    24755400 nanoseconds spent executing 10 JDBC statements;
    0 nanoseconds spent executing 0 JDBC batches;
    0 nanoseconds spent performing 0 L2C puts;
    0 nanoseconds spent performing 0 L2C hits;
    0 nanoseconds spent performing 0 L2C misses;
    0 nanoseconds spent executing 0 flushes (flushing a total of 0 entities and 0 collections);
    495900 nanoseconds spent executing 1 partial-flushes (flushing a total of 0 entities and 0 collections)
}
[/Code]&lt;/pre&gt;



&lt;h2&gt;Avoid additional queries&lt;/h2&gt;



&lt;p&gt;You can avoid this issue by using a JOIN FETCH clause that tells Hibernate to fetch the Concert and associated Band entities within the same query. You can do that by adding a method to your repository interface and defining a custom query using the @Query annotation.&lt;/p&gt;



&lt;pre class="EnlighterJSRAW"&gt;[Code]
public interface ConcertRepository extends JpaRepository {

    @Query("SELECT c FROM Concert c LEFT JOIN FETCH c.band")
    List getConcertsWithBand();
}



@RestController
@RequestMapping(path = "/concert")
public class ConcertController {

    Logger logger = Logger.getLogger(ConcertController.class.getSimpleName());

    private ConcertRepository concertRepo;

    @GetMapping
    public List getConcerts() {
        List concerts = this.concertRepo.getConcertsWithBand();

        for (Concert c : concerts) {
            logger.info("Concert "+c.getName()+" gets played by "+c.getBand().getName());
        }

        return concerts;
    }
}
[/Code]&lt;/pre&gt;



&lt;p&gt;Instead of 10 queries, Hibernate now gets all information with only 1 query.&lt;/p&gt;



&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/05/TooManyColumns-1.png" rel="prettyimage"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VAjkSi5U--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/05/TooManyColumns-1-1024x374.png" alt="" class="wp-image-44354"&gt;&lt;/a&gt;



&lt;h2&gt;Pitfall 2: Slow database queries&lt;/h2&gt;



&lt;p&gt;Slow queries are a common issue in all applications that store their data in a relational database. That’s why all databases provide an extensive set of tools to analyze and improve these queries.&lt;/p&gt;



&lt;p&gt;Even though we can’t blame Spring Data JPA or Hibernate for these issues, we still need to find and fix these queries in our application. And that’s often not as easy as it might seem. Hibernate generates the executed SQL statements based on our JPQL queries. In general, the executed queries are efficient. But sometimes, the additional abstraction of JPQL hides performance problems that would be obvious, if we would write the SQL query ourselves.&lt;/p&gt;



&lt;p&gt;The following JPQL query, for example, looks totally fine. We’re loading Concert entities and use multiple JOIN FETCH clauses.&lt;/p&gt;



&lt;pre class="EnlighterJSRAW"&gt;[Code]
public interface ConcertRepository extends JpaRepository {

    @Query("SELECT c FROM Concert c LEFT JOIN FETCH c.band b LEFT JOIN FETCH b.artists WHERE b.name = :band")
    Concert getConcertOfBand(&lt;a class="comment-mentioned-user" href="https://dev.to/param"&gt;@param&lt;/a&gt;
("band") String band);
}
[/Code]&lt;/pre&gt;



&lt;h2&gt;Find inefficient queries&lt;/h2&gt;



&lt;p&gt;The problem becomes obvious if you activate the logging of SQL statements in Hibernate or take a look at the executed JDBC statements in FusionReactor.&lt;/p&gt;



&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/05/JoinFetch1Statement.png" rel="prettyimage"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--o47rLBig--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/05/JoinFetch1Statement-1024x555.png" alt="" class="wp-image-44355"&gt;&lt;/a&gt;



&lt;p&gt;Hibernate has to select all columns mapped by an entity if you reference it in your SELECT clause or if you tell Hibernate to JOIN FETCH an association. In this case, the JPQL query that referenced 3 entities caused an SQL statement that selects 22 columns. These are a lot more columns than you might expect when you look at the JPQL query, and it gets worse if your entities map more columns or you JOIN FETCH more associations. &lt;/p&gt;



&lt;p&gt;The JOIN FETCH clause creates another issue: The result set contains the product of all joined records. Due to that, such result sets often contain thousands of records.&lt;/p&gt;



&lt;h2&gt;Improve inefficient queries&lt;/h2&gt;



&lt;p&gt;The only way to fix this performance problem is to avoid these kinds of queries. You could try to use a smaller, use case specific projection. Or you could split your query into multiple ones, e.g., one that fetches the Band entity with a JOIN FETCH clause for the artist attribute and another query for the Concert entity.&lt;/p&gt;



&lt;pre class="EnlighterJSRAW"&gt;[Code]
@RestController
@RequestMapping(path = "/concert")
public class ConcertController {

    Logger logger = Logger.getLogger(ConcertController.class.getSimpleName());

    private ConcertRepository concertRepo;
    
    private BandRepository bandRepo;

    public ConcertController(ConcertRepository orderRepo, BandRepository bandRepo) {
        this.concertRepo = orderRepo;
        this.bandRepo = bandRepo;
    }

    @GetMapping(path = "/name/{name}")
    public List getConcertOfBand(@PathVariable("name") String name) {
        Band b = this.bandRepo.getBandWithArtists(name);
        List concerts = this.concertRepo.getConcertsOfBand(name);
        
        if (concerts.isEmpty()) {
            throw new NoResultException();
        }
        return concerts;
    }
}
[/Code]&lt;/pre&gt;



&lt;p&gt;Pitfall 3: Too many write operations&lt;/p&gt;



&lt;p&gt;Another common performance pitfall is the inefficient handling of write operations for multiple entities. &lt;/p&gt;



&lt;p&gt;Let’s say you need to reschedule all concerts that were planned for the month of April. Using Java and Hibernate as your ORM framework, it feels natural to get a Concert entity object for each of these concerts and to change the eventDateTime attribute.&lt;/p&gt;



&lt;pre class="EnlighterJSRAW"&gt;[Code]
List&amp;lt;Concert&amp;gt; concerts = this.concertRepo.getConcertsScheduledFor(LocalDateTime.of(2020, 04, 01, 00, 00), LocalDateTime.of(2020, 04, 30, 23, 59));

for (Concert c : concerts) {
    c.setEventDateTime(c.getEventDateTime().plusMonths(1));
}
[/Code]&lt;/pre&gt;



&lt;h2&gt;Find inefficient write operations&lt;/h2&gt;



&lt;p&gt;But that would force Hibernate to execute an SQL UPDATE statement for each concert. Similar to the previous performance issues, this inefficiency is only visible, if you monitor the executed SQL statements.&lt;/p&gt;



&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/05/TooManyUpdates-1.png" rel="prettyimage"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cC-v3trR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/05/TooManyUpdates-1-1024x555.png" alt="" class="wp-image-44357"&gt;&lt;/a&gt;



&lt;h2&gt;Reduce the number of write operations&lt;/h2&gt;



&lt;p&gt;In SQL, you would write one SQL UPDATE statement that changes the value in the event_date_time column of all concerts that are scheduled for the month of April. That’s obviously the more efficient approach.&lt;/p&gt;



&lt;p&gt;You can do the same with a native query in Hibernate. But before you do that, you should always call the flush() and clear() methods on your EntityManager. That ensures that your 1st level cache doesn’t contain any local copy of the data that your query will change.&lt;/p&gt;



&lt;pre class="EnlighterJSRAW"&gt;[Code]
em.flush();
em.clear();
em.createNativeQuery("UPDATE concert SET event_date_time = event_date_time + INTERVAL '1 month'").executeUpdate();
[/Code]
&lt;/pre&gt;

&lt;h2&gt;Conclusion – Finding and fixing Spring Data JPA performance issues with FusionReactor&lt;/h2&gt;

&lt;p&gt;As you have seen, Hibernate is easy to use, but it can also cause some unexpected performance problems. These are often hard to find in your code but very easy to see as soon as you monitor the executed SQL statements. If you use the right logging configuration, you can find these statements in your application log file. Or you can use FusionReactor’s &lt;a href="http://www.fusion-reactor.com/news/database-monitoring/"&gt;Database Monitoring features&lt;/a&gt; and integrate these checks in your application monitoring strategy.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Understanding StackTraces in Java</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Thu, 21 May 2020 08:17:09 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/understanding-stacktraces-in-java-2pli</link>
      <guid>https://dev.to/fusion_reactor/understanding-stacktraces-in-java-2pli</guid>
      <description>&lt;p&gt;By guest author Thorben Janssen&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;StackTrace &lt;/em&gt;is one of the key concepts in Java. It’s a call stack for the thread and lists all method calls since the start of the thread. You have probably seen its textual representation in your log file or console output. It gets printed to &lt;em&gt;System.out&lt;/em&gt; whenever an exception is thrown and not handled by your application. The following snippet shows a typical example of such an output.&lt;br&gt;&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;java.lang.NumberFormatException: For input string: "123a45"
    at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
    at java.base/java.lang.Long.parseLong(Long.java:699)
    at java.base/java.lang.Long.valueOf(Long.java:1151)
    at org.thoughts.on.java.TestStackTrace.testStackTrace(TestStackTrace.java:17)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)
    ...&lt;/pre&gt;

&lt;p&gt;Using monitoring tools, like FusionReactor, or by calling the &lt;em&gt;getStackTrace()&lt;/em&gt; method on the current thread, you can access the &lt;em&gt;StackTrace &lt;/em&gt;for all active threads in your JVM. But there are other ways to examine and work with a StackTrace. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;In most cases, you will not look at a &lt;em&gt;StackTrace &lt;/em&gt;until you need to analyze an &lt;em&gt;Exception&lt;/em&gt;. The &lt;em&gt;StackTrace &lt;/em&gt;is part of an &lt;em&gt;Exception &lt;/em&gt;object, and it shows all method calls that happened until the exception was thrown. That shows you where the exception occurred and how you reached that specific part of the code. &lt;br&gt;&lt;/p&gt;

&lt;p&gt;In the next step, you can then analyze your code and find out what caused the exception. But that’s a topic for a different article. In this one, I want to tell you more about exceptions with their &lt;em&gt;StackTrace&lt;/em&gt;s and all the information they provide, so that you have a better understanding of StackTraces in Java.&lt;/p&gt;

&lt;h2&gt;Exceptions in Java&lt;/h2&gt;

&lt;p&gt;An exception gets thrown whenever an error happens within a Java application. It gets represented by an object of the &lt;a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/StackTraceElement.html"&gt;&lt;em&gt;java.lang.Exception&lt;/em&gt;&lt;/a&gt; class or one of its subclasses. The JDK provides you with a huge set of different &lt;em&gt;Exception &lt;/em&gt;classes. If you want, you can also implement your own business exceptions.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;It’s a general &lt;a href="https://howtodoinjava.com/best-practices/java-exception-handling-best-practices/"&gt;best practice&lt;/a&gt; to use the most specific exception class for each error. A typical example for that is the &lt;a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/Long.html#valueOf(java.lang.String)"&gt;&lt;em&gt;valueOf&lt;/em&gt;&lt;/a&gt;&lt;em&gt; &lt;/em&gt;method of the &lt;em&gt;java.lang.Long&lt;/em&gt; class. You can call it with a &lt;em&gt;java.lang.String&lt;/em&gt; and it throws a &lt;a href="https://docs.oracle.com/en/java/javase/13/docs/api/java.base/java/lang/NumberFormatException.html"&gt;&lt;em&gt;java.lang.NumberFormatException&lt;/em&gt;&lt;/a&gt; if the String has a format that can’t be parsed to a &lt;em&gt;Long&lt;/em&gt;. The &lt;em&gt;NumberFormatException &lt;/em&gt;is a subclass of the &lt;em&gt;IllegalArgumentException&lt;/em&gt;, which indicates that an invalid argument value was passed to a method. As you can see, the &lt;em&gt;IllegalArgumentException &lt;/em&gt;would describe the error situation, but the &lt;em&gt;NumberFormatException &lt;/em&gt;is more specific and should be preferred.&lt;br&gt;&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;private Long parseToLong(String s) {
    return Long.valueOf(s);
}

Long l;
try {
    l = parseToLong(s);
} catch (NullPointerException npe) {
    // handle NullPointerException
    log.error("No value provided. Using 0 as default.", npe);
    l = 0L;
}
log.info(l);&lt;/pre&gt;

&lt;p&gt;Using the most specific exception class makes your code easier to read, and it enables you to implement a different catch clause for each exception class. This allows you to handle each error situation differently.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;You could, for example, decide to throw a &lt;em&gt;NullPointerException &lt;/em&gt;if the provided String is null and throw a &lt;em&gt;NumberFormatException &lt;/em&gt;if it doesn’t have the correct format.&lt;br&gt;&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;private Long parseToLong(String s) {
    if (s == null) {
        throw new NullPointerException("String can't be null");
    }
    return Long.valueOf(s);
}&lt;/pre&gt;

&lt;p&gt;In the code that calls this method, you can then implement 2 separate &lt;a href="https://java-tutorial.org/exception-handling.html"&gt;catch blocks&lt;/a&gt; that handle the &lt;em&gt;NullPointerException &lt;/em&gt;and the &lt;em&gt;NumberFormatExceptions &lt;/em&gt;in different ways. I did that in the following code snippet to provide different error messages for both situations. But you could, of course, use the same approach to implement a more complex error handling or to provide a fallback to default values.&lt;br&gt;&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;Long l;
try {
    l = parseToLong(s);
} catch (NullPointerException npe) {
    // handle NullPointerException
    log.error("No value provided. Using 0 as default.", npe);
    l = 0L;
} catch (NumberFormatException nfe) {
    // handle NullPointerException
    log.error("Provided value was invalid. Using 0 as default.", nfe);
    l = 0L;
}
log.info(l);&lt;/pre&gt;

&lt;h2&gt;The structure of a StackTrace&lt;/h2&gt;

&lt;p&gt;In the previous code snippet, I wrote log messages that contained the caught exception objects. The following snippet shows an example of such a message in the log file. Your application writes a similar message for all unhandled exceptions to your console.&lt;br&gt;&lt;/p&gt;

&lt;pre class="EnlighterJSRAW"&gt;15:28:34,694  ERROR TestStackTrace:26 - Provided value was invalid. Using 0 as default.
java.lang.NumberFormatException: For input string: "123a45"
    at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
    at java.base/java.lang.Long.parseLong(Long.java:699)
    at java.base/java.lang.Long.valueOf(Long.java:1151)
    at org.thoughts.on.java.TestStackTrace.parseToLong(TestStackTrace.java:39)
TestStackTrace.java:39
    at org.thoughts.on.java.TestStackTrace.testStackTrace(TestStackTrace.java:18)
TestStackTrace.java:18
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:567)&lt;/pre&gt;

&lt;p&gt;As you can see, the log message contains a long list of class and method names. This is the textual representation of the &lt;em&gt;StackTrace &lt;/em&gt;of the exception. Whenever a new method gets called, it gets added to the top of the stack, and after it got executed, it gets removed from the stack. Based on this approach, the last method that got called before the exception occurred is at the top of the &lt;em&gt;StackTrace &lt;/em&gt;and logged first. The following elements in the &lt;em&gt;StackTrace &lt;/em&gt;and lines in the log file show which methods were previously called to reach the part of the code that caused the exception.&lt;/p&gt;

&lt;h2&gt;Using StackTraces to analyze incidents&lt;/h2&gt;

&lt;p&gt;If you take another look at the previously shown &lt;em&gt;StackTrace&lt;/em&gt;, you can see that the exception was created in the &lt;em&gt;forInputString &lt;/em&gt;method of the &lt;em&gt;NumberFormatException &lt;/em&gt;class. The actual problem occurred in the &lt;em&gt;parseLong &lt;/em&gt;method of the &lt;em&gt;Long &lt;/em&gt;class, which was called by the &lt;em&gt;valueOf &lt;/em&gt;method of the same class, which was called by &lt;em&gt;parseToLong &lt;/em&gt;method of my &lt;em&gt;TestStackTrace &lt;/em&gt;class. As you can see, the StackTrace provided by the &lt;em&gt;NumberFormatException &lt;/em&gt;clearly shows where the exception happened and which chain of method calls lead to it.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;This information is a good start to analyze an exception and to find the actual cause of it. But quite often, you will need more information to understand the issue. The &lt;em&gt;Exception &lt;/em&gt;object and its &lt;em&gt;StackTrace &lt;/em&gt;only describe which kind of error occurred and where it happened. But they don’t provide you with any additional information, like the values of certain variables. This can make it very hard to reproduce the error in a test case.&lt;/p&gt;

&lt;h2&gt;How FusionReactor can help&lt;/h2&gt;

&lt;p&gt;FusionReactor can provide you more information about the error situation. If you want, you can even debug the issues on your live system when it occurs next time.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/01/Error-details.png" rel="prettyphoto"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--31K7ovkr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/01/Error-details.png" alt="FusionRector Debugger error" class="wp-image-43457" width="602" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only thing you need to do is to log into the web interface of the FusionReactor instance that monitors your application, select the exception from the “Error History” and go to the “Error Details” tab. There you can activate the debugger for this specific exception.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;After you’ve done that, FusionReactor will send you &lt;a href="https://intergral.atlassian.net/wiki/spaces/FR82/pages/245553082/Production+Debugger+Email+Alert"&gt;an email&lt;/a&gt; when the exception occurs again and pause the thread for a configured amount of time. The email contains the stack trace and information about the variable context. As long as the thread is paused, you can also use FusionReactor’s &lt;a href="https://www.fusion-reactor.com/production-debugger-3/production-debugging-java/"&gt;Production Debugger&lt;/a&gt; to debug the error in a similar way as you would in your IDE without affecting any of the other threads of your application.&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.fusion-reactor.com/wp-content/uploads/2020/01/FusionReactor-Debugger.png" rel="prettyphoto"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C0d788lv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://www.fusion-reactor.com/wp-content/uploads/2020/01/FusionReactor-Debugger.png" alt="FusionReactor Debugger" class="wp-image-43463" width="602" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>stacktraces</category>
      <category>java</category>
    </item>
    <item>
      <title>How to Find Memory Leaks in Java Web Applications</title>
      <dc:creator>FusionReactor</dc:creator>
      <pubDate>Thu, 21 May 2020 08:11:06 +0000</pubDate>
      <link>https://dev.to/fusion_reactor/how-to-find-memory-leaks-in-java-web-applications-2aej</link>
      <guid>https://dev.to/fusion_reactor/how-to-find-memory-leaks-in-java-web-applications-2aej</guid>
      <description>&lt;p&gt;Finding memory leaks in your Java application could be a needle in a haystack exercise if you are a rookie or intermediate Java developer who is yet to know their way around the Java Virtual Machine (JVM) production environment. However, depending on your profiling tool, you can easily analyze your Java memory consumption, while obtaining instantaneous insights into the heap in your Java production applications. But before we go into the details on how to find memory leaks in java web applications, let’s get into what a Java memory leak is, the possible causes of such leakages and remediation procedures to handle this.&lt;/p&gt;

&lt;h2&gt;Java Memory Leak&lt;/h2&gt;

&lt;p&gt;A memory leak is simply caused by reference chaining which is held up in the PermGen and cannot be garbage-collected. Sounds gibberish, right? Well, keep calm and follow-through while I explain further. Since web containers utilizes a class to class loader mapping system to isolate web applications and because a class is uniquely identified by its name and the class loader that loaded it. Hence, you can have a class with the same name, loaded multiple times in a single JVM – with each class having a distinct class loader.&lt;/p&gt;

&lt;p&gt;Whereas; &lt;/p&gt;

&lt;p&gt;An object retains a reference to the class (java.lang.Class) that instantiated it.&lt;br&gt;
The class in turn retains a reference to the class loader that loaded it.&lt;br&gt;&lt;br&gt;
The class loader retains a reference to every class it loaded.&lt;br&gt;
This potentially becomes a very big reference graph to handle on a long run. Not to forget that these classes are loaded directly into the PermGen. Therefore, retaining a reference to a particular object from a web application pins every class loaded by the web application in the PermGen. These references often remain even after a web application is reloaded and with each new reload, more classes get pinned or stuck up in the PermGen – which in due course gets full.&lt;/p&gt;

&lt;h2&gt;What is a PermGen?&lt;/h2&gt;

&lt;p&gt;PermGen, short for Permanent Generation is a heap in the JVM dedicated to storing the JVM’s internal representation of Java Classes – and also detained string instances. In simple terms; it is an exclusive heap location separate from the primary Java heap, where the JVM registers metadata related to the classes which have been loaded. &lt;/p&gt;

&lt;p&gt;Although, most Java Servlet containers and WebSocket technologies enable the org.apache.catalina.core.JreMemoryLeakPreventionListener Class by extension such as Apache Tomcat 7.0 and upwards. Nonetheless, the inclusion of this memory leak handler wouldn’t suffice in the event of a more sophisticated such as PermGen errors on reload and bug interference caused by the application itself. This gets a little more interesting when the Tomcat servlet isn’t causing the leak, neither is the application (at least not directly) but rather a bug in the JRE code triggered by some third-party library. &lt;/p&gt;

&lt;p&gt;With the advent of the Java Development Kit – JDK6 (Update 7 or later), comes a handy tool that ships with the JDK and makes life a whole lot easier for us. This tool is called the VisualVM; which is a graphical tool that seamlessly connects to any JVM and allows you to expel unwanted garbage from the JVM’s heap besides letting you navigate that heap. In a Tomcat servlet, a class loader for a web application is also a class called org.apache.catalina.loader.WebappClassLoader. Wherefore, if our Tomcat instance has just a single web application deployed, then there should only be one instance of this class in the heap. But in the event that there are more, then we have a leak.  &lt;/p&gt;

&lt;p&gt;STEPS ON HOW TO FIND MEMORY LEAKS IN JAVA WEB APPLICATIONS&lt;br&gt;
Now that we have that out of the way, let’s quickly dive into the steps on how to detect and avoid Java memory leaks. Let’s immediately lucubrate on how we can use VisualVM to figure this out.&lt;/p&gt;

&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Open the command prompt terminal and type in the following command below to Start Visual VM;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;${JAVA_HOME}/bin/jvisualvm&lt;/p&gt;

&lt;p&gt;A window similar to figure 1 would pop up.&lt;/p&gt;

&lt;p&gt;How to Find Memory Leaks in Java Web Applications&lt;br&gt;
Figure 1: The Java VisualVM&lt;br&gt;
 &lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MrcHQwKJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rc5gt2sfqce97o87t30g.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MrcHQwKJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rc5gt2sfqce97o87t30g.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click on Tomcat from the sidebar on the left-hand side then select ‘Heap Dump’.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;How to Find Memory Leaks in Java Web Applications&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Rq1Mz8kV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ui8j2rfcbk0unruw6v5p.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Rq1Mz8kV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ui8j2rfcbk0unruw6v5p.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Figure 2: Heap Dump: Click on the ‘OQL Console’ button. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Click on the ‘OQL Console’ button at the top of the Heap Dump navbar. This opens up a console that allows you to query the heap dump. For this exercise, we want to locate all instance of org.apache.catalina.loader.WebappClassLoader.So enter the command below in the resulting console;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;select x from org.apache.catalina.loader.WebappClassLoader x&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--gksfp15B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aujp6k6m2fo0k9i5wnus.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--gksfp15B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/aujp6k6m2fo0k9i5wnus.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Figure 3: ‘OQL Query Editor Console’: Type in the above command and click execute&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In this case, VisualVM found two instances of the web application class loader; one slated for the web application itself and the other for the Tomcat manager application. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Use the Tomcat manager application to restart the web application at &lt;a href="http://localhost:8080/manager/html"&gt;http://localhost:8080/manager/html&lt;/a&gt; and take yet another heap dump of the Tomcat process.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0haPG4wK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5q3rusn80uycr51ztta2.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0haPG4wK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5q3rusn80uycr51ztta2.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Figure 4: Restart the web application and navigate back to the ‘OQL Console’ to repeat step 3 again&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Notice the inclusion of an extra instance from the above step. This is because one of these 3 instances was supposed to be collected by the garbage-collector, yet it wasn’t. Thanks to Tomcat we can easily tell which instance was not garbage-collected as all active class loaders are provisioned with the field name: ‘started’ set to ‘true’. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In order to find the invalid instance, click through each class loader instance until you find the one whose ‘started’ field is set to ‘false’.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--mdpMCK87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7uyqh4c5fj9ircr6240r.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--mdpMCK87--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7uyqh4c5fj9ircr6240r.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Figure 5: Click through each class loader instance in the heap dump to spot the faulty one – with the ‘started’ field set to false&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Now that we have spotted the class loader that causes the leak, we need to determine what object is holding a reference to the class loader. Evidently, a good number of objects would be referenced by many other objects, but in all essence, only a limited number of these objects would form the root of the graph of references. These are particularly the object(s) we are interested in.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Therefore, on the bottom pane of the instances tab, right-click on the object instances that forms the root of the reference graph and select ‘Show nearest GC root’. &lt;/p&gt;

&lt;p&gt;The resulting window should look like this; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LXjuR7co--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/immc7jm3nhscsg2odc5e.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LXjuR7co--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/immc7jm3nhscsg2odc5e.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Figure 6: Right-click on the object instances that forms the root of the reference graph and select ‘Show nearest GC root’.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Right-click on the instance and select ‘Show Instance’.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sX9W8TVL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/65v0ti341m7tc7guql8p.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sX9W8TVL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/65v0ti341m7tc7guql8p.JPG" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
Figure 7: Right-click on the instance and select ‘Show Instance’.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;From this, we can deduce that this is an instance of the sun.awt.AppContext type. We could also see that the contextClassLoader field in AppContext is holding a reference to the WebappClassLoader. Hence, this is the errant reference causing the memory leak. Now we figure out what instantiated the sun.awt.AppContext type, for starters.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Firstly, we restart the Tomcat in debug mode with the following code;&lt;/p&gt;

&lt;p&gt;export JPDA_SUSPEND=y&lt;/p&gt;

&lt;p&gt;${TOMCAT_HOME}/bin/catalina.sh jpda&lt;/p&gt;

&lt;p&gt;Then, we move on to remotely debug the class loading sequence – in which case I would be using Eclipse to do this. Also, we need to set a class loader breakpoint on sun.awt.AppContext;&lt;/p&gt;

&lt;p&gt;Use the Open Type Command (Shift+Control+T) to navigate to the sun.awt.AppContext type.&lt;br&gt;
Right-click on the class name in the Outline pane and choose ‘Toggle Class Load Breakpoint’.&lt;br&gt;
Thereafter, we need to trigger the class loading sequence by connecting the debugger to the Tomcat instance and having the debugger come to a halt exactly at the point where the sun.awt.AppContext is loaded;&lt;/p&gt;

&lt;p&gt;Figure 8: Connecting the debugger to the Tomcat instance and set the debugger to stop right after where the sun.awt.AppContext is loaded.&lt;br&gt;
And there you go! It has been instantiated by the JavaBeans framework, which in this instance is being used by the Oracle Universal Connection Pool (UCP). We could therefore notice that the contextClassLoader is a final field and it looks like AppContext appears to be a singleton; so we can assume that this field is set once and once only during the instantiation of AppContext.&lt;/p&gt;

&lt;p&gt;so we can infer that this field is set once and once only during the instantiation of.&lt;/p&gt;

&lt;p&gt;I conveniently added the above code to my servlet context listener, causing it to execute during application start-up and it had the desired effect of remedying this particular memory leak.&lt;/p&gt;

&lt;h2&gt;How to Find Memory Leaks in Java Web Applications – Summary &lt;/h2&gt;

&lt;p&gt;In summary, JEE Applications’ PermGen ‘out of memory errors’ usually reside in the application itself (or a library used by the application) and is often compounded by classes in the JRE library holding references to the web application class loader or objects instantiated by the web application class loader.&lt;/p&gt;

&lt;p&gt;The overall process of finding the causative agent of a leak is to utilize a Java Application Performance Monitoring (APM) solution. Just like &lt;a href="https://www.fusion-reactor.com/technologies/java-monitoring/"&gt;Fusion-Reactor&lt;/a&gt;’s heap analyzer to source for uncollected web application class loader instance(s) and subsequently source for the root GC object that is directly or indirectly holding onto the class loader. When you find this object, you can now use the APM’s inbuilt debugger to discover how this object is being instantiated and then devise a means to modify its conventional behavior. This is done so that it does not continue to hold on to the class loader reference forever.&lt;/p&gt;

</description>
      <category>java</category>
      <category>memory</category>
      <category>performance</category>
    </item>
  </channel>
</rss>
