Thursday, March 12, 2015

6 Most Common Java Performance Problems

 In today’s age, making an application fast is as important as making it functional. Java application developers are always concerned about the performance of their applications. Most of these performance issues have common root causes. So performance analysts have addressed this issue in three basic categories, Database problems, memory problems and concurrency problems. Today we have listed six common Java performance problems.
java, performance, application performance, java performance, java problems, most common Java problems, persistence configuration, caching, application optimization, garbage collection, memory leaks, thread deadlocks, thread gridlocks.




1. Persistence Configuration: 

Advance options like Hibernate and JPA implementation provide fine tuning of database access but, there are some more options such as eager or lazy fetching that prolong the database response. Eager fetching makes less but complex database calls while, lazy fetching makes database calls more simple and fast. However, when the load of application increases, it causes database load. Developers need to understand persistence technology to avoid such problems. Using correct configuration options can fix this problem.

2. Caching: 

Caching is used to optimise the application response time. There is large in-memory data that enables fast access to persisted cache. The problem starts when no caching is used. Sometimes cache exhausts the memory. A properly configured cache doesn't cause any problem in application performance. Synchronization is another problem that occurs in distributed caching. Synchronization is important when caches are communicating with multiple server. Cache update is sent to caches in all servers to achieve the consistency. You should examine if your database really needs caching or not. You can determine cache size and ratio metrics. Proper planning of cache is very important to avoid cace problems.

3. Garbage Collector: 

The main functionality of Garbage collector is to reclaim the memory. The procedure is quite lengthy and Garbage collection may temporarily terminate all running threads. Garbage collector requires big response times and it causes CPU spikes. Developers can configure their verbosegc params to fix the system downtime. However, it is next to impossible to avoid the problems caused by Garbage collector. It is advised to limit the process by configuring heap size and JVM.

4. Memory Leaks: 

Memory leaks commonly occur in all the apps. Memory leaks in Java are different in some ways than C or C++. They are more related to reference management issue. In Java apps, reference to an object exists even if it is not required in program again, this leads to OutOfMemory error and forces JVM to restart. Developers can configure JVM params in different way to deal with memory leaks. Make sure that you pay attention to all details related to memory leak, sensitive Java collections and session management while coding an app in Java.

5. Thread Deadlocks: 

Thread deadlocks occur when more than two threads are accessing same resource and one is waiting for the other to release a resource. JVM exhausts all threads when deadlock occurs, this leads to slow processes in application. The only way to solve deadlock problem is to capture the thread dump when threads are deadlocked. You can avoid this problem by making application resources as immutable as possible.

6. Thread Gridlocks: 

This issue occurs when there is load on synchronisation, too much of time is spent on waiting for single resource. Thread gridlock leads to slow response time and low CPU utilization. There are many threads that accesss same code and wait for the one to finish. You can solve this issue by checking where your threads and waiting. Eliminating thread synchronization according to business requirement can solve the slow processes issue caused by Thread Gridlocks. 






This article originally published by:-efytimes

No comments:

Post a Comment