Configuration management best practices March 30, 2007
Posted by Saravanan in Programming, Software.add a comment
In my earlier post, I discussed about how the configurations can be managed in an enterprise application easily. This is an exclusive post to discuss about the configuration management best practices based on my experience.
1. Put comments for every configuration parameters. This applies for configurations as it applies for code. The operations team who will manage it cannot understand it without comments. Also if new instance is setup, you may not be involved and comments will help operations to decide the new value.
2. Where ever possible, put the example values in comments and how the application will be behave if the value is changed
3. If the configuration file is shared with other components, maintain a copy of parameters used by your application. This will help you if you want to maintain the configurations separately.
4. Though java properties files are good, to maintain large configuration information, I prefer Windows INI format for its grouping. Let the configuration readers return the values in java properties format.
5. Have a singleton configuration loader to manage the configurations. Application will always get the value from configuration loader and NOT cache it locally
6. Implement JMX console to refresh configuration values in singleton loaders so that application need not be restarted.
7. You can also put a monitor to load configurations if the file is modified. This will avoid the server restart to apply the new configuration values.
8. The last but the most important one – NEVER modify your configuration file without taking a backup. If the file gets messed up and without backup, your service will be severely impacted and you cannot meet your SLA.
Effective Java March 14, 2007
Posted by Saravanan in Programming.1 comment so far
Effective Java Programming Language Guide by Joshua Bloch is one of the book I always recommend to java users who want to write the best java code. After reading the book, you can find big difference in the way you think and write java code.
A must read book for every java programmer.
JVM – Heap and GC Tuning Primer March 10, 2007
Posted by Saravanan in Programming.add a comment
This is the second part of my earlier post JVM – GC Tuning
Let us start our JVM heap tuning by identifying the factors which influences the memory management
1. Number of CPUs in the box
2. Max heap size available
3. Object creation rate in the application
4. How long the objects will be required
5. Average session time
6. Tradeoff between GC and Performance
Tradeoff between GC and Performance is very critical and if you tune for one, the other will get impacted. Keeping both of them within the acceptable limit is the key while tuning JVM.
What are we looking for in the application? Is it performance improvement or stability improvement?
If improving performance is the objective
Heap Tuning – Move the objects very quickly to the older generation. Keep young generation free for new objects.
GC Tuning – Ensure objects are collected quickly in young generation. If it is not collected, move to old generation immediately. Young generation should be kept free as much as possible for high performance applications else while processing, JVM will wait for GC to free up young generation.
If improving stability is the objective
Heap Tuning – Ensure only required objects are moved to old generation.
GC Tuning – Ensure objects are collected quickly and not moved to other spaces unnecessarily
So now what are the minimal parameters required
1. Max and min heap size
2. Young generation space – Within heap, what is the young generation size
3. Survivor ratio – Ratio of the Eden/survivor space size. Young generation is divided into Eden and 2 survivor spaces. Both the survivor spaces have the same size.
3. Max threshold value – How many minor GC the object can survive before moved to old generation
4. GC algorithms
GC and Heap tuning will be challenging when the max heap size available in small. Let us take a hypothetical case of web application where stability is the primary requirement and max heap memory available is only 256 MB. The application was developed long back and developers did not worry about the memory constraints and now due increased usage, application encounters out of memory. Most of the developers would have encountered such applications in their career.
How we can apply the above parameters for this scenario.
1. Max and min heap size – 256 MB. Not much option here. Max available is 256 MB only.
2. Young generation space – Stability will be impacted when too many objects are moved to old generation very quickly and if they cannot be collected quickly. So we need to ensure we have big young generation. Let us go for 128 MB.
3. Survivor ratio – Objects are first created in eden, then moved to survivor spaces before they are moved to old or tenured space. Let us maximize the survivor space by opting for value 2. With this setting, eden size will be 64 MB and each survivor space will be 32 MB. (In case of high performance applications, survivor space will set as 20000 so that the size of survivor space will be minimal and objects will be promoted to old generation quickly.
3. Max threshold value – Since our survivor space is big, let us keep this value as 10. The default is around 30.
4. GC algorithms – Opt for new generational parallel GC and concurrent mark-sweep collector. Classical concurrent collector will for 68% of space to get filled up before running full GC. Since we have limited old generation space, include incremental collector so that as and when objects are available it will be collected. These GC algorithms are selected based on heap size. If the heap size is large (few gigs), then throughput collectors are more efficient than this.
The values I showed above are very aggressive to improve the stability. As we all know these values cannot be applied directly without a detailed study of factors, which will influence the memory management in JVM.
JVM – GC Tuning March 6, 2007
Posted by Saravanan in Programming.add a comment
Have you ever encountered the situation where your application goes down in production every day and you are clueless what to do? I went through that situation when we moved our application from iPlanet to Tomcat and it started going down every day during peak hours. After tuning the heap and GC parameter, we stabilized it. While working on this, I searched the internet for JVM tuning primer but could not find one. Though lot of information is available, a primer stuff that will help in identifying the parameters was missing. In the next couple of post, I will put my learning’s in the form of primer and hope it will be useful for others also.

