How to improve performance of java application

Asked on March 27, 2014
How to improve  performance of java application?
What to check if I want to improve the performance of the application
in which I am working.
Any suggestion?

Replied on April 02, 2014
1.    Tune your server. If any  web or application server is taking high CPU utilization, tune  your server
2.    Use any profiling tool and identify which areas of code are taking more time and start optimizing that code if possible. Avoid using synchronized block or method. Use proper logging that takes minimum execution time and memory like log4j.  When the resources are being created and destroying time to time which is costly, then use pool like thread pool.  Do not keep many objects in the session that will consume your memory and will be time taking in serialization and dieselization also.  Try to minimize session time out. In servlet, try to use forward not send Redirect if possible. sendRedirect method sends request to client that takes time. In input output operation,  java stream is better than Reader and Writer.

3.    Tune the number of threads which can be served by the server. It should be high enough to serve the request but it should not be so high that it becomes loads over the server.

4.    If there is database being used, then tune your sql query.   If enough memory, increase memory for query.  Also allow the max worker thread.  Avoid using select *, use the specific column name in select query, add indexes in database.

Write Answer

©2024 | Privacy Policy | Contact Us