Tuesday, March 4, 2008

Java Application Performance improvement

This blog provides with the tips for Java Application Performance improvement.
These are some of the lessons/thoughts learned from experiences.

Here we go :

  1. Often even the experienced developer makes the mistake of adding the code which is either unnecessary or function calls which are not necessary.
  2. When database is the issue :
    1. Use the batching to commit,play with batch size and see the result.
    PreparedStatement.addBatch
    2. Create indexes on the table also see that not many indexes are created as index comes with some overhead while insert and delete ,as it has to reorder the index.
  3. When the process is intensive and involves processing of thousands and millions of records records,
    There are 3 strategies
    1. Delay the sub-process
    2. Divide and Conquer
    3. Hybrid of above both

1. Delay the sub-process : One of the delaying sub-process could be to delay the committing sub-process by adding to batch of batchSize(e.g..100) records.
2. Divide and Conquer : This can be archived in 3 ways;
1. Let say you have 100,000 records to process,delegate to 2 or 3 threads to process the records.
2. Divide between machines : Quoting the same example of processing 100,000 records can be divided between the machines. In this case process will use different CPU cycles for processing.

I suggest the combination of threads and RMI could be used for Divide and Conquer and see that there is not much network latency between the machines. RMI Example quoted in RMI Tutorial is good example to use a costly resources(such as Sun Solaris box with high configuration).

This strategy is best implemented with application hosted in distributed environment with Load Balancing.

Conculsion :
You dont need humungus boxes(machines) to process,divide the work between threads and boxes, dont believe refer google architecture.

More in my next blogs....

Post your comments and suggestion,what do you think?

No comments: