Meta

Subscribe

Posts Tagged ‘Performance’

Writing an application is an easy task but its performance tuning and the optimization is a bit tricky job. To make it bit more simple I have listed few concrete options below:

Do not take every thing as granted.

Use buffering where possible specially in i/o operations.

Use batches for bulk db operations.

Avoid object creation in loops if possible.

Synchronization should be minimized where possible.

Put only non-avoidable data inside sessions, and remove them right after their usage.

Choose the best fit XML parser, like if you have no need to load full document then DOM based parsers could be avoided.

Remove unnecessary layers of your application, here you need good architectural skills to decide what should be removed.

Remove unnecessary libraries and relevant code could be copied to your app if its really small. This could be helpful in avoiding PermGen errors.

Make smart selection of collections. Like hashing based collections are the best candidate for implementing caching.

Use of caches could improve the response time.

Use standard implementation of caching instead of implementing your own, but of course it depends on your requirement. Like ORM mapping tools accompany standard caching options.

Use of appropriate design patterns could also optimize your code, like java.io uses decorator pattern to provide added functionality (like buffering etc.) on demand basis, instead of making every thing available either needed or not.

Fetch what is required, instead of loading every thing relevant or irrelevant.

Move db intensive operations into the database stored procedure, but it has a portability concerns which needs to be prioritize.

Make use of paging when you are working with large data sets, this could also improve the response time.

Joins using correct indexes could speed up performance.

Set appropriate size of heap memory, like using a default heap memory size is non-sense for the application having hundreds of hibernate mapping files and lot of xml parsing functionality etc.

Choose right application server based on your application requirements, if you can live with Tomcat then why WAS.

Carefully set the size of connection pool, based on your application usage.

Table Indexes should be added.

De normalization could also be an option, but this needs to be decided carefully.

This is not you who is always wrong, check your third party libraries if they are causing performance/memory issues, normally such issues are fixed in the new versions.