JVM Tuning and JDBC Performance in JAVA

Posted By : Amit Kumar Gupta | 30-Nov-2018

In this blog, we will see JVM tuning and architecture changes to increase the performance of JAVA application

JVM Tuning
Heap Size standardization


Determination of correct JVM heap size for a production system isn't a simple exercise. the primary step is to see foreseeable memory needs by responsive following questions:

How many totally different applications we have a tendency to square measure going to deploy to one JVM method, e.g., the number of EAR files, WAR files, jar files, etc.?
How many Java categories are going to be doubtless loaded at runtime; as well as third-party API’s?
Estimate the footprint necessary for in-memory caching, e.g., internal cache information structures loaded by our application (and third party API’s) like cached information from a information, information browse from a file, etc.
Estimate the number of Threads that the applying can produce.
These numbers square measure tough to estimate while not some real-world testing.

The most reliable thanks to getting a decent plan regarding what the applying desires square measure, is to run a sensible load check against the applying and track metrics at runtime. The Gatling-based tests we have a tendency to mentioned earlier square measure a good thanks to trying this.

Choosing the Right Garbage Collector


Stop-the-world garbage pickup cycles wont to represent a large issue for the responsiveness and overall Java performance of most client-facing applications.

However, the present generation of garbage collectors has largely resolved that issue and, with correct standardization and size, will cause having no noticeable assortment cycles. That being same, it will take AN in-depth understanding of each GHz on the JVM as a full, however additionally the precise profile of the applying – to urge there.

Tools sort of a profiler, heap dumps, and long-winded GHz work will definitely facilitate. And again, these all ought to be captured on real-world load patterns, that is wherever the Gatling performance tests we have a tendency to mentioned earlier are available.

For a lot of data around totally different Garbage Collectors, have a glance at this guide here.

JDBC Performance


Relational databases square measure another common performance drawback in typical Java applications. so as to urge to a decent time interval for a full request, we've to naturally verify every layer of the applying and take into account however the code interacts with the underlying SQL dB.

Connection Pooling


Let’s begin with the well-known proven fact that information connections square measure costly. An association pooling mechanism could be a nice opening move towards addressing that.

A quick recommendation here is HikariCP JDBC – a really light-weight (at roughly 130Kb) and lightning quick JDBC association pooling framework.

JDBC Batching


Another facet of the approach we have a tendency to handle persistence is attempting to batch operations where doable. JDBC batching permits America to send multiple SQL statements in a very single information roundtrip.

The performance gain will be important each on the motive force and also the information aspect. PreparedStatement is a superb candidate for batching, and a few information systems (e.g., Oracle) support batching for ready statements solely.

Hibernate, on the opposite aspect, is a lot of versatile and permits America to change to batching with one configuration.

Statement Caching


Next, statement caching is otherwise to doubtless improve the performance of our persistence layer – a less-known performance optimization that you simply will simply cash in of.

Depending on the underlying JDBC Driver, you'll cache PreparedStatement each on the client-side (the Driver) or databases-side (either the syntax tree or perhaps the execution plan).

Scale-Up and Scale-Out


Database replication and sharding also are glorious ways in which to extend output, and that we ought to cash in of those battle-tested fine arts patterns to scale persistent layer of our enterprise application.

About Author

Author Image
Amit Kumar Gupta

Amit is a bright Web App Developer, and has good knowledge of Java,Machine Learning, Python, Algorithm. His hobbies are playing badminton and reading novel.

Request for Proposal

Name is required

Comment is required

Sending message..